[patch] No allocation for empty unordered containers
François Dumont
frs.dumont@gmail.com
Tue Aug 5 20:01:00 GMT 2014
On 04/08/2014 13:55, Jonathan Wakely wrote:
>
> If we don't make it noexcept then I see no point in avoiding
> allocation.
>
> (And if the functors and allocator can throw then the noexcept might
> have to be condition.)
>
> So please make sure we get that change as well during stage 1.
>
>
Hi
I know why move constructor must be noexcept but why default must
be too ?
If it is the only goal then easier and most natural approach is the
small attached patch. No yet fully tested so not a proposal yet.
Drawback is of course that we do not have only Standard constructors.
I can think of another solution using the rehash policy. We could
store in it the user hint and use it as soon as an element is inserted.
This way constructor with hint would simply prepare the rehash policy
and not allocate anything. But it is an additional std::size_t to store
in the memory footprint of the container and implementing it will tell
us if it is feasible.
François
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hashtable.patch
Type: text/x-patch
Size: 6055 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20140805/d0be8154/attachment.bin>
More information about the Libstdc++
mailing list