[C++-sig] C++ object pointers contained in a vector

Roman Yakovenko roman.yakovenko at gmail.com
Thu Oct 19 07:58:31 CEST 2006


On 10/19/06, Noah Schwartz <noah.schwartz1 at gmail.com> wrote:
> I have read in several places that using return_internal_reference is a bad
> idea. I am already using it in several places.

It is not bad, you just should understand what you are doing.

> I don't expect to have any
> issues with invalid references to objects in a container.
>
> Is there anything else I should watch out when using
> return_internal_reference?

In this case you will have to manage lifetime of objects ( keep alive
) created from
Python and added to your containers.

> Would you recommend that I use shared_ptr's
> instead?

The answer is obvious: yes.


-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/



More information about the Cplusplus-sig mailing list