]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix tests for std::variant to match original intention
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 17 Apr 2019 19:27:19 +0000 (19:27 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 17 Apr 2019 19:27:19 +0000 (19:27 +0000)
* testsuite/20_util/variant/compile.cc (MoveCtorOnly): Fix type to
actually match its name.
(MoveCtorAndSwapOnly): Define new type that adds swap to MoveCtorOnly.
(test_swap()): Fix result for MoveCtorOnly and check
MoveCtorAndSwapOnly.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@270423 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/testsuite/20_util/variant/compile.cc

index 9ab8bb9154a5dc7cca236a907b75fbd8e7baaf10..8bba4b3d028e36fa03af320cfbad5d4296e17bee 100644 (file)
@@ -1,5 +1,11 @@
 2019-04-17  Jonathan Wakely  <jwakely@redhat.com>
 
+       * testsuite/20_util/variant/compile.cc (MoveCtorOnly): Fix type to
+       actually match its name.
+       (MoveCtorAndSwapOnly): Define new type that adds swap to MoveCtorOnly.
+       (test_swap()): Fix result for MoveCtorOnly and check
+       MoveCtorAndSwapOnly.
+
        * include/std/optional (optional::value_or(U&&) &&): Add missing
        constexpr specifier.
        * testsuite/20_util/optional/constexpr/observers/4.cc: Check value_or
index 04fef0be13fdbf5772474edb572c9bd1f70deb62..5a2d91709a0fbdb2c53adf772b2feb9645abea70 100644 (file)
@@ -54,12 +54,15 @@ struct DefaultNoexcept
 struct MoveCtorOnly
 {
   MoveCtorOnly() noexcept = delete;
-  MoveCtorOnly(const DefaultNoexcept&) noexcept = delete;
-  MoveCtorOnly(DefaultNoexcept&&) noexcept { }
-  MoveCtorOnly& operator=(const DefaultNoexcept&) noexcept = delete;
-  MoveCtorOnly& operator=(DefaultNoexcept&&) noexcept = delete;
+  MoveCtorOnly(const MoveCtorOnly&) noexcept = delete;
+  MoveCtorOnly(MoveCtorOnly&&) noexcept { }
+  MoveCtorOnly& operator=(const MoveCtorOnly&) noexcept = delete;
+  MoveCtorOnly& operator=(MoveCtorOnly&&) noexcept = delete;
 };
 
+struct MoveCtorAndSwapOnly : MoveCtorOnly { };
+void swap(MoveCtorAndSwapOnly&, MoveCtorAndSwapOnly&) { }
+
 struct nonliteral
 {
   nonliteral() { }
@@ -259,7 +262,8 @@ static_assert( !std::is_swappable_v<variant<D, int>> );
 void test_swap()
 {
   static_assert(is_swappable_v<variant<int, string>>, "");
-  static_assert(is_swappable_v<variant<MoveCtorOnly>>, "");
+  static_assert(!is_swappable_v<variant<MoveCtorOnly>>, "");
+  static_assert(is_swappable_v<variant<MoveCtorAndSwapOnly>>, "");
   static_assert(!is_swappable_v<variant<AllDeleted>>, "");
 }