Move from state of allocators (LWG2593)
authorFrançois Dumont <fdumont@gcc.gnu.org>
Fri, 17 May 2019 04:55:37 +0000 (04:55 +0000)
committerFrançois Dumont <fdumont@gcc.gnu.org>
Fri, 17 May 2019 04:55:37 +0000 (04:55 +0000)
2019-05-17  François Dumont  <fdumont@gcc.gnu.org>

Move from state of allocators (LWG2593)
* include/bits/stl_deque.h
(_Deque_base(_Deque_base&&, false_type)): Remove.
(_Deque_base(_Deque_base&&, true_type)): Remove.
(_Deque_base(_Deque_base&&)): Adapt.
(_Deque_base::_M_move_impl()): Remove.
* testsuite/util/testsuite_allocator.h
(propagating_allocator(propagating_allocator&&)): Preserve move from
state.
* testsuite/23_containers/deque/allocator/move_assign.cc (test02):
Adapt.
* testsuite/23_containers/forward_list/allocator/move_assign.cc (test02):
Adapt.
* testsuite/23_containers/list/allocator/move_assign.cc (test02): Adapt.
* testsuite/23_containers/map/allocator/move_assign.cc (test02): Adapt.
* testsuite/23_containers/multimap/allocator/move_assign.cc (test02):
Adapt.
* testsuite/23_containers/multiset/allocator/move_assign.cc (test02):
Adapt.
* testsuite/23_containers/set/allocator/move_assign.cc (test02): Adapt.
* testsuite/23_containers/unordered_map/allocator/move_assign.cc
(test02): Adapt.
* testsuite/23_containers/unordered_multimap/allocator/move_assign.cc
(test02): Adapt.
* testsuite/23_containers/unordered_multiset/allocator/move_assign.cc
(test02): Adapt.
* testsuite/23_containers/unordered_set/allocator/move_assign.cc
(test02): Adapt.
* testsuite/23_containers/vector/allocator/move_assign.cc (test02):
Adapt.
* testsuite/23_containers/vector/bool/allocator/move_assign.cc (test02):
Adapt.
* testsuite/21_strings/basic_string/allocator/char/move_assign.cc
(test02): Adapt.
* testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc
(test02): Adapt.

From-SVN: r271309

18 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_deque.h
libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/move_assign.cc
libstdc++-v3/testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc
libstdc++-v3/testsuite/23_containers/deque/allocator/move_assign.cc
libstdc++-v3/testsuite/23_containers/forward_list/allocator/move_assign.cc
libstdc++-v3/testsuite/23_containers/list/allocator/move_assign.cc
libstdc++-v3/testsuite/23_containers/map/allocator/move_assign.cc
libstdc++-v3/testsuite/23_containers/multimap/allocator/move_assign.cc
libstdc++-v3/testsuite/23_containers/multiset/allocator/move_assign.cc
libstdc++-v3/testsuite/23_containers/set/allocator/move_assign.cc
libstdc++-v3/testsuite/23_containers/unordered_map/allocator/move_assign.cc
libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/move_assign.cc
libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/move_assign.cc
libstdc++-v3/testsuite/23_containers/unordered_set/allocator/move_assign.cc
libstdc++-v3/testsuite/23_containers/vector/allocator/move_assign.cc
libstdc++-v3/testsuite/23_containers/vector/bool/allocator/move_assign.cc
libstdc++-v3/testsuite/util/testsuite_allocator.h

index 934d5139f7057e93f77dbc4a065a10a759d8453c..5ba8c2212e357b5940378fe96784d34692b476ed 100644 (file)
@@ -1,3 +1,42 @@
+2019-05-17  François Dumont  <fdumont@gcc.gnu.org>
+
+       Move from state of allocators (LWG2593)
+       * include/bits/stl_deque.h
+       (_Deque_base(_Deque_base&&, false_type)): Remove.
+       (_Deque_base(_Deque_base&&, true_type)): Remove.
+       (_Deque_base(_Deque_base&&)): Adapt.
+       (_Deque_base::_M_move_impl()): Remove.
+       * testsuite/util/testsuite_allocator.h
+       (propagating_allocator(propagating_allocator&&)): Preserve move from
+       state.
+       * testsuite/23_containers/deque/allocator/move_assign.cc (test02):
+       Adapt.
+       * testsuite/23_containers/forward_list/allocator/move_assign.cc (test02):
+       Adapt.
+       * testsuite/23_containers/list/allocator/move_assign.cc (test02): Adapt.
+       * testsuite/23_containers/map/allocator/move_assign.cc (test02): Adapt.
+       * testsuite/23_containers/multimap/allocator/move_assign.cc (test02):
+       Adapt.
+       * testsuite/23_containers/multiset/allocator/move_assign.cc (test02):
+       Adapt.
+       * testsuite/23_containers/set/allocator/move_assign.cc (test02): Adapt.
+       * testsuite/23_containers/unordered_map/allocator/move_assign.cc
+       (test02): Adapt.
+       * testsuite/23_containers/unordered_multimap/allocator/move_assign.cc
+       (test02): Adapt.
+       * testsuite/23_containers/unordered_multiset/allocator/move_assign.cc
+       (test02): Adapt.
+       * testsuite/23_containers/unordered_set/allocator/move_assign.cc
+       (test02): Adapt.
+       * testsuite/23_containers/vector/allocator/move_assign.cc (test02):
+       Adapt.
+       * testsuite/23_containers/vector/bool/allocator/move_assign.cc (test02):
+       Adapt.
+       * testsuite/21_strings/basic_string/allocator/char/move_assign.cc
+       (test02): Adapt.
+       * testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc
+       (test02): Adapt.
+
 2019-05-16  Jonathan Wakely  <jwakely@redhat.com>
 
        * src/c++17/fs_ops.cc (absolute(const path&, error_code&))
index 6e0f6dcd7846d6e671830a6c84f6b3095d0061d0..d0b46c671d348e01d7d17a78b962c52b95922bb0 100644 (file)
@@ -500,11 +500,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       { /* Caller must initialize map. */ }
 
 #if __cplusplus >= 201103L
-      _Deque_base(_Deque_base&& __x, false_type)
-      : _M_impl(__x._M_move_impl())
-      { }
-
-      _Deque_base(_Deque_base&& __x, true_type)
+      _Deque_base(_Deque_base&& __x)
       : _M_impl(std::move(__x._M_get_Tp_allocator()))
       {
        _M_initialize_map(0);
@@ -512,10 +508,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
          this->_M_impl._M_swap_data(__x._M_impl);
       }
 
-      _Deque_base(_Deque_base&& __x)
-      : _Deque_base(std::move(__x), typename _Alloc_traits::is_always_equal{})
-      { }
-
       _Deque_base(_Deque_base&& __x, const allocator_type& __a, size_t __n)
       : _M_impl(__a)
       {
@@ -627,29 +619,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       enum { _S_initial_map_size = 8 };
 
       _Deque_impl _M_impl;
-
-#if __cplusplus >= 201103L
-    private:
-      _Deque_impl
-      _M_move_impl()
-      {
-       if (!_M_impl._M_map)
-         return std::move(_M_impl);
-
-       // Create a copy of the current allocator.
-       _Tp_alloc_type __alloc{_M_get_Tp_allocator()};
-       // Put that copy in a moved-from state.
-       _Tp_alloc_type __sink __attribute((__unused__)) {std::move(__alloc)};
-       // Create an empty map that allocates using the moved-from allocator.
-       _Deque_base __empty{__alloc};
-       __empty._M_initialize_map(0);
-       // Now safe to modify current allocator and perform non-throwing swaps.
-       _Deque_impl __ret{std::move(_M_get_Tp_allocator())};
-       _M_impl._M_swap_data(__ret);
-       _M_impl._M_swap_data(__empty._M_impl);
-       return __ret;
-      }
-#endif
     };
 
   template<typename _Tp, typename _Alloc>
index 6ff64e67a7d3acab303bb986d2104906005b9775..d021831caeee757278dc943670d00beef9b8a236 100644 (file)
@@ -80,7 +80,7 @@ void test02()
   test_type v2(alloc_type(2));
   v2.assign(1, c);
   v2 = std::move(v1);
-  VERIFY(0 == v1.get_allocator().get_personality());
+  VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(1 == v2.get_allocator().get_personality());
 
   test_type v3(alloc_type(3));
@@ -88,7 +88,7 @@ void test02()
   test_type v4(alloc_type(4));
   v4.assign(100, c);
   v4 = std::move(v3);
-  VERIFY(0 == v3.get_allocator().get_personality());
+  VERIFY(3 == v3.get_allocator().get_personality());
   VERIFY(3 == v4.get_allocator().get_personality());
 
   test_type v5(alloc_type(5));
@@ -96,7 +96,7 @@ void test02()
   test_type v6(alloc_type(6));
   v6.assign(1, c);
   v6 = std::move(v5);
-  VERIFY(0 == v5.get_allocator().get_personality());
+  VERIFY(5 == v5.get_allocator().get_personality());
   VERIFY(5 == v6.get_allocator().get_personality());
 
   test_type v7(alloc_type(7));
@@ -104,7 +104,7 @@ void test02()
   test_type v8(alloc_type(8));
   v8.assign(100, c);
   v8 = std::move(v7);
-  VERIFY(0 == v7.get_allocator().get_personality());
+  VERIFY(7 == v7.get_allocator().get_personality());
   VERIFY(7 == v8.get_allocator().get_personality());
 }
 
index 4edf9cad06de320ef56657c6f1c14feb4b999463..66a5036c5b81703f254a0108e1a7df3a812bd98b 100644 (file)
@@ -80,7 +80,7 @@ void test02()
   test_type v2(alloc_type(2));
   v2.assign(1, c);
   v2 = std::move(v1);
-  VERIFY(0 == v1.get_allocator().get_personality());
+  VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(1 == v2.get_allocator().get_personality());
 
   test_type v3(alloc_type(3));
@@ -88,7 +88,7 @@ void test02()
   test_type v4(alloc_type(4));
   v4.assign(100, c);
   v4 = std::move(v3);
-  VERIFY(0 == v3.get_allocator().get_personality());
+  VERIFY(3 == v3.get_allocator().get_personality());
   VERIFY(3 == v4.get_allocator().get_personality());
 
   test_type v5(alloc_type(5));
@@ -96,7 +96,7 @@ void test02()
   test_type v6(alloc_type(6));
   v6.assign(1, c);
   v6 = std::move(v5);
-  VERIFY(0 == v5.get_allocator().get_personality());
+  VERIFY(5 == v5.get_allocator().get_personality());
   VERIFY(5 == v6.get_allocator().get_personality());
 
   test_type v7(alloc_type(7));
@@ -104,7 +104,7 @@ void test02()
   test_type v8(alloc_type(8));
   v8.assign(100, c);
   v8 = std::move(v7);
-  VERIFY(0 == v7.get_allocator().get_personality());
+  VERIFY(7 == v7.get_allocator().get_personality());
   VERIFY(7 == v8.get_allocator().get_personality());
 }
 
index 49d9c24ae9e5bbf9df563125034553f9e3ab46a3..2eb66af9040e85d148229cbb2bc66bbcc094240d 100644 (file)
@@ -45,7 +45,7 @@ void test02()
   test_type v2(1, alloc_type(2));
   v2 = std::move(v1);
   VERIFY( it == v2.begin() );
-  VERIFY(0 == v1.get_allocator().get_personality());
+  VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(1 == v2.get_allocator().get_personality());
 }
 
index 44592baf1a6e7ba327cd59a518cfd269d6c345a6..118ac2353916bd1b30dd8300643b2a7c5897a3fe 100644 (file)
@@ -48,7 +48,7 @@ void test02()
   test_type v2(alloc_type(2));
   v2.push_front(T());
   v2 = std::move(v1);
-  VERIFY(0 == v1.get_allocator().get_personality());
+  VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(1 == v2.get_allocator().get_personality());
   VERIFY( it == v2.begin() );
 }
index f0e9b55dc5fc34a6507fe4e245762e6a43b8e072..e739fadacef8494d2db421fb230135be2f2b1892 100644 (file)
@@ -48,7 +48,7 @@ void test02()
   test_type v2(alloc_type(2));
   v2.push_front(T());
   v2 = std::move(v1);
-  VERIFY(0 == v1.get_allocator().get_personality());
+  VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(1 == v2.get_allocator().get_personality());
   VERIFY( it == v2.begin() );
 }
index 9d94009e44c34942d75e0c0403861619fb01cf48..828e4dd7cc7388836bccf00c946a737c8750404e 100644 (file)
@@ -58,7 +58,7 @@ void test02()
   v2 = { test_type::value_type{} };
   v2 = std::move(v1);
 
-  VERIFY( 0 == v1.get_allocator().get_personality() );
+  VERIFY( 1 == v1.get_allocator().get_personality() );
   VERIFY( 1 == v2.get_allocator().get_personality() );
   VERIFY( it == v2.begin() );
 }
index f2df25c7a45b8995dfb14c458054b1093a13785f..a4cbe85158ac7febdf8811db353663f6963d8fa0 100644 (file)
@@ -54,7 +54,7 @@ void test02()
   test_type v2(alloc_type(2));
   v2 = { test_type::value_type{} };
   v2 = std::move(v1);
-  VERIFY(0 == v1.get_allocator().get_personality());
+  VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(1 == v2.get_allocator().get_personality());
   VERIFY( it == v2.begin()  );
 }
index 58d17e4b3bf488f712907a59a9e32f33b1c737c6..0ba27c95aacc3c3ff611192dd8122da934ff8e73 100644 (file)
@@ -52,7 +52,7 @@ void test02()
   test_type v2(alloc_type(2));
   v2 = { test_type::value_type{} };
   v2 = std::move(v1);
-  VERIFY(0 == v1.get_allocator().get_personality());
+  VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(1 == v2.get_allocator().get_personality());
   VERIFY( it == v2.begin() );
 }
index a1e5ea59fe115e0fd6bb2c9ce6ed6474733dad52..17b15611283830b5f17d133fbcc9de2d5f7b0df9 100644 (file)
@@ -55,7 +55,7 @@ void test02()
   test_type v2(alloc_type(2));
   v2 = { test_type::value_type{} };
   v2 = std::move(v1);
-  VERIFY(0 == v1.get_allocator().get_personality());
+  VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(1 == v2.get_allocator().get_personality());
   VERIFY( it == v2.begin() );
 }
index d377916a8da181ef35b02da23d9d81ef11e4fa08..577a2adb2de45471de02244abb6d7eb74ba5ee78 100644 (file)
@@ -76,7 +76,7 @@ void test02()
 
   v2 = std::move(v1);
 
-  VERIFY(0 == v1.get_allocator().get_personality());
+  VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(1 == v2.get_allocator().get_personality());
 
   VERIFY( counter_type::move_assign_count == 0 );
index 34cdedc929c3f584a8f087b5aa070c351a1979d7..e58199673d33c13d303175c11d8e9118208d4046 100644 (file)
@@ -76,7 +76,7 @@ void test02()
 
   v2 = std::move(v1);
 
-  VERIFY(0 == v1.get_allocator().get_personality());
+  VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(1 == v2.get_allocator().get_personality());
 
   VERIFY( counter_type::move_assign_count == 0 );
index 9abc5f5296a67a324990ee4fbf717df2f0df5b76..92354241093f48f11c107e1ff32ffab3223d2b7d 100644 (file)
@@ -70,7 +70,7 @@ void test02()
 
   v2 = std::move(v1);
 
-  VERIFY(0 == v1.get_allocator().get_personality());
+  VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(1 == v2.get_allocator().get_personality());
 
   VERIFY( counter_type::move_count == 0 );
index 8f2578710026ace633e5de8f5aa7e28b405bd598..7243663ca5185a2b60d9a4c52c98ad49f572d37b 100644 (file)
@@ -86,7 +86,7 @@ void test02()
 
     v2 = std::move(v1);
 
-    VERIFY(0 == v1.get_allocator().get_personality());
+    VERIFY(1 == v1.get_allocator().get_personality());
     VERIFY(1 == v2.get_allocator().get_personality());
 
     VERIFY( counter_type::move_count == 0 );
index 5bca700f77d18840ed4359d861eb8d8a7d77f394..2a2e33994256c2f7f0ebcc629badb3e2ada32e37 100644 (file)
@@ -49,7 +49,7 @@ void test02()
   v2.push_back(T());
   v2 = std::move(v1);
   VERIFY( it == v2.begin() );
-  VERIFY(0 == v1.get_allocator().get_personality());
+  VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(1 == v2.get_allocator().get_personality());
 }
 
index 903b1f9d6a21ce6585e176193a1306307f0e26df..b14ecb7d6e4158f3d226124d80ef1198335fc173 100644 (file)
@@ -49,7 +49,7 @@ void test02()
   v2.push_back(T());
   v2 = std::move(v1);
   VERIFY( it == v2.begin() );
-  VERIFY(0 == v1.get_allocator().get_personality());
+  VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(1 == v2.get_allocator().get_personality());
 }
 
index d817ac4e838fd67a70b7e7713b80a9fce80a5cd2..34dba16669fef84ae8bc4c989a75e2f199625029 100644 (file)
@@ -465,12 +465,12 @@ namespace __gnu_test
          return *this;
        }
 
-      // postcondition: a.get_personality() == 0
+      // postcondition: LWG2593 a.get_personality() un-changed.
       propagating_allocator(propagating_allocator&& a) noexcept
-      : base_alloc()
-      { swap_base(a); }
+      : base_alloc(std::move(a.base()))
+      { }
 
-      // postcondition: a.get_personality() == 0
+      // postcondition: LWG2593 a.get_personality() un-changed
       propagating_allocator&
       operator=(propagating_allocator&& a) noexcept
       {