This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] Add C++14's dynarray container (23.3.4, n3662).


On 25 September 2013 23:39, Rüdiger Sonderfeld wrote:
> Hello,
> I've also written an implementation for C++14's std::dynarray.
> It theoretically supports both memory allocation using `operator new'
> and `alloca'.  (Switch by #defining USE_ALLOCA at the moment.)  However the
> alloca implementation is buggy because std::__uninitialized* seems to have
> issues initialising the memory.

You can't use alloca, as you've realised, and you can't use the
__uninitialized_*_a functions either. They use
std::allocator_traits<Alloc>::construct(), which does not implement
"uses-allocator construction". Wrapping the allocator in
std::scoped_allocator_adaptor would give something very similar to
uses-allocator construction, but you can just use the utilities in
<bits/uses_allocator.h> to do it correctly.

I have attached my prototype heap-based implementation, which doesn't
try to use the stack, but does implement uses-allocator construction,
with the help of <bits/uses_allocator.h>.

> Another problem is the allocator constructor interface.  Which seems to be
> covered by this LWG issue:
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#2255

Yes, I implemented the first resolution in my dynarray prototype.

Attachment: dynarray
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]