Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


On Thu, Feb 16, 2012 at 4:01 PM, Michael Meeks <michael.meeks@suse.com> wrote:

On Thu, 2012-02-16 at 15:20 -0500, Kohei Yoshida wrote:
Is it a safe code?

     pForbiddenCharacters = &maMap[ nLanguage ];
     return pForbiddenCharacters;
...
So, in theory, taking the address of a returned object which itself is a
reference to the instance stored in the container is very much safe.

       I guess :-) I imagine the real problem here is that any kind of
operation on the stl container could then realloc the underlying memory
in some way, busting the reference / pointer you handed out elsewhere;
so it looks only transiently safe to me ;-)

Of course.  If the content of the container changes all bets are off.
But I thought that was a given in this context (the same way all
associated iterators are invalid once the state of the container
changes).

My understanding of the question was, does the address of the object
point to the real object inside the container or a temporary object?
And my answer was it points to the real object inside the container.
I didn't mean to insinuate anything else. Sorry if I gave such
impression.

Kohei

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.