unordered containers emplace

Paolo Carlini paolo.carlini@oracle.com
Wed Dec 7 12:03:00 GMT 2011


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.



More information about the Libstdc++ mailing list