fork download
  1. #include <boost/interprocess/smart_ptr/unique_ptr.hpp>
  2. using namespace boost::interprocess;
  3.  
  4. struct poly_deleter
  5. {
  6. template<typename T>
  7. void operator()(T *p)
  8. {
  9. delete p;
  10. }
  11. };
  12.  
  13. typedef unique_ptr<int, poly_deleter> u_ptr;
  14.  
  15. u_ptr func()
  16. {
  17. return u_ptr();
  18. }
  19.  
  20. int main()
  21. {
  22. u_ptr u;
  23. u = func();
  24. }
  25.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:23: error: ambiguous overload for ‘operator=’ in ‘u = func()()’
/usr/include/boost/interprocess/smart_ptr/unique_ptr.hpp:212: note: candidates are: boost::interprocess::unique_ptr<T, D>& boost::interprocess::unique_ptr<T, D>::operator=(boost::interprocess::rv<boost::interprocess::unique_ptr<T, D> >&) [with T = int, D = poly_deleter]
/usr/include/boost/interprocess/smart_ptr/unique_ptr.hpp:250: note:                 boost::interprocess::unique_ptr<T, D>& boost::interprocess::unique_ptr<T, D>::operator=(int boost::interprocess::unique_ptr<T, D>::nat::*) [with T = int, D = poly_deleter]
stdout
Standard output is empty