Add std::unordered_* C++11 allocator support

François Dumont frs.dumont@gmail.com
Fri Mar 15 20:46:00 GMT 2013


Hello

     I think I have completed support of C++11 allocators in unordered 
containers.

     I preferred to remove the const of the key part to enable copy/move 
assignment in the context of std::unordered_map/multimap. This will give 
more behavioral consistency accross all the std::unordered_* types.

     I took the opportunity to remove include of <bits/stl_algobase.h> 
from <unordered_set> and <unordered_map> Standard headers. It became 
useless since _Prime_rehash_policy definition that is using 
std::lower_bound moved to src/c++11/hashtable_c0x.cc. This source file 
doesn't need it neither because bits/stl_algobase.h is included by the 
way through an other path, should I add it explicitly ?

     I also noticed that operator=(std::initializer_list<>) could reuse 
existing nodes rather than reallocating everything. I kept it for a 
future patch.

2013-03-31  François Dumont <fdumont@gcc.gnu.org>

     * include/bits/move.h (std::__move_assign_if_noexcept): New.
     * include/bits/hashtable_policy.h: Add C++11 allocator support.
     * include/bits/hashtable.h: Likewise.
     * include/bits/unordered_set.h: Likewise.
     * include/bits/unordered_map.h: Likewise.
     * include/debug/unordered_set: Likewise.
     * include/debug/unordered_map: Likewise.
     * include/std/unordered_set: Remove bits/algobase.h
     include. Replace bits/alloc_traits.h by ext/alloc_traits.h.
     * include/std/unordered_map: Likewise.
     * testsuite/util/testsuite_counter_type.h: Add count of destructors.
     * testsuite/23_containers/unordered_set/
     not_default_constructible_hash_neg.cc: Adapt line number.
     * testsuite/23_containers/unordered_set/instantiation_neg.cc: Likewise.
     * testsuite/23_containers/unordered_set/allocator/copy.cc: New.
     * testsuite/23_containers/unordered_set/allocator/copy_assign.cc: New.
     * testsuite/23_containers/unordered_set/allocator/minimal.cc: New.
     * testsuite/23_containers/unordered_set/allocator/move_assign.cc: New.
     * testsuite/23_containers/unordered_set/allocator/noexcept.cc: New.
     * testsuite/23_containers/unordered_set/allocator/swap.cc: New.
     * testsuite/23_containers/unordered_multiset/allocator/copy.cc: New.
     * testsuite/23_containers/unordered_multiset/allocator/copy_assign.cc:
     New.
     * testsuite/23_containers/unordered_multiset/allocator/minimal.cc: New.
     * testsuite/23_containers/unordered_multiset/allocator/move_assign.cc:
     New.
     * testsuite/23_containers/unordered_multiset/allocator/noexcept.cc: 
New.
     * testsuite/23_containers/unordered_multiset/allocator/swap.cc: New.
     * testsuite/23_containers/unordered_map/allocator/copy.cc: New.
     * testsuite/23_containers/unordered_map/allocator/copy_assign.cc: New.
     * testsuite/23_containers/unordered_map/allocator/minimal.cc: New.
     * testsuite/23_containers/unordered_map/allocator/move_assign.cc: New.
     * testsuite/23_containers/unordered_map/allocator/noexcept.cc:
     New.
     * testsuite/23_containers/unordered_map/allocator/swap.cc: New.
     * testsuite/23_containers/unordered_multimap/allocator/copy.cc: New.
     * testsuite/23_containers/unordered_multimap/allocator/copy_assign.cc:
     New.
     * testsuite/23_containers/unordered_multimap/allocator/minimal.cc: New.
     * testsuite/23_containers/unordered_multimap/allocator/move_assign.cc:
     New.
     * testsuite/23_containers/unordered_multimap/allocator/noexcept.cc: 
New.
     * testsuite/23_containers/unordered_multimap/allocator/swap.cc: New.

Tested under Linux x86_64 normal and debug modes.

Ok to commit when 4.9 stage 1 open ?

François

-------------- next part --------------
A non-text attachment was scrubbed...
Name: unordered_alloc.patch
Type: text/x-patch
Size: 123868 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20130315/3219695c/attachment.bin>


More information about the Libstdc++ mailing list