diff mbox series

[1/3] Fix tests for std::variant to match original intention

Message ID 20190417160743.GA31346@redhat.com
State New
Headers show
Series [1/3] Fix tests for std::variant to match original intention | expand

Commit Message

Jonathan Wakely April 17, 2019, 4:07 p.m. UTC
* 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.

Tested powerpc64le-linux.
commit 855e2fb029adf77f6189f01b1a8d86dc2cca2464
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Apr 17 14:55:39 2019 +0100

    Fix tests for std::variant to match original intention
    
            * 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.

Comments

Ville Voutilainen April 17, 2019, 4:17 p.m. UTC | #1
On Wed, 17 Apr 2019 at 19:07, Jonathan Wakely <jwakely@redhat.com> wrote:
>
>         * 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.
>
> Tested powerpc64le-linux.

Looks good to me.
diff mbox series

Patch

diff --git a/libstdc++-v3/testsuite/20_util/variant/compile.cc b/libstdc++-v3/testsuite/20_util/variant/compile.cc
index 04fef0be13f..5a2d91709a0 100644
--- a/libstdc++-v3/testsuite/20_util/variant/compile.cc
+++ b/libstdc++-v3/testsuite/20_util/variant/compile.cc
@@ -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>>, "");
 }