[C++-sig] return boost::shared_ptr<some internal>
Alex Leach
beamesleach at gmail.com
Fri Jun 14 14:32:51 CEST 2013
On Fri, 14 Jun 2013 12:57:48 +0100, Neal Becker <ndbecker2 at gmail.com>
wrote:
> I have a class that has a member
>
> something like this:
>
> class A {
> boost::shared_ptr<B> b;
>
> };
>
> boost::shared_ptr<B> get_b (A const& ...) {
> return A.b;
> }
>
> where class B is already exposed to python in a different module.
I think this depends on (at least) a few things:-
1. libboost_python shouldn't be linked statically into each extension.
If it is, then the to_python converter registry will be duplicated in each
extension, so one extension module wouldn't be able to locate to python
converters (e.g. class_'s) registered in other extensions.
2. Class B will need to be exposed with a shared_ptr as its instance
holder / object manager(?).. e.g.
class_<B, shared_ptr<B> >
...
3. Like you've said, you'll also need to import B into Python, but as
there's no inheritance involved between A and B (no 'bases<>' declared), I
don't think the import order is completely relevant here, so long as both
modules have inserted their to_python converters into a single registry.
HTH,
Alex
More information about the Cplusplus-sig
mailing list