Boost logo

Boost :

Subject: Re: [boost] [cpo-proposal] presentation of the idea
From: Larry Evans (cppljevans_at_[hidden])
Date: 2013-08-20 08:11:02

On 08/20/13 06:55, Larry Evans wrote:
> On 08/20/13 04:23, Thorsten Ottosen wrote:
>> On 20-08-2013 11:04, Rob Stewart wrote:
>>> On Aug 19, 2013, at 9:44 AM, Thorsten Ottosen
>>> <thorsten.ottosen_at_[hidden]> wrote:
>>>> Yes, at this level it is nice to take advantage of the memcopying
>>>> built into vector<char>.
>>> Here's the problem. Replicating the bits of and object isn't the same
>>> as copying it. Many classes store a this pointer or rely on a data
>>> member address as a unique key, etc. Copy constructors must run.
> Good catch. Thanks Rob.
However, this is a specific case of a more general problem.
Suppose the polymorphic_object at container[i+j] contains a
pointer of the polymorphic_obect at container[i]. Then
after resizing, the pointer will become invalid. The
specific case Rob mentions is when j=0.

Maybe the class should just warn the user not to do this
or suggest a workaround, maybe instead of storing a pointer,
just store the index into the container?


Boost list run by bdawes at, gregod at, cpdaniel at, john at