[C++-sig] std::tr1::shared_ptr and C++ Singletons

Stefan Seefeld seefeld at sympatico.ca
Thu Mar 15 23:26:52 CET 2007


Piotr Jaroszynski wrote:
>> 1) class_<Foo, std::tr1::shared_ptr<Foo> > doesn't work=compile errors
>> while boost::shared_ptr does. In the code I am writing bindings for
>> std::tr1::shared_ptr is used.
> The fix is rather simple, one needs to declare the following get_pointer 
> template before including boost/python.hpp. Maybe it's worth adding to the 
> boost?
> 
> namespace boost {
> template<class T> inline T * get_pointer(std::tr1::shared_ptr<T> const & p){
>         return p.get();
> }
> }

As I said on IRC: I don't think this is 'correct', as boost and tr1 are two
disjunct sets of APIs. I don't know the details of how the converters work,
but I'd guess just declaring the above get_pointer() function so it makes
its way into the overload set seen when the compiler instantiates the conerter
harness should be enough.

If it isn't, a (simple, minimal) test case may be a good idea. :-)

Regards,
		Stefan

-- 

      ...ich hab' noch einen Koffer in Berlin...



More information about the Cplusplus-sig mailing list