]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
set.h (set): Implement C++11 allocator-aware container requirements.
authorFrançois Dumont <fdumont@gcc.gnu.org>
Mon, 13 Jan 2014 20:07:22 +0000 (20:07 +0000)
committerFrançois Dumont <fdumont@gcc.gnu.org>
Mon, 13 Jan 2014 20:07:22 +0000 (20:07 +0000)
2014-01-13  François Dumont  <fdumont@gcc.gnu.org>

* include/debug/set.h (set): Implement C++11 allocator-aware
container requirements.
* include/debug/map.h (map): Likewise.
* include/debug/multiset.h (multiset): Likewise.
* include/debug/multimap.h (multimap): Likewise.
* include/debug/set.h (set::operator=(set&&)): Add noexcept and
fix implementation regarding management of safe iterators.
* include/debug/map.h (map::operator=(map&&)): Likewise.
* include/debug/multiset.h (multiset::operator=(multiset&&)): Likewise.
* include/debug/multimap.h (multimap::operator=(multimap&&)):
Likewise.
* include/debug/set.h (set::operator=(std::initializer_list<>)):
Rely on the same operator from normal mode.
* include/debug/map.h (map::operator=(std::initializer_list<>)):
Likewise.
* include/debug/multiset.h
(multiset::operator=(std::initializer_list<>)): Likewise.
* include/debug/multimap.h
(multimap::operator=(std::initializer_list<>)): Likewise.
* include/debug/set.h (set::swap(set&)): Add noexcept
specification, add allocator equality check.
* include/debug/map.h (map::swap(map&)): Likewise.
* include/debug/multiset.h (multiset::swap(multiset&)): Likewise.
* include/debug/multimap.h (multimap::swap(multimap&)): Likewise.

From-SVN: r206588

libstdc++-v3/ChangeLog
libstdc++-v3/include/debug/map.h
libstdc++-v3/include/debug/multimap.h
libstdc++-v3/include/debug/multiset.h
libstdc++-v3/include/debug/set.h

index 78d99829759c7efc9c006944e7251be85c468981..43c2900d0d733c43a66dd3f4df09391c7edbe3de 100644 (file)
@@ -1,3 +1,30 @@
+2014-01-13  François Dumont  <fdumont@gcc.gnu.org>
+
+       * include/debug/set.h (set): Implement C++11 allocator-aware
+       container requirements.
+       * include/debug/map.h (map): Likewise.
+       * include/debug/multiset.h (multiset): Likewise.
+       * include/debug/multimap.h (multimap): Likewise.
+       * include/debug/set.h (set::operator=(set&&)): Add noexcept and
+       fix implementation regarding management of safe iterators.
+       * include/debug/map.h (map::operator=(map&&)): Likewise.
+       * include/debug/multiset.h (multiset::operator=(multiset&&)): Likewise.
+       * include/debug/multimap.h (multimap::operator=(multimap&&)):
+       Likewise.
+       * include/debug/set.h (set::operator=(std::initializer_list<>)):
+       Rely on the same operator from normal mode.
+       * include/debug/map.h (map::operator=(std::initializer_list<>)):
+       Likewise.
+       * include/debug/multiset.h
+       (multiset::operator=(std::initializer_list<>)): Likewise.
+       * include/debug/multimap.h
+       (multimap::operator=(std::initializer_list<>)): Likewise.
+       * include/debug/set.h (set::swap(set&)): Add noexcept
+       specification, add allocator equality check.
+       * include/debug/map.h (map::swap(map&)): Likewise.
+       * include/debug/multiset.h (multiset::swap(multiset&)): Likewise.
+       * include/debug/multimap.h (multimap::swap(multimap&)): Likewise.
+
 2014-01-10  Jonathan Wakely  <jwakely@redhat.com>
 
        PR libstdc++/59698
index e9bf7c60dd5c91eb703e54e9f6aa0767760629a6..2367d57452c7403450d2a9c3624d129322ed02ae 100644 (file)
@@ -49,6 +49,11 @@ namespace __debug
       typedef typename _Base::const_iterator _Base_const_iterator;
       typedef typename _Base::iterator _Base_iterator;
       typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal;
+
+#if __cplusplus >= 201103L
+      typedef __gnu_cxx::__alloc_traits<typename
+                                       _Base::allocator_type> _Alloc_traits;
+#endif
     public:
       // types:
       typedef _Key                                  key_type;
@@ -101,6 +106,27 @@ namespace __debug
          const _Compare& __c = _Compare(),
          const allocator_type& __a = allocator_type())
       : _Base(__l, __c, __a) { }
