[C++-sig] std::tr1::shared_ptr as boost::shared_ptr

Roman Yakovenko roman.yakovenko at gmail.com
Fri Apr 20 18:53:32 CEST 2007


On 4/20/07, Piotr Jaroszynski <p.jaroszynski at gmail.com> wrote:
> bp::class_<Foo, std::tr1::shared_ptr<Foo> > ...
> bp::class_<Derived, std::tr1::shared_ptr<Derived>, bp::bases<Foo> > ...
> bp::implicitly_convertible<std::tr1::shared_ptr<Foo>,
> std::tr1::shared_ptr<Derived> >();
>
> How can I make it working just as with boost::shared_ptr?

There is no implicit conversion from a base class to the dervied.
The other way will work:

bp::implicitly_convertible<std::tr1::shared_ptr<Derived>,
std::tr1::shared_ptr<Foo> >();

> Btw. I have seen [2] already, but it doesn't seem to cover that.

It does :-)

>
> [1] -
>
http://language-binding.net/pyplusplus/troubleshooting_guide/shared_ptr/shared_ptr.html
> [2] -
>
http://language-binding.net/pyplusplus/troubleshooting_guide/smart_ptrs/smart_ptrs.html

Glad you found this useful

> --
> Best Regards,
> Piotr Jaroszynski
>



-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20070420/0d8d7658/attachment.htm>


More information about the Cplusplus-sig mailing list