From 9d3e662d294a2861a1c8fb9825edd11013d621c1 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 17 Apr 2019 20:27:19 +0100 Subject: [PATCH] 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. From-SVN: r270423 --- libstdc++-v3/ChangeLog | 6 ++++++ libstdc++-v3/testsuite/20_util/variant/compile.cc | 14 +++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 9ab8bb9154a..8bba4b3d028 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,11 @@ 2019-04-17 Jonathan Wakely + * 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 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> ); void test_swap() { static_assert(is_swappable_v>, ""); - static_assert(is_swappable_v>, ""); + static_assert(!is_swappable_v>, ""); + static_assert(is_swappable_v>, ""); static_assert(!is_swappable_v>, ""); } -- 2.30.2