[RFC] Add C++14's dynarray container (23.3.4, n3662).
Joe Buck
Joe.Buck@synopsys.COM
Thu Sep 26 00:57:00 GMT 2013
On Thu, Sep 26, 2013 at 12:39:44AM +0200, 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.
>
> In theory dynarray should be the C++ equivalent of VLAs. Which would require
> stack allocation. But I'm not sure if this can be safely handled at all and
> the implementation should instead simply stick to operator new/delete. Maybe
> this could be a configuration option (not sure how such a thing would be
> handled).
My two cents as an observer:
It doesn't seem that there is much point to a dynarray that is on the heap
because we already have std::vector, and the rationale for dynarray
appears to be that it is on the stack and so avoids heap overhead. So I
don't think that dynarray should ever be on the heap.
As you say, dynarray should be the C++ equivalent of VLAs, so ideally the
compiler could use the same code as is used for VLAs, perhaps by creating
new builtin functions if there isn't something that can already be used.
It might not be possible to produce a quality library-only implementation,
compiler support might be needed.
More information about the Libstdc++
mailing list