我想在对象中存储对对象的引用boost::any
。如何初始化 boost::any 对象?我试过了std::ref()
,但boost::any
被初始化为std::reference_wrapper<>
. 例如,以下
#include <boost/any.hpp>
#include <cxxabi.h>
#include <iostream>
int main(void)
{
int s;
int i = 0;
boost::any x(std::ref(i));
std::cout << abi::__cxa_demangle(x.type().name(), 0, 0, &s) << "\n";
return 0;
}
印刷
std::reference_wrapper<int>
我希望boost::any
改为包含int&
。