[unique_ptr] How should I assign unique_ptr returned from a factory function, possibly using boost::move, in C++03
Hi, the question is: how should I assign boost::interprocess::unique_ptr returned from a factory function, possibly using boost::move, in C++03? Here's an example: --- #include <boost/interprocess/smart_ptr/unique_ptr.hpp> using namespace boost::interprocess; class my_class { public: my_class() {} }; struct my_class_deleter { void operator()(my_class *p) {} }; typedef unique_ptr<my_class, my_class_deleter> uptr; uptr create() { return uptr(); } int main() { uptr x; x = create(); // return 0; } --- The problem is that gcc fails to compile the above code saying: main.cpp:22: error: ambiguous overload for ‘operator=’ in ‘x = create()()’ ../../boost_latest/boost/interprocess/smart_ptr/unique_ptr.hpp:211: note: candidates are: boost::interprocess::unique_ptr<T, D>& boost::interprocess::unique_ptr<T, D>::operator=(boost::rv<boost::interprocess::unique_ptr<T, D> >&) [with T = my_class, D = my_class_deleter] ../../boost_latest/boost/interprocess/smart_ptr/unique_ptr.hpp:249: note: boost::interprocess::unique_ptr<T, D>& boost::interprocess::unique_ptr<T, D>::operator=(int boost::interprocess::unique_ptr<T, D>::nat::*) [with T = my_class, D = my_class_deleter] I use gcc v4.4.3 and Boost v1.51.0. BTW: I posted the same question on StackOverflow: http://stackoverflow.com/questions/13086428/how-should-i-assign-boostinterpr...
participants (1)
-
Adam Romanek