summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/include/debug
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/include/debug')
-rw-r--r--libstdc++-v3/include/debug/unordered_map88
-rw-r--r--libstdc++-v3/include/debug/unordered_set91
2 files changed, 141 insertions, 38 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);
}
diff --git a/libstdc++-v3/include/debug/unordered_set b/libstdc++-v3/include/debug/unordered_set
index 8e88addd87f..66898e243b1 100644
--- a/libstdc++-v3/include/debug/unordered_set
+++ b/libstdc++-v3/include/debug/unordered_set
@@ -60,6 +60,8 @@ 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 +98,27 @@ namespace __debug
__gnu_debug::__base(__last), __n,
__hf, __eql, __a) { }
- unordered_set(const unordered_set& __x) = default;
+ unordered_set(const unordered_set&) = default;
- unordered_set(const _Base& __x)
- : _Base(__x) { }
+ unordered_set(const _Base& __x)
+ : _Base(__x) { }
+
+ unordered_set(unordered_set&&) = default;
+
+ explicit
+ unordered_set(const allocator_type& __a)
+ : _Base(__a)
+ { }
+
+ unordered_set(const unordered_set& __uset,
+ const allocator_type& __a)
+ : _Base(__uset._M_base(), __a)
+ { }
- unordered_set(unordered_set&& __x) = default;
+ unordered_set(unordered_set&& __uset,
+ const allocator_type& __a)
+ : _Base(std::move(__uset._M_base()), __a)
+ { }
unordered_set(initializer_list<value_type> __l,
size_type __n = 0,
@@ -115,33 +132,41 @@ namespace __debug
unordered_set&
operator=(const unordered_set& __x)
{
- *static_cast<_Base*>(this) = __x;
+ _M_base() = __x._M_base();
this->_M_invalidate_all();
return *this;
}
unordered_set&
operator=(unordered_set&& __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_set&
operator=(initializer_list<value_type> __l)
{
- this->clear();
- this->insert(__l);
+ _M_base() = __l;
+ this->_M_invalidate_all();
return *this;
}
void
swap(unordered_set& __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);
}
@@ -485,6 +510,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;
@@ -521,12 +549,27 @@ namespace __debug
__gnu_debug::__base(__last), __n,
__hf, __eql, __a) { }
- unordered_multiset(const unordered_multiset& __x) = default;
+ unordered_multiset(const unordered_multiset&) = default;
unordered_multiset(const _Base& __x)
: _Base(__x) { }
- unordered_multiset(unordered_multiset&& __x) = default;
+ unordered_multiset(unordered_multiset&&) = default;
+
+ explicit
+ unordered_multiset(const allocator_type& __a)
+ : _Base(__a)
+ { }
+
+ unordered_multiset(const unordered_multiset& __uset,
+ const allocator_type& __a)
+ : _Base(__uset._M_base(), __a)
+ { }
+
+ unordered_multiset(unordered_multiset&& __uset,
+ const allocator_type& __a)
+ : _Base(std::move(__uset._M_base()), __a)
+ { }
unordered_multiset(initializer_list<value_type> __l,
size_type __n = 0,
@@ -540,33 +583,41 @@ namespace __debug
unordered_multiset&
operator=(const unordered_multiset& __x)
{
- *static_cast<_Base*>(this) = __x;
+ _M_base() = __x._M_base();
this->_M_invalidate_all();
return *this;
}
unordered_multiset&
operator=(unordered_multiset&& __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_multiset&
operator=(initializer_list<value_type> __l)
{
- this->clear();
- this->insert(__l);
+ _M_base() = __l;
+ this->_M_invalidate_all();
return *this;
}
void
swap(unordered_multiset& __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);
}
OpenPOWER on IntegriCloud