+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&))
{ /* 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);
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)
{
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>
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));
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));
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));
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());
}
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));
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));
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));
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());
}
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());
}
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() );
}
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() );
}
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() );
}
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() );
}
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() );
}
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() );
}
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 );
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 );
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 );
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 );
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());
}
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());
}
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
{