
On 19-08-2013 14:54, Larry Evans wrote:
On 08/19/13 06:59, Thorsten Ottosen wrote:
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?
Yes. And I think that very often i_aligned would be zero due to the internal padding in classes. -Thorsten