I have a c++ code which heavily uses shared_ptr
and STL. A common header says
#include<boost/shared_ptr.hpp>
using boost::shared_ptr; // for shared_ptr
using namespace std; // for STL
I wanted to switch to c++0x now to make use of the language features, using gcc 4.6 with -std=c++0x
. There is however std::shared_ptr
now as well, leading to ambiguity for unspecified shared_ptr
(boost::shared_ptr
vs std::shared_ptr
).
When switching to std::shared_ptr
instead, like this:
#include<memory>
using namespace std; // for STL; also imports std::shared_ptr
then I am getting problems with boost::python
, which works apprently with boost::shared_ptr
only (at least without further fiddling):
/usr/include/boost/python/object/make_ptr_instance.hpp:30:52: error: no matching function for call to 'get_pointer(const std::shared_ptr<Cell>&)'
My question therefore is
- if there is a simple solution to resolve the ambiguity between
boost::shared_ptr
andstd::shared_ptr
(other than not using c++0x for now), and also - if
boost::shared_ptr
will eventually be just an alias forstd::shared_ptr
; that would solve my problem automatically.
Thanks!
You need to the define the freestanding function 'get_pointer' for your shared pointer class for it to work with Boost Python. (Note that this enables you to write your own shared pointer, and still work with Boost Python: this is a conscious design effort to prevent tight coupling of distinct Boost libraries).
You might get that using the boost tr1 compatibility headers, but I haven't tried.
http://boost.cowic.de/rc/pdf/tr1.pdf