From 9425300b415916c5474204fa1157c94612d9f8ac Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 26 Apr 2017 20:25:30 +0100 Subject: [PATCH] Improve tests for vector and deque move-assignment * testsuite/23_containers/deque/allocator/move_assign-2.cc: Improve comment. Ensure first test works because allocator type propagates and not because is_always_equal is true. * testsuite/23_containers/vector/52591.cc: Likewise. Restore original testcase that instantiates the move-assignment operator. From-SVN: r247284 --- libstdc++-v3/ChangeLog | 8 ++++++++ .../deque/allocator/move_assign-2.cc | 7 ++++--- .../testsuite/23_containers/vector/52591.cc | 17 ++++++++++++----- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index f2b533b4ae9..b7d1727d5ca 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2017-04-26 Jonathan Wakely + + * testsuite/23_containers/deque/allocator/move_assign-2.cc: Improve + comment. Ensure first test works because allocator type propagates and + not because is_always_equal is true. + * testsuite/23_containers/vector/52591.cc: Likewise. Restore original + testcase that instantiates the move-assignment operator. + 2017-04-24 Jonathan Wakely PR libstdc++/80506 diff --git a/libstdc++-v3/testsuite/23_containers/deque/allocator/move_assign-2.cc b/libstdc++-v3/testsuite/23_containers/deque/allocator/move_assign-2.cc index c86c2c9975a..65c98f00028 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/allocator/move_assign-2.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/allocator/move_assign-2.cc @@ -25,9 +25,9 @@ #include -// As an extension we allow move-assignment of std::deque when the element -// type is not MoveAssignable, as long as the allocator type propagates or -// is known to always compare equal. +// Move-assignment of std::deque is allowed for non-MoveAssignable T when +// the allocator type propagates. As an extension we also allow it if the +// allocator type is known to always compare equal. struct C { @@ -43,6 +43,7 @@ struct A1 : std::allocator template A1(const A1&) { } using propagate_on_container_move_assignment = std::true_type; + using is_always_equal = std::false_type; }; void test01() diff --git a/libstdc++-v3/testsuite/23_containers/vector/52591.cc b/libstdc++-v3/testsuite/23_containers/vector/52591.cc index 3c0d39ea351..20938fac529 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/52591.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/52591.cc @@ -23,15 +23,21 @@ #include #include -// As an extension we allow move-assignment of std::vector when the element -// type is not MoveAssignable, as long as the allocator type propagates or -// is known to always compare equal. +// Move-assignment of std::vector is allowed for non-MoveAssignable T when +// the allocator type propagates. As an extension we also allow it if the +// allocator type is known to always compare equal. struct C { C& operator=(C&&) = delete; }; +void test01() +{ + std::vector a; + a = std::vector(); +} + template struct A1 : std::allocator { @@ -41,9 +47,10 @@ struct A1 : std::allocator template A1(const A1&) { } using propagate_on_container_move_assignment = std::true_type; + using is_always_equal = std::false_type; }; -void test01() +void test02() { using test_type = std::vector>; static_assert(std::is_nothrow_move_assignable::value, @@ -62,7 +69,7 @@ struct A2 : std::allocator using is_always_equal = std::true_type; }; -void test02() +void test03() { using test_type = std::vector>; static_assert(std::is_nothrow_move_assignable::value, -- 2.30.2