|
Boost : |
Subject: Re: [boost] [cpo-proposal] presentation of the idea
From: Ben Pope (benpope81_at_[hidden])
Date: 2013-08-22 22:54:27
On 23/08/13 00:27, Larry Evans wrote:
> On 08/22/13 10:38, Thorsten Ottosen wrote:
> [snip]
>>
>>> OTOH, if only offsets were used, then wouldn't simply using
>>> the vector<char>::swap work?
>>
>> Doesn't that have the same problems as memcpy'ing? That is, if we don't
>> call the constructor, we don't get the implicit stuff inside the
>> classes properly constructed.
>
> OK. Maybe so. I was still under the impression that the only
> problem with simply copying the old std::vector<char>::data() to
> a new std::vector<char>::data() is that this could copy the
> raw pointers verbatim which would mean those raw pointers
> in the new std::vector<char>::data() would point somewhere
> still in the old std::vector<char>::data(), which would be
> invalid after the resize. OTOH, with offsets instead of
> raw pointers, the offsets would be w.r.t. the
> existing std::vector<char>::data(); hence, would still be
> valid since offsets would remain invariant.
But how can you be sure an arbitrary non-POD object in the vector
doesn't hold a pointer to itself?
Also, this problem has just been found in Folly fbvector:
https://github.com/facebook/folly/issues/35
Ben
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk