2016-12-07 François Dumont <fdumont@gcc.gnu.org>
authorFrançois Dumont <fdumont@gcc.gnu.org>
Wed, 7 Dec 2016 21:16:24 +0000 (21:16 +0000)
committerFrançois Dumont <fdumont@gcc.gnu.org>
Wed, 7 Dec 2016 21:16:24 +0000 (21:16 +0000)
* include/bits/stl_tree.h
(_Rb_tree<>::_M_copy(_Const_Link_type, _Base_ptr)): Delete.
(_Rb_tree<>::_M_copy(const _Rb_tree&, _NodeGen&)): New.
(_Rb_tree<>::_M_copy(const _Rb_tree&)): New, use latter.
(_Rb_tree<>(const _Rb_tree&): Use latter.
(_Rb_tree<>(const _Rb_tree&, const allocator_type&)): Likewise.
(_Rb_tree<>::_M_move_data(_Rb_tree&, false_type)): Likewise.
(_Rb_tree<>::_M_move_assign(_Rb_tree&, false_type)): Likewise.
(_Rb_tree<>::operator=(const _Rb_tree&)): Likewise.

From-SVN: r243380

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_tree.h

index 3feef857c009875c0c389ae9e4e9c65390aed88d..085b95a3d0cd7ebe4ec33bcd229de50c368d7121 100644 (file)
@@ -1,5 +1,15 @@
 2016-12-07  François Dumont  <fdumont@gcc.gnu.org>
 
+       * include/bits/stl_tree.h
+       (_Rb_tree<>::_M_copy(_Const_Link_type, _Base_ptr)): Delete.
+       (_Rb_tree<>::_M_copy(const _Rb_tree&, _NodeGen&)): New.
+       (_Rb_tree<>::_M_copy(const _Rb_tree&)): New, use latter.
+       (_Rb_tree<>(const _Rb_tree&): Use latter.
+       (_Rb_tree<>(const _Rb_tree&, const allocator_type&)): Likewise.
+       (_Rb_tree<>::_M_move_data(_Rb_tree&, false_type)): Likewise.
+       (_Rb_tree<>::_M_move_assign(_Rb_tree&, false_type)): Likewise.
+       (_Rb_tree<>::operator=(const _Rb_tree&)): Likewise.
+
        * include/bits/stl_map.h (map(const map&)): Make default.
        (map(map&&)): Likewise.
        (~map()): Likewise.
index f5bb5f78946452720d9b4b69f35026052aeaaf81..86d26d5d557cfc9062c5947c1fbfbcf1fe3ca3be 100644 (file)
@@ -861,11 +861,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        _Link_type
        _M_copy(_Const_Link_type __x, _Base_ptr __p, _NodeGen&);
 
+      template<typename _NodeGen>
+       _Link_type
+       _M_copy(const _Rb_tree& __x, _NodeGen& __gen)
+       {
+         _Link_type __root = _M_copy(__x._M_begin(), _M_end(), __gen);
+         _M_leftmost() = _S_minimum(__root);
+         _M_rightmost() = _S_maximum(__root);
+         _M_impl._M_node_count = __x._M_impl._M_node_count;
+         return __root;
+       }
+
       _Link_type
-      _M_copy(_Const_Link_type __x, _Base_ptr __p)
+      _M_copy(const _Rb_tree& __x)
       {
        _Alloc_node __an(*this);
-       return _M_copy(__x, __p, __an);
+       return _M_copy(__x, __an);
       }
 
       void
@@ -903,12 +914,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       : _M_impl(__x._M_impl)
       {
        if (__x._M_root() != 0)
-         {
-           _M_root() = _M_copy(__x._M_begin(), _M_end());
-           _M_leftmost() = _S_minimum(_M_root());
-           _M_rightmost() = _S_maximum(_M_root());
-           _M_impl._M_node_count = __x._M_impl._M_node_count;
-         }
+         _M_root() = _M_copy(__x);
       }
 
 #if __cplusplus >= 201103L
@@ -920,12 +926,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       : _M_impl(__x._M_impl._M_key_compare, _Node_allocator(__a))
       {
        if (__x._M_root() != nullptr)
-         {
-           _M_root() = _M_copy(__x._M_begin(), _M_end());
-           _M_leftmost() = _S_minimum(_M_root());
-           _M_rightmost() = _S_maximum(_M_root());
-           _M_impl._M_node_count = __x._M_impl._M_node_count;
-         }
+         _M_root() = _M_copy(__x);
       }
 
       _Rb_tree(_Rb_tree&&) = default;
@@ -1595,10 +1596,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
              auto& __val = const_cast<value_type&>(__cval);
              return __an(std::move_if_noexcept(__val));
            };
-         _M_root() = _M_copy(__x._M_begin(), _M_end(), __lbd);
-         _M_leftmost() = _S_minimum(_M_root());
-         _M_rightmost() = _S_maximum(_M_root());
-         _M_impl._M_node_count = __x._M_impl._M_node_count;
+         _M_root() = _M_copy(__x, __lbd);
        }
     }
 
@@ -1636,10 +1634,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
              auto& __val = const_cast<value_type&>(__cval);
              return __roan(std::move_if_noexcept(__val));
            };
-         _M_root() = _M_copy(__x._M_begin(), _M_end(), __lbd);
-         _M_leftmost() = _S_minimum(_M_root());
-         _M_rightmost() = _S_maximum(_M_root());
-         _M_impl._M_node_count = __x._M_impl._M_node_count;
+         _M_root() = _M_copy(__x, __lbd);
          __x.clear();
        }
     }
@@ -1653,10 +1648,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
             && is_nothrow_move_assignable<_Compare>::value)
     {
       _M_impl._M_key_compare = std::move(__x._M_impl._M_key_compare);
-      constexpr bool __move_storage =
-         _Alloc_traits::_S_propagate_on_move_assign()
-         || _Alloc_traits::_S_always_equal();
-      _M_move_assign(__x, __bool_constant<__move_storage>());
+      _M_move_assign(__x, __bool_constant<_Alloc_traits::_S_nothrow_move()>());
       return *this;
     }
 
@@ -1716,12 +1708,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
          _M_impl._M_reset();
          _M_impl._M_key_compare = __x._M_impl._M_key_compare;
          if (__x._M_root() != 0)
-           {
-             _M_root() = _M_copy(__x._M_begin(), _M_end(), __roan);
-             _M_leftmost() = _S_minimum(_M_root());
-             _M_rightmost() = _S_maximum(_M_root());
-             _M_impl._M_node_count = __x._M_impl._M_node_count;
-           }
+           _M_root() = _M_copy(__x, __roan);
        }
 
       return *this;