+
+      explicit
+      map(const allocator_type& __a)
+      : _Base(__a) { }
+
+      map(const map& __m, const allocator_type& __a)
+      : _Base(__m, __a) { }
+
+      map(map&& __m, const allocator_type& __a)
+      : _Base(std::move(__m._M_base()), __a) { }
+
+      map(initializer_list<value_type> __l, const allocator_type& __a)
+      : _Base(__l, __a) { }
+
+      template<typename _InputIterator>
+        map(_InputIterator __first, _InputIterator __last,
+           const allocator_type& __a)
+         : _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
+                                                                      __last)),
+                 __gnu_debug::__base(__last), __a)
+       { }
 #endif
 
       ~map() _GLIBCXX_NOEXCEPT { }
@@ -108,7 +134,7 @@ namespace __debug
       map&
       operator=(const map& __x)
       {
-       *static_cast<_Base*>(this) = __x;
+       _M_base() = __x;
        this->_M_invalidate_all();
        return *this;
       }
@@ -116,20 +142,25 @@ namespace __debug
 #if __cplusplus >= 201103L
       map&
       operator=(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;
       }
 
       map&
       operator=(initializer_list<value_type> __l)
       {
-       this->clear();
-       this->insert(__l);
+       _M_base() = __l;
+       this->_M_invalidate_all();
        return *this;
       }
 #endif
@@ -360,7 +391,14 @@ namespace __debug
 
       void
       swap(map& __x)
+#if __cplusplus >= 201103L
+      noexcept(_Alloc_traits::_S_nothrow_swap())
+#endif
       {
+#if __cplusplus >= 201103L
+       if (!_Alloc_traits::_S_propagate_on_swap())
+         __glibcxx_check_equal_allocs(__x);
+#endif
        _Base::swap(__x);
        this->_M_swap(__x);
       }
index 35c827bb94946af5f37c0e26f87a505cfe62cfa9..0976573b7e1fdf4a407c1df1d62f7212f40f9a12 100644 (file)
@@ -50,6 +50,11 @@ namespace __debug
       typedef typename _Base::const_iterator _Base_const_iterator;
       typedef typename _Base::iterator _Base_iterator;
       typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal;
+
+#if __cplusplus >= 201103L
+      typedef __gnu_cxx::__alloc_traits<typename
+                                       _Base::allocator_type> _Alloc_traits;
+#endif
     public:
       // types:
       typedef _Key                                  key_type;
@@ -102,6 +107,28 @@ namespace __debug
               const _Compare& __c = _Compare(),
               const allocator_type& __a = allocator_type())
       : _Base(__l, __c, __a) { }
+
+      explicit
+      multimap(const allocator_type& __a)
+      : _Base(__a) { }
+
+      multimap(const multimap& __m, const allocator_type& __a)
+      : _Base(__m, __a) { }
+
+      multimap(multimap&& __m, const allocator_type& __a)
+      : _Base(std::move(__m._M_base()), __a) { }
+
+      multimap(initializer_list<value_type> __l, const allocator_type& __a)
+      : _Base(__l, __a)
+      { }
+
+      template<typename _InputIterator>
+        multimap(_InputIterator __first, _InputIterator __last,
+                const allocator_type& __a)
+       : _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
+                                                                    __last)),
+               __gnu_debug::__base(__last), __a)
+      { }
 #endif
 
       ~multimap() _GLIBCXX_NOEXCEPT { }
@@ -109,7 +136,7 @@ namespace __debug
       multimap&
       operator=(const multimap& __x)
       {
-       *static_cast<_Base*>(this) = __x;
+       _M_base() = __x;
        this->_M_invalidate_all();
        return *this;
       }
@@ -117,20 +144,25 @@ namespace __debug
 #if __cplusplus >= 201103L
       multimap&
       operator=(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;
       }
 
       multimap&
       operator=(initializer_list<value_type> __l)
       {
-       this->clear();
-       this->insert(__l);
+       _M_base() = __l;
+       this->_M_invalidate_all();
        return *this;
       }
 #endif
@@ -343,7 +375,14 @@ namespace __debug
 
       void
       swap(multimap& __x)
+#if __cplusplus >= 201103L
+      noexcept(_Alloc_traits::_S_nothrow_swap())
+#endif
       {
+#if __cplusplus >= 201103L
+       if (!_Alloc_traits::_S_propagate_on_swap())
+         __glibcxx_check_equal_allocs(__x);
+#endif
        _Base::swap(__x);
        this->_M_swap(__x);
       }
index 7aff7caad6f513cd1485b8d1e00a586b7921cba2..5a39ef8887f2d427a6705c82b16bf799310a23b8 100644 (file)
@@ -49,6 +49,11 @@ namespace __debug
       typedef typename _Base::const_iterator _Base_const_iterator;
       typedef typename _Base::iterator _Base_iterator;
       typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal;
+
+#if __cplusplus >= 201103L
+      typedef __gnu_cxx::__alloc_traits<typename
+                                       _Base::allocator_type> _Alloc_traits;
+#endif
     public:
       // types:
       typedef _Key                                  key_type;
