[C++-sig] how to handle bare references with a shared_ptr HeldType

David Abrahams dave at boost-consulting.com
Sat Sep 24 00:38:02 CEST 2005


Hans Meine <meine at kogs1.informatik.uni-hamburg.de> writes:

> On Thursday 22 September 2005 16:37, Gregory Price wrote:
>> Is there a way to tell Boost.Python not to make a shared_ptr
>> for this return value -- to override the HeldType just for this
>> function's return value?  Alternatively, to tell Boost.Python
>> always to leave bare A references as they are?
>>
>> Or perhaps there's a simpler solution that I'm missing.
>
> Ah.  I knew I was overlooking something.
> Is changing the HeldType an option for you?
>
> OTOH, if you use return_internal_reference, BP should know that creating a 
> shared_ptr with a refcount of 1 is evil..  is that really what it does?

No, that's not what it does.  When you use return_internal_reference
it creates a Python object holding the C++ object with a raw pointer.
Isn't that in the documentation?

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Cplusplus-sig mailing list