diff options
| author | fdumont <fdumont@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-04-22 20:22:07 +0000 |
|---|---|---|
| committer | fdumont <fdumont@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-04-22 20:22:07 +0000 |
| commit | 60eba405d23ddeb2d0a289d2b79bebdd89b7c01b (patch) | |
| tree | 5569c55c22034b5f3fd78df58dc634c6e5709ead /libstdc++-v3/include/debug/unordered_map | |
| parent | 609c541fd0e5e1a46f856ce125e0249352b995f2 (diff) | |
| download | ppe42-gcc-60eba405d23ddeb2d0a289d2b79bebdd89b7c01b.tar.gz ppe42-gcc-60eba405d23ddeb2d0a289d2b79bebdd89b7c01b.zip | |
2013-04-22 François Dumont <fdumont@gcc.gnu.org>
* 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.
* include/ext/throw_allocator.h: Add checks on calls to allocator
construct/destroy.
(std::hash<__gnu_cxx::throw_value_limit>): Add conditional throw.
(std::hash<__gnu_cxx::throw_value_random>): Likewise.
* testsuite/util/regression/rand/priority_queue
/container_rand_regression_test.tcc: Adapt.
* testsuite/util/regression/rand/assoc
/container_rand_regression_test.tcc: Likewise.
* testsuite/util/testsuite_counter_type.h: Add count of destructors.
* testsuite/23_containers/unordered_set
/not_default_constructible_hash_neg.cc: Adjust dg-error 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@198158 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/debug/unordered_map')
| -rw-r--r-- | libstdc++-v3/include/debug/unordered_map | 88 |
1 files changed, 70 insertions, 18 deletions
diff --git a/libstdc++-v3/include/debug/unordered_map b/libstdc++-v3/include/debug/unordered_map index a826b0190d5..d62deac3917 100644 --- a/libstdc++-v3/include/debug/unordered_map +++ b/libstdc++-v3/include/debug/unordered_map @@ -60,6 +60,9 @@ namespace __debug typedef typename _Base::const_local_iterator _Base_const_local_iterator; typedef typename _Base::local_iterator _Base_local_iterator; + typedef __gnu_cxx::__alloc_traits<typename + _Base::allocator_type> _Alloc_traits; + public: typedef typename _Base::size_type size_type; typedef typename _Base::hasher hasher; @@ -96,12 +99,27 @@ namespace __debug __gnu_debug::__base(__last), __n, __hf, __eql, __a) { } - unordered_map(const unordered_map& __x) = default; + unordered_map(const unordered_map&) = default; unordered_map(const _Base& __x) : _Base(__x) { } - unordered_map(unordered_map&& __x) = default; + unordered_map(unordered_map&&) = default; + + explicit + unordered_map(const allocator_type& __a) + : _Base(__a) + { } + + unordered_map(const unordered_map& __umap, + const allocator_type& __a) + : _Base(__umap._M_base(), __a) + { } + + unordered_map(unordered_map&& __umap, + const allocator_type& __a) + : _Base(std::move(__umap._M_base()), __a) + { } unordered_map(initializer_list<value_type> __l, size_type __n = 0, @@ -115,33 +133,41 @@ namespace __debug unordered_map& operator=(const unordered_map& __x) { - *static_cast<_Base*>(this) = __x; + _M_base() = __x._M_base(); this->_M_invalidate_all(); return *this; } unordered_map& operator=(unordered_map&& __x) + noexcept(_Alloc_traits::_S_nothrow_move()) { - // NB: DR 1204. - // NB: DR 675. __glibcxx_check_self_move_assign(__x); - clear(); - swap(__x); + bool xfer_memory = _Alloc_traits::_S_propagate_on_move_assign() + || __x.get_allocator() == this->get_allocator(); + _M_base() = std::move(__x._M_base()); + if (xfer_memory) + this->_M_swap(__x); + else + this->_M_invalidate_all(); + __x._M_invalidate_all(); return *this; } unordered_map& operator=(initializer_list<value_type> __l) { - this->clear(); - this->insert(__l); + _M_base() = __l; + this->_M_invalidate_all(); return *this; } void swap(unordered_map& __x) + noexcept(_Alloc_traits::_S_nothrow_swap()) { + if (!_Alloc_traits::_S_propagate_on_swap()) + __glibcxx_check_equal_allocs(__x); _Base::swap(__x); _Safe_base::_M_swap(__x); } @@ -490,6 +516,9 @@ namespace __debug typedef typename _Base::const_local_iterator _Base_const_local_iterator; typedef typename _Base::local_iterator _Base_local_iterator; + typedef __gnu_cxx::__alloc_traits<typename + _Base::allocator_type> _Alloc_traits; + public: typedef typename _Base::size_type size_type; typedef typename _Base::hasher hasher; @@ -526,12 +555,27 @@ namespace __debug __gnu_debug::__base(__last), __n, __hf, __eql, __a) { } - unordered_multimap(const unordered_multimap& __x) = default; + unordered_multimap(const unordered_multimap&) = default; unordered_multimap(const _Base& __x) : _Base(__x) { } - unordered_multimap(unordered_multimap&& __x) = default; + unordered_multimap(unordered_multimap&&) = default; + + explicit + unordered_multimap(const allocator_type& __a) + : _Base(__a) + { } + + unordered_multimap(const unordered_multimap& __umap, + const allocator_type& __a) + : _Base(__umap._M_base(), __a) + { } + + unordered_multimap(unordered_multimap&& __umap, + const allocator_type& __a) + : _Base(std::move(__umap._M_base()), __a) + { } unordered_multimap(initializer_list<value_type> __l, size_type __n = 0, @@ -545,33 +589,41 @@ namespace __debug unordered_multimap& operator=(const unordered_multimap& __x) { - *static_cast<_Base*>(this) = __x; + _M_base() = __x._M_base(); this->_M_invalidate_all(); return *this; } unordered_multimap& operator=(unordered_multimap&& __x) + noexcept(_Alloc_traits::_S_nothrow_move()) { - // NB: DR 1204. - // NB: DR 675. __glibcxx_check_self_move_assign(__x); - clear(); - swap(__x); + bool xfer_memory = _Alloc_traits::_S_propagate_on_move_assign() + || __x.get_allocator() == this->get_allocator(); + _M_base() = std::move(__x._M_base()); + if (xfer_memory) + this->_M_swap(__x); + else + this->_M_invalidate_all(); + __x._M_invalidate_all(); return *this; } unordered_multimap& operator=(initializer_list<value_type> __l) { - this->clear(); - this->insert(__l); + _M_base() = __l; + this->_M_invalidate_all(); return *this; } void swap(unordered_multimap& __x) + noexcept(_Alloc_traits::_S_nothrow_swap()) { + if (!_Alloc_traits::_S_propagate_on_swap()) + __glibcxx_check_equal_allocs(__x); _Base::swap(__x); _Safe_base::_M_swap(__x); } |