@@ -101,6 +106,28 @@ namespace __debug
               const _Compare& __comp = _Compare(),
               const allocator_type& __a = allocator_type())
       : _Base(__l, __comp, __a) { }
+
+      explicit
+      multiset(const allocator_type& __a)
+      : _Base(__a) { }
+
+      multiset(const multiset& __m, const allocator_type& __a)
+      : _Base(__m, __a) { }
+
+      multiset(multiset&& __m, const allocator_type& __a)
+      : _Base(std::move(__m._M_base()), __a) { }
+
+      multiset(initializer_list<value_type> __l, const allocator_type& __a)
+       : _Base(__l, __a)
+      { }
+
+      template<typename _InputIterator>
+        multiset(_InputIterator __first, _InputIterator __last,
+                const allocator_type& __a)
+         : _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
+                                                                      __last)),
+                 __gnu_debug::__base(__last), __a)
+        { }
 #endif
 
       ~multiset() _GLIBCXX_NOEXCEPT { }
@@ -108,7 +135,7 @@ namespace __debug
       multiset&
       operator=(const multiset& __x)
       {
-       *static_cast<_Base*>(this) = __x;
+       _M_base() = __x;
        this->_M_invalidate_all();
        return *this;
       }
@@ -116,20 +143,25 @@ namespace __debug
 #if __cplusplus >= 201103L
       multiset&
       operator=(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;
       }
 
       multiset&
       operator=(initializer_list<value_type> __l)
       {
-       this->clear();
-       this->insert(__l);
+       _M_base() = __l;
+       this->_M_invalidate_all();
        return *this;
       }
 #endif
@@ -328,7 +360,14 @@ namespace __debug
 
       void
       swap(multiset& __x)
+#if __cplusplus >= 201103L
+      noexcept(_Alloc_traits::_S_nothrow_swap())
+#endif
       {
+#if __cplusplus >= 201103L
+       if (!_Alloc_traits::_S_propagate_on_swap())
+         __glibcxx_check_equal_allocs(__x);
+#endif
        _Base::swap(__x);
        this->_M_swap(__x);
       }
index 5da8821930ca25522b8918b7be1df837655e74ed..8c84f25298a9f3cee7f692d90c5e6cb1ac34a251 100644 (file)
@@ -49,6 +49,10 @@ namespace __debug
       typedef typename _Base::const_iterator _Base_const_iterator;
       typedef typename _Base::iterator _Base_iterator;
       typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal;
+#if __cplusplus >= 201103L
+      typedef __gnu_cxx::__alloc_traits<typename
+                                       _Base::allocator_type> _Alloc_traits;
+#endif
     public:
       // types:
       typedef _Key                                 key_type;
@@ -101,6 +105,28 @@ namespace __debug
          const _Compare& __comp = _Compare(),
          const allocator_type& __a = allocator_type())
       : _Base(__l, __comp, __a) { }
+
+      explicit
+      set(const allocator_type& __a)
+      : _Base(__a) { }
+
+      set(const set& __x, const allocator_type& __a)
+      : _Base(__x, __a) { }
+
+      set(set&& __x, const allocator_type& __a)
+      : _Base(std::move(__x._M_base()), __a) { }
+
+      set(initializer_list<value_type> __l, const allocator_type& __a)
+       : _Base(__l, __a)
+      { }
+
+      template<typename _InputIterator>
+        set(_InputIterator __first, _InputIterator __last,
+           const allocator_type& __a)
+       : _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
+                                                                    __last)),
+               __gnu_debug::__base(__last), __a)
+        { }
 #endif
 
       ~set() _GLIBCXX_NOEXCEPT { }
@@ -108,7 +134,7 @@ namespace __debug
       set&
       operator=(const set& __x)
       {
-       *static_cast<_Base*>(this) = __x;
+       _M_base() = __x;
        this->_M_invalidate_all();
        return *this;
       }
@@ -116,20 +142,25 @@ namespace __debug
 #if __cplusplus >= 201103L
       set&
       operator=(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;
       }
 
       set&
       operator=(initializer_list<value_type> __l)
       {
-       this->clear();
-       this->insert(__l);
+       _M_base() = __l;
+       this->_M_invalidate_all();
        return *this;
       }
 #endif
@@ -337,7 +368,14 @@ namespace __debug
 
       void
       swap(set& __x)
+#if __cplusplus >= 201103L
+      noexcept(_Alloc_traits::_S_nothrow_swap())
+#endif
       {
+#if __cplusplus >= 201103L
+       if (!_Alloc_traits::_S_propagate_on_swap())
+         __glibcxx_check_equal_allocs(__x);
+#endif
        _Base::swap(__x);
        this->_M_swap(__x);
       }