id summary reporter owner description type status milestone component version severity resolution keywords cc 7598 Unable to use operator=() for boost::interprocess::unique_ptr due to its ambiguity Adam Romanek Ion Gaztañaga "I'm not able to easily use `operator=()` of `boost::interprocess::unique_ptr`. See the example below: {{{ #include using namespace boost::interprocess; class my_class { public: my_class() {} }; struct my_class_deleter { void operator()(my_class *p) {} }; typedef unique_ptr 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& boost::interprocess::unique_ptr::operator=(boost::rv >&) [with T = my_class, D = my_class_deleter] ../../boost_latest/boost/interprocess/smart_ptr/unique_ptr.hpp:249: note: boost::interprocess::unique_ptr& boost::interprocess::unique_ptr::operator=(int boost::interprocess::unique_ptr::nat::*) [with T = my_class, D = my_class_deleter] }}} Now, when I change the `main()` function to something like this: {{{ int main() { uptr x = create(); return 0; } }}} the code compiles without any issues. I've been able to overcome this issue by using the following snippet: {{{ x = static_cast&>(create()); }}} It works, but it's not an elegant solution. I'm not even sure if it's a legal construct. I've also investigated `boost::interprocess::unique_ptr` implementation and I think I've found the problem. The conversion-to-bool operator messes up with the `operator=()`. I attached a patch that fixes this problem, however I'm not sure if it doesn't break any existing code. BTW: I use gcc v4.4.3 and Boost v1.51.0 on Ubuntu 10.04. BTW 2: Before I managed to overcome this issue I had written about it on stackoverflow.com: http://stackoverflow.com/questions/13086428/how-should-i-assign-boostinterprocessunique-ptr-returned-from-a-factory-func" Bugs closed To Be Determined interprocess Boost 1.51.0 Problem fixed