The shared_ptr
constructor is declared as:
template<class Other> shared_ptr(auto_ptr<Other>& ap);
Note that it requires a reference to the lvalue constant. It does this so that it can correctly release the auto_ptr
property for the object.
Since it accepts a reference to a non-constant lvalue, you cannot call this member function with rvalue, which is what you are trying to do:
return boost::shared_ptr(only_auto::create_only_auto());
You need to save the result of only_auto::create_only_auto()
in a variable, and then pass this variable to the shared_ptr
constructor:
std::auto_ptr<only_auto> p(only_auto::create_only_auto()); return boost::shared_ptr<only_auto>(p);
source share