Boost logo

Boost :

Subject: Re: [boost] [cpo-proposal] presentation of the idea
From: Larry Evans (cppljevans_at_[hidden])
Date: 2013-08-19 09:10:43


On 08/19/13 07:54, Larry Evans wrote:
> On 08/19/13 06:59, Thorsten Ottosen wrote:
[snip]
>> On 16-08-2013 15:33, Larry Evans wrote:
>>> On 08/16/13 06:00, Thorsten Ottosen wrote:
>>> [snip]
>> That sounds like the basic idea. Alignment may not be needed if we
>> assume some kind of maximal alignment. Sizeof may not be needed either
>> if the syntax for adding objects is
>>
>> cont.push_back<Derived>( x, y );
>>
>
> Using a templated push_back, IIUC, would require some sort of
> container, such as std::vector<char> cont, which contains contigous
> storage, and the push_back should find the next location, i_aligned,
> in std::vector<char> which is at alignment, alignof(Derived).
> and would then push_back i_aligned chars, then further push_back
> sizeof(Derived) char's, the new inplace at cont.begin()+i_aligned.
>
> Does that make sense?
>
OOPS. If all those push_back's of a char causes the vector to be
resized in placed in a different location, then wouldn't that require
all the realignments for each element to be recalculated :(

Hmmm. Not if &cont[0] is stored at a max aligned location,
which I assume it would be since the storage would be created
on the heap with new[] which, according to the c++ standard
( can't remember which page or section), returns a maximally
aligned storage location. And since the start of cont
is maximally aligned, any offsets in that cont with a given
alignment would have the same alignment when moved, IIUC.

-regards,
Larry

[snip]


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk