This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: unordered containers emplace
- From: Paolo Carlini <paolo dot carlini at oracle dot com>
- To: François Dumont <frs dot dumont at gmail dot com>
- Cc: "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>, Jonathan Wakely <jwakely dot gcc at gmail dot com>, Christopher Jefferson <chris at bubblescope dot net>
- Date: Wed, 07 Dec 2011 13:01:38 +0100
- Subject: Re: unordered containers emplace
- References: <4EDBD234.8030208@gmail.com>
Hi,
Hi
This is the implementation of emplace and emplace_hint for
unordered containers. For the moment in emplace_hint the hint iterator
is not considered like in the current insert with hint implementation.
detail: for consistency with _M_insert, I think we should swap the
arguments of _M_emplace, last true_type / false_type.
Much more importantly, I don't think we are doing the right thing for
map / multimap; honestly I cannot say to have followed in any special
detail the standardization of the piecewise_construct_t things, at the
corresponding ISO Meetings, but I think we have to involve that pair
constructor in this case. I'm adding Jon and Chris in CC for you to have
more help on this, please also have a look to various papers authored by
Pablo Halpern et al over the last 2/3 years.
If I'm not mistaken, a simple way of achieving this - given that for now
we are not getting into the scoped_allocator business - could be having
internally something like:
_M_emplace_do()
_M_emplace_do(_Arg1&&, _Args&&...)
the first one is just a special case of everything default constructed.
The latter essentially would build two tuples, the first one by
forwarding only _Arg1, the second _Args..., and would call
_M_allocate_node with piecewise_construct and the two tuples as
arguments (also see the existing piecewise* pair testcases for details)
Eventually you should be able to write more consistent testcases between
set / map.
Paolo.