
25 Jan
2010
25 Jan
'10
7:08 a.m.
Jeff Flinn wrote:
The last statement below fails to compile with boost 1.39.0 on MSVC 8. Am I doing anything obviously wrong? Any help is appreciated.
...
boost::bind(&boost::make_shared<Y, int&>, boost::ref(i));
Under C++03 compilers, make_shared takes its arguments by const reference: template<class T, class A1> shared_ptr<T> make_shared( A1 const & a1 ); MSVC doesn't like the A1=int& case because it forms the questionably valid "int& const&". boost::bind( &boost::make_shared<Y, boost::reference_wrapper<int> >, boost::ref(i) ); works though. This is what make_shared<Y>( ref(i) ) would instantiate.