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

Noah Schwartz noah.schwartz1 at gmail.com
Thu Oct 19 00:43:34 CEST 2006


On Wednesday 18 October 2006 16:55, Roman Yakovenko wrote:
> On 10/18/06, Roman Yakovenko <roman.yakovenko at gmail.com> wrote:
> > > > Take a look on this post:
> > > > http://aspn.activestate.com/ASPN/Mail/Message/cpp-sig/2261029
> > > >
> > > > I am not sure about indexing suite v2, because you can change call
> > > > policies: return_internal_reference.
> > > >
> > > > You can find documentation for indexing suite v2 here:
> > > > http://tinyurl.com/yndgbw
> > >
> > > Seems to indicate that I need to use shared_ptr's instead of regular
> > > pointers...
> > >
> > > Unfortunately I have thousands and thousands of line of C++ code all
> > > written -- none of which use shared_ptrs. I have never used a
> > > shared_ptr but, I get the feeling that I am going to have to change a
> > > lot of code and retest everything :(
> >
> > Wait a little, I will try indexing suite v2 for you.
>
> Okay, I tested your use case with indexing suite v2. If you set container
> call policy to return_internal_reference all works as expected.
>
> Here you will find all setup information and source code for v2 suite:
> http://svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/indexing_suite_v2
>/
>
> It should not take too much time to install it.

Ok...I will definitely look into this later tonight.

I have read in several places that using return_internal_reference is a bad 
idea. I am already using it in several places. 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? Would you recommend that I use shared_ptr's 
instead?

Noah



More information about the Cplusplus-sig mailing list