unordered containers emplace
François Dumont
frs.dumont@gmail.com
Thu Dec 8 21:14:00 GMT 2011
So here is the new proposition with additional tests experimenting
emplace insertion using piecewise_construct.
2011-12-08 François Dumont <fdumont@gcc.gnu.org>
* include/bits/hashtable.h (_Hashtable<>::emplace,
_Hashtable<>::emplace_hint): Add.
* include/debug/unordered_set (unordered_set<>::emplace,
unordered_set<>::emplace_hint, unordered_multiset<>::emplace,
unordered_multiset<>::emplace_hint): Add.
* include/debug/unordered_map (unordered_map<>::emplace,
unordered_map<>::emplace_hint, unordered_multimap<>::emplace,
unordered_multimap<>::emplace_hint): Add.
* testsuite/23_containers/unordered_map/modifiers/emplace.cc: New.
* testsuite/23_containers/unordered_multimap/modifiers/emplace.cc:
New.
* testsuite/23_containers/unordered_set/modifiers/emplace.cc: New.
* testsuite/23_containers/unordered_multiset/modifiers/emplace.cc:
New.
* testsuite/util/testsuite_container_traits.h
(traits_base::has_emplace): Add and defined as std::true_type for
unordered containers.
* testsuite/util/exception/safety.h (emplace, emplace_hint):
Add and
use them in basic_safety exception test case.
* doc/xml/manual/status_cxx2011.xml: Update unordered containers
status.
Tested under linux x86_64 normal and debug mode.
I haven't touch to profile mode for the moment even if I noticed that
this mode is broken since recent hashtable modifications. I will submit
an other patch for that.
Ok to commit ?
François
On 12/07/2011 09:43 PM, Paolo Carlini wrote:
> Hi,
>
> On 12/07/2011 09:37 PM, François Dumont wrote:
>> On 12/07/2011 01:01 PM, Paolo Carlini wrote:
>>> 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.
>> This is what I did to begin but it failed to compile, g++ do not
>> know then when to stop considering arguments as part of the _Args....
>> I consider it was a normal limitation of using variadic templates, if
>> so I can invert parameters of _M_insert to have consistency.
> Of course, sorry. This is absolutely expected, I just didn't consider,
> formally, that _M_insert is not variadic.
>>>
>>> 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.
>> Good point, I hadn't notice this potential issue. I am lucky that
>> the library is well designed making my patch not so bad. I will add
>> the necessary tests and resubmit a patch.
> Essentially, I would just recommend adding some tests per Jon's comment.
>
> Thanks!
> Paolo.
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: unordered_emplace.patch
Type: text/x-patch
Size: 28719 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20111208/79b2fd4c/attachment.bin>
More information about the Libstdc++
mailing list