[C++-sig] std::tr1::shared_ptr and C++ Singletons
Piotr Jaroszynski
p.jaroszynski at gmail.com
Mon Mar 12 22:31:06 CET 2007
Hello,
I have 2 problems:
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.
2) I am not sure how to handle C++ Singletons. I thought that the proper way
is to use return_value_policy<reference_existing_object>() for functions
returning pointers to them as described in [1], but at the bottom of [2] Dave
seems to disagree or I am missing something. Btw. how would you handle the
situation when the get_it() is a method of object you want to get? I used:
def("get_it", &Foo::get_instance,
return_value_policy<reference_existing_object>());
Is it the best solution?
[1] - http://www.boost.org/libs/python/doc/v2/reference_existing_object.html
[2] - http://mail.python.org/pipermail/c++-sig/2005-January/008481.html
--
Best Regards,
Piotr Jaroszynski
More information about the Cplusplus-sig
mailing list