I want to store a reference to an object in a boost::any
object. How do I initialize the boost::any object? I tried std::ref()
, but boost::any
gets initialized with std::reference_wrapper<>
. For example, the following
#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;
}
prints
std::reference_wrapper<int>
I want the boost::any
to contain int&
instead.