boost::python handles boost::shared_ptr specially...

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

boost::python handles boost::shared_ptr specially...

Neal Becker
Will std::shared_ptr just work also?

_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Reply | Threaded
Open this post in threaded view
|

Re: boost::python handles boost::shared_ptr specially...

Jim Bosch-2
On 02/06/2012 11:33 AM, Neal Becker wrote:
> Will std::shared_ptr just work also?

Just tried the experiment, albeit with slightly old versions.

As of gcc 4.4 (with -std=gnu++0x) and Boost 1.47, it looks like
Boost.Python doesn't even recognize std::shared_ptr as any kind of smart
pointer, let alone an equivalent to boost::shared_ptr.

That's definitely going to need fixing in the near future.

Jim
_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Reply | Threaded
Open this post in threaded view
|

Re: boost::python handles boost::shared_ptr specially...

Neal Becker
Jim Bosch wrote:

> On 02/06/2012 11:33 AM, Neal Becker wrote:
>> Will std::shared_ptr just work also?
>
> Just tried the experiment, albeit with slightly old versions.
>
> As of gcc 4.4 (with -std=gnu++0x) and Boost 1.47, it looks like
> Boost.Python doesn't even recognize std::shared_ptr as any kind of smart
> pointer, let alone an equivalent to boost::shared_ptr.
>
> That's definitely going to need fixing in the near future.
>
> Jim

Thanks:
https://svn.boost.org/trac/boost/ticket/6545

_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Reply | Threaded
Open this post in threaded view
|

Re: boost::python handles boost::shared_ptr specially...

Václav Šmilauer
In reply to this post by Neal Becker
> Will std::shared_ptr just work also?
I asked this question some time ago here:
http://stackoverflow.com/questions/6568952/c0x-stdshared-ptr-vs-boostshared-ptr

To summarize: you need to define free get_pointer<T> functions for T=your
shared_ptr type and it will work. I eventyallu did not go that way because
boost::serialization (which I also needed) will not work with std::shared_ptr.


_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Reply | Threaded
Open this post in threaded view
|

Re: boost::python handles boost::shared_ptr specially...

Jim Bosch-2
On 02/12/2012 01:01 PM, VáclavŠmilauer wrote:
>> Will std::shared_ptr just work also?
> I asked this question some time ago here:
> http://stackoverflow.com/questions/6568952/c0x-stdshared-ptr-vs-boostshared-ptr
>
> To summarize: you need to define free get_pointer<T>  functions for T=your
> shared_ptr type and it will work. I eventyallu did not go that way because
> boost::serialization (which I also needed) will not work with std::shared_ptr.
>

This would be a good start; it would make the std::shared_ptr support at
least as good as, say, std::auto_ptr.  It wouldn't be quite enough in
some cases, though, because Boost.Python does a lot of special things
for boost::shared_ptr, related to fact that it can have custom deleters.

In particular, if you have a Boost.Python-wrapped C++ object that is
held *by-value* inside a PyObject*, you can actually pass that to a C++
function by boost::shared_ptr, because Boost.Python creates that
shared_ptr on the fly with a custom deleter that holds the PyObject*.
That's should also be possible with std::shared_ptr, and Boost.Python
would need to be told about that too.

Jim

_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig