summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/utilities/variant/variant.variant
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-12-02 23:00:05 +0000
committerEric Fiselier <eric@efcs.ca>2016-12-02 23:00:05 +0000
commit0d3d8de014f1012dd0b2c2c077099cf6face44e5 (patch)
tree393c7c9e6470ac1076fd1d504275a9da84dda05d /libcxx/test/std/utilities/variant/variant.variant
parent1882002c91fe37fa76d7379697cee4275a5bcc3a (diff)
downloadbcm5719-llvm-0d3d8de014f1012dd0b2c2c077099cf6face44e5.tar.gz
bcm5719-llvm-0d3d8de014f1012dd0b2c2c077099cf6face44e5.zip
Implement C++17 <variant>. Patch from Michael Park!
This patch was reviewed as https://reviews.llvm.org/D23263. llvm-svn: 288547
Diffstat (limited to 'libcxx/test/std/utilities/variant/variant.variant')
-rw-r--r--libcxx/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp6
-rw-r--r--libcxx/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp46
-rw-r--r--libcxx/test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp20
-rw-r--r--libcxx/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp6
-rw-r--r--libcxx/test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp14
-rw-r--r--libcxx/test/std/utilities/variant/variant.variant/variant.ctor/default.pass.cpp2
-rw-r--r--libcxx/test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp10
-rw-r--r--libcxx/test/std/utilities/variant/variant.variant/variant.dtor/dtor.pass.cpp2
-rw-r--r--libcxx/test/std/utilities/variant/variant.variant/variant.mod/emplace_index_args.pass.cpp10
-rw-r--r--libcxx/test/std/utilities/variant/variant.variant/variant.mod/emplace_type_args.pass.cpp26
-rw-r--r--libcxx/test/std/utilities/variant/variant.variant/variant.swap/swap.pass.cpp12
-rw-r--r--libcxx/test/std/utilities/variant/variant.variant/variant_reference.fail.cpp2
12 files changed, 78 insertions, 78 deletions
diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp
index 0a1d3c9e028..10022b14aa0 100644
--- a/libcxx/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp
+++ b/libcxx/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp
@@ -116,7 +116,7 @@ void test_T_assignment_sfinae() {
static_assert(!std::is_assignable<V, int>::value, "ambiguous");
}
{
- using V = std::variant<int, int const &>;
+ using V = std::variant<int, const int &>;
static_assert(!std::is_assignable<V, int>::value, "ambiguous");
}
#endif
@@ -149,9 +149,9 @@ void test_T_assignment_basic() {
v = std::move(x);
assert(v.index() == 1);
assert(&std::get<1>(v) == &x);
- // 'long' is selected by FUN(int const&) since 'int const&' cannot bind
+ // 'long' is selected by FUN(const int &) since 'const int &' cannot bind
// to 'int&'.
- int const &cx = x;
+ const int &cx = x;
v = cx;
assert(v.index() == 2);
assert(std::get<2>(v) == 42);
diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
index 65c2052fdfe..0e1a0cd2a38 100644
--- a/libcxx/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
+++ b/libcxx/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
@@ -24,32 +24,32 @@
#include "test_macros.h"
struct NoCopy {
- NoCopy(NoCopy const &) = delete;
- NoCopy &operator=(NoCopy const &) = default;
+ NoCopy(const NoCopy &) = delete;
+ NoCopy &operator=(const NoCopy &) = default;
};
struct NothrowCopy {
- NothrowCopy(NothrowCopy const &) noexcept = default;
- NothrowCopy &operator=(NothrowCopy const &) noexcept = default;
+ NothrowCopy(const NothrowCopy &) noexcept = default;
+ NothrowCopy &operator=(const NothrowCopy &) noexcept = default;
};
struct CopyOnly {
- CopyOnly(CopyOnly const &) = default;
+ CopyOnly(const CopyOnly &) = default;
CopyOnly(CopyOnly &&) = delete;
- CopyOnly &operator=(CopyOnly const &) = default;
+ CopyOnly &operator=(const CopyOnly &) = default;
CopyOnly &operator=(CopyOnly &&) = delete;
};
struct MoveOnly {
- MoveOnly(MoveOnly const &) = delete;
+ MoveOnly(const MoveOnly &) = delete;
MoveOnly(MoveOnly &&) = default;
- MoveOnly &operator=(MoveOnly const &) = default;
+ MoveOnly &operator=(const MoveOnly &) = default;
};
struct MoveOnlyNT {
- MoveOnlyNT(MoveOnlyNT const &) = delete;
+ MoveOnlyNT(const MoveOnlyNT &) = delete;
MoveOnlyNT(MoveOnlyNT &&) {}
- MoveOnlyNT &operator=(MoveOnlyNT const &) = default;
+ MoveOnlyNT &operator=(const MoveOnlyNT &) = default;
};
struct CopyAssign {
@@ -62,7 +62,7 @@ struct CopyAssign {
copy_construct = copy_assign = move_construct = move_assign = alive = 0;
}
CopyAssign(int v) : value(v) { ++alive; }
- CopyAssign(CopyAssign const &o) : value(o.value) {
+ CopyAssign(const CopyAssign &o) : value(o.value) {
++alive;
++copy_construct;
}
@@ -71,7 +71,7 @@ struct CopyAssign {
++alive;
++move_construct;
}
- CopyAssign &operator=(CopyAssign const &o) {
+ CopyAssign &operator=(const CopyAssign &o) {
value = o.value;
++copy_assign;
return *this;
@@ -93,27 +93,27 @@ int CopyAssign::move_construct = 0;
int CopyAssign::move_assign = 0;
struct CopyMaybeThrows {
- CopyMaybeThrows(CopyMaybeThrows const &);
- CopyMaybeThrows &operator=(CopyMaybeThrows const &);
+ CopyMaybeThrows(const CopyMaybeThrows &);
+ CopyMaybeThrows &operator=(const CopyMaybeThrows &);
};
struct CopyDoesThrow {
- CopyDoesThrow(CopyDoesThrow const &) noexcept(false);
- CopyDoesThrow &operator=(CopyDoesThrow const &) noexcept(false);
+ CopyDoesThrow(const CopyDoesThrow &) noexcept(false);
+ CopyDoesThrow &operator=(const CopyDoesThrow &) noexcept(false);
};
#ifndef TEST_HAS_NO_EXCEPTIONS
struct CopyThrows {
CopyThrows() = default;
- CopyThrows(CopyThrows const &) { throw 42; }
- CopyThrows &operator=(CopyThrows const &) { throw 42; }
+ CopyThrows(const CopyThrows &) { throw 42; }
+ CopyThrows &operator=(const CopyThrows &) { throw 42; }
};
struct MoveThrows {
static int alive;
MoveThrows() { ++alive; }
- MoveThrows(MoveThrows const &) { ++alive; }
+ MoveThrows(const MoveThrows &) { ++alive; }
MoveThrows(MoveThrows &&) { throw 42; }
- MoveThrows &operator=(MoveThrows const &) { return *this; }
+ MoveThrows &operator=(const MoveThrows &) { return *this; }
MoveThrows &operator=(MoveThrows &&) { throw 42; }
~MoveThrows() { --alive; }
};
@@ -123,13 +123,13 @@ int MoveThrows::alive = 0;
struct MakeEmptyT {
static int alive;
MakeEmptyT() { ++alive; }
- MakeEmptyT(MakeEmptyT const &) {
+ MakeEmptyT(const MakeEmptyT &) {
++alive;
// Don't throw from the copy constructor since variant's assignment
// operator performs a copy before committing to the assignment.
}
MakeEmptyT(MakeEmptyT &&) { throw 42; }
- MakeEmptyT &operator=(MakeEmptyT const &) { throw 42; }
+ MakeEmptyT &operator=(const MakeEmptyT &) { throw 42; }
MakeEmptyT &operator=(MakeEmptyT &&) { throw 42; }
~MakeEmptyT() { --alive; }
};
@@ -164,7 +164,7 @@ void test_copy_assignment_sfinae() {
static_assert(std::is_copy_assignable<V>::value, "");
}
{
- // variant only provides copy assignment when beth the copy and move
+ // variant only provides copy assignment when both the copy and move
// constructors are well formed
using V = std::variant<int, CopyOnly>;
static_assert(!std::is_copy_assignable<V>::value, "");
diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp
index 0e07d13e9e9..f3dc8155b6b 100644
--- a/libcxx/test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp
+++ b/libcxx/test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp
@@ -26,36 +26,36 @@
#include "variant_test_helpers.hpp"
struct NoCopy {
- NoCopy(NoCopy const &) = delete;
- NoCopy &operator=(NoCopy const &) = default;
+ NoCopy(const NoCopy &) = delete;
+ NoCopy &operator=(const NoCopy &) = default;
};
struct CopyOnly {
- CopyOnly(CopyOnly const &) = default;
+ CopyOnly(const CopyOnly &) = default;
CopyOnly(CopyOnly &&) = delete;
- CopyOnly &operator=(CopyOnly const &) = default;
+ CopyOnly &operator=(const CopyOnly &) = default;
CopyOnly &operator=(CopyOnly &&) = delete;
};
struct MoveOnly {
- MoveOnly(MoveOnly const &) = delete;
+ MoveOnly(const MoveOnly &) = delete;
MoveOnly(MoveOnly &&) = default;
- MoveOnly &operator=(MoveOnly const &) = delete;
+ MoveOnly &operator=(const MoveOnly &) = delete;
MoveOnly &operator=(MoveOnly &&) = default;
};
struct MoveOnlyNT {
- MoveOnlyNT(MoveOnlyNT const &) = delete;
+ MoveOnlyNT(const MoveOnlyNT &) = delete;
MoveOnlyNT(MoveOnlyNT &&) {}
- MoveOnlyNT &operator=(MoveOnlyNT const &) = delete;
+ MoveOnlyNT &operator=(const MoveOnlyNT &) = delete;
MoveOnlyNT &operator=(MoveOnlyNT &&) = default;
};
struct MoveOnlyOddNothrow {
MoveOnlyOddNothrow(MoveOnlyOddNothrow &&) noexcept(false) {}
- MoveOnlyOddNothrow(MoveOnlyOddNothrow const &) = delete;
+ MoveOnlyOddNothrow(const MoveOnlyOddNothrow &) = delete;
MoveOnlyOddNothrow &operator=(MoveOnlyOddNothrow &&) noexcept = default;
- MoveOnlyOddNothrow &operator=(MoveOnlyOddNothrow const &) = delete;
+ MoveOnlyOddNothrow &operator=(const MoveOnlyOddNothrow &) = delete;
};
struct MoveAssignOnly {
diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp
index b9ea61046b4..d33ea0bd3f4 100644
--- a/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp
+++ b/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp
@@ -68,7 +68,7 @@ void test_T_ctor_sfinae() {
static_assert(!std::is_constructible<V, int>::value, "ambiguous");
}
{
- using V = std::variant<int, int const &>;
+ using V = std::variant<int, const int &>;
static_assert(!std::is_constructible<V, int>::value, "ambiguous");
}
#endif
@@ -87,7 +87,7 @@ void test_T_ctor_basic() {
}
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
{
- using V = std::variant<int const &, int &&, long>;
+ using V = std::variant<const int &, int &&, long>;
static_assert(std::is_convertible<int &, V>::value, "must be implicit");
int x = 42;
V v(x);
@@ -95,7 +95,7 @@ void test_T_ctor_basic() {
assert(&std::get<0>(v) == &x);
}
{
- using V = std::variant<int const &, int &&, long>;
+ using V = std::variant<const int &, int &&, long>;
static_assert(std::is_convertible<int, V>::value, "must be implicit");
int x = 42;
V v(std::move(x));
diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
index 78fab6258b4..18216c6da92 100644
--- a/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
+++ b/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
@@ -24,22 +24,22 @@
struct NonT {
NonT(int v) : value(v) {}
- NonT(NonT const &o) : value(o.value) {}
+ NonT(const NonT &o) : value(o.value) {}
int value;
};
static_assert(!std::is_trivially_copy_constructible<NonT>::value, "");
struct NoCopy {
- NoCopy(NoCopy const &) = delete;
+ NoCopy(const NoCopy &) = delete;
};
struct MoveOnly {
- MoveOnly(MoveOnly const &) = delete;
+ MoveOnly(const MoveOnly &) = delete;
MoveOnly(MoveOnly &&) = default;
};
struct MoveOnlyNT {
- MoveOnlyNT(MoveOnlyNT const &) = delete;
+ MoveOnlyNT(const MoveOnlyNT &) = delete;
MoveOnlyNT(MoveOnlyNT &&) {}
};
@@ -47,13 +47,13 @@ struct MoveOnlyNT {
struct MakeEmptyT {
static int alive;
MakeEmptyT() { ++alive; }
- MakeEmptyT(MakeEmptyT const &) {
+ MakeEmptyT(const MakeEmptyT &) {
++alive;
// Don't throw from the copy constructor since variant's assignment
// operator performs a copy before committing to the assignment.
}
MakeEmptyT(MakeEmptyT &&) { throw 42; }
- MakeEmptyT &operator=(MakeEmptyT const &) { throw 42; }
+ MakeEmptyT &operator=(const MakeEmptyT &) { throw 42; }
MakeEmptyT &operator=(MakeEmptyT &&) { throw 42; }
~MakeEmptyT() { --alive; }
};
@@ -124,7 +124,7 @@ void test_copy_ctor_valueless_by_exception() {
using V = std::variant<int, MakeEmptyT>;
V v1;
makeEmpty(v1);
- V const &cv1 = v1;
+ const V &cv1 = v1;
V v(cv1);
assert(v.valueless_by_exception());
#endif
diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/default.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/default.pass.cpp
index 124260bfcbf..a4a86ff6c1c 100644
--- a/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/default.pass.cpp
+++ b/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/default.pass.cpp
@@ -71,7 +71,7 @@ void test_default_ctor_throws() {
try {
V v;
assert(false);
- } catch (int const &ex) {
+ } catch (const int &ex) {
assert(ex == 42);
} catch (...) {
assert(false);
diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
index 2a87f32ef9a..66f67fe8d3f 100644
--- a/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
+++ b/libcxx/test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
@@ -28,20 +28,20 @@ struct ThrowsMove {
};
struct NoCopy {
- NoCopy(NoCopy const &) = delete;
+ NoCopy(const NoCopy &) = delete;
};
struct MoveOnly {
int value;
MoveOnly(int v) : value(v) {}
- MoveOnly(MoveOnly const &) = delete;
+ MoveOnly(const MoveOnly &) = delete;
MoveOnly(MoveOnly &&) = default;
};
struct MoveOnlyNT {
int value;
MoveOnlyNT(int v) : value(v) {}
- MoveOnlyNT(MoveOnlyNT const &) = delete;
+ MoveOnlyNT(const MoveOnlyNT &) = delete;
MoveOnlyNT(MoveOnlyNT &&other) : value(other.value) { other.value = -1; }
};
@@ -49,13 +49,13 @@ struct MoveOnlyNT {
struct MakeEmptyT {
static int alive;
MakeEmptyT() { ++alive; }
- MakeEmptyT(MakeEmptyT const &) {
+ MakeEmptyT(const MakeEmptyT &) {
++alive;
// Don't throw from the copy constructor since variant's assignment
// operator performs a copy before committing to the assignment.
}
MakeEmptyT(MakeEmptyT &&) { throw 42; }
- MakeEmptyT &operator=(MakeEmptyT const &) { throw 42; }
+ MakeEmptyT &operator=(const MakeEmptyT &) { throw 42; }
MakeEmptyT &operator=(MakeEmptyT &&) { throw 42; }
~MakeEmptyT() { --alive; }
};
diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.dtor/dtor.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.dtor/dtor.pass.cpp
index 8e36a8aa135..7299394ee7b 100644
--- a/libcxx/test/std/utilities/variant/variant.variant/variant.dtor/dtor.pass.cpp
+++ b/libcxx/test/std/utilities/variant/variant.variant/variant.dtor/dtor.pass.cpp
@@ -39,7 +39,7 @@ int NonTDtor1::count = 0;
static_assert(!std::is_trivially_destructible<NonTDtor1>::value, "");
struct TDtor {
- TDtor(TDtor const &) {} // non-trivial copy
+ TDtor(const TDtor &) {} // non-trivial copy
~TDtor() = default;
};
static_assert(!std::is_trivially_copy_constructible<TDtor>::value, "");
diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.mod/emplace_index_args.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.mod/emplace_index_args.pass.cpp
index 4dae324e665..8f694cfd5ed 100644
--- a/libcxx/test/std/utilities/variant/variant.variant/variant.mod/emplace_index_args.pass.cpp
+++ b/libcxx/test/std/utilities/variant/variant.variant/variant.mod/emplace_index_args.pass.cpp
@@ -58,14 +58,14 @@ void test_emplace_sfinae() {
}
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
{
- using V = std::variant<int, int &, int const &, int &&, TestTypes::NoCtors>;
+ using V = std::variant<int, int &, const int &, int &&, TestTypes::NoCtors>;
static_assert(emplace_exists<V, 0>(), "");
static_assert(emplace_exists<V, 0, int>(), "");
static_assert(emplace_exists<V, 0, long long>(), "");
static_assert(!emplace_exists<V, 0, int, int>(), "too many args");
static_assert(emplace_exists<V, 1, int &>(), "");
static_assert(!emplace_exists<V, 1>(), "cannot default construct ref");
- static_assert(!emplace_exists<V, 1, int const &>(), "cannot bind ref");
+ static_assert(!emplace_exists<V, 1, const int &>(), "cannot bind ref");
static_assert(!emplace_exists<V, 1, int &&>(), "cannot bind ref");
static_assert(emplace_exists<V, 2, int &>(), "");
static_assert(emplace_exists<V, 2, const int &>(), "");
@@ -74,8 +74,8 @@ void test_emplace_sfinae() {
"not constructible from void*");
static_assert(emplace_exists<V, 3, int>(), "");
static_assert(!emplace_exists<V, 3, int &>(), "cannot bind ref");
- static_assert(!emplace_exists<V, 3, int const &>(), "cannot bind ref");
- static_assert(!emplace_exists<V, 3, int const &&>(), "cannot bind ref");
+ static_assert(!emplace_exists<V, 3, const int &>(), "cannot bind ref");
+ static_assert(!emplace_exists<V, 3, const int &&>(), "cannot bind ref");
static_assert(!emplace_exists<V, 4>(), "no ctors");
}
#endif
@@ -106,7 +106,7 @@ void test_basic() {
}
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
{
- using V = std::variant<int, long, int const &, int &&, TestTypes::NoCtors,
+ using V = std::variant<int, long, const int &, int &&, TestTypes::NoCtors,
std::string>;
const int x = 100;
int y = 42;
diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.mod/emplace_type_args.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.mod/emplace_type_args.pass.cpp
index 53a030d082a..4ca2cc4803e 100644
--- a/libcxx/test/std/utilities/variant/variant.variant/variant.mod/emplace_type_args.pass.cpp
+++ b/libcxx/test/std/utilities/variant/variant.variant/variant.mod/emplace_type_args.pass.cpp
@@ -52,12 +52,12 @@ void test_emplace_sfinae() {
static_assert(!emplace_exists<V, void *, int>(), "cannot construct");
static_assert(emplace_exists<V, void *, int *>(), "");
static_assert(!emplace_exists<V, void *, const int *>(), "");
- static_assert(emplace_exists<V, void const *, const int *>(), "");
- static_assert(emplace_exists<V, void const *, int *>(), "");
+ static_assert(emplace_exists<V, const void *, const int *>(), "");
+ static_assert(emplace_exists<V, const void *, int *>(), "");
static_assert(!emplace_exists<V, TestTypes::NoCtors>(), "cannot construct");
}
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
- using V = std::variant<int, int &, int const &, int &&, long, long,
+ using V = std::variant<int, int &, const int &, int &&, long, long,
TestTypes::NoCtors>;
static_assert(emplace_exists<V, int>(), "");
static_assert(emplace_exists<V, int, int>(), "");
@@ -65,17 +65,17 @@ void test_emplace_sfinae() {
static_assert(!emplace_exists<V, int, int, int>(), "too many args");
static_assert(emplace_exists<V, int &, int &>(), "");
static_assert(!emplace_exists<V, int &>(), "cannot default construct ref");
- static_assert(!emplace_exists<V, int &, int const &>(), "cannot bind ref");
+ static_assert(!emplace_exists<V, int &, const int &>(), "cannot bind ref");
static_assert(!emplace_exists<V, int &, int &&>(), "cannot bind ref");
- static_assert(emplace_exists<V, int const &, int &>(), "");
- static_assert(emplace_exists<V, int const &, const int &>(), "");
- static_assert(emplace_exists<V, int const &, int &&>(), "");
- static_assert(!emplace_exists<V, int const &, void *>(),
+ static_assert(emplace_exists<V, const int &, int &>(), "");
+ static_assert(emplace_exists<V, const int &, const int &>(), "");
+ static_assert(emplace_exists<V, const int &, int &&>(), "");
+ static_assert(!emplace_exists<V, const int &, void *>(),
"not constructible from void*");
static_assert(emplace_exists<V, int &&, int>(), "");
static_assert(!emplace_exists<V, int &&, int &>(), "cannot bind ref");
- static_assert(!emplace_exists<V, int &&, int const &>(), "cannot bind ref");
- static_assert(!emplace_exists<V, int &&, int const &&>(), "cannot bind ref");
+ static_assert(!emplace_exists<V, int &&, const int &>(), "cannot bind ref");
+ static_assert(!emplace_exists<V, int &&, const int &&>(), "cannot bind ref");
static_assert(!emplace_exists<V, long, long>(), "ambiguous");
static_assert(!emplace_exists<V, TestTypes::NoCtors>(),
"cannot construct void");
@@ -107,7 +107,7 @@ void test_basic() {
}
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
{
- using V = std::variant<int, long, int const &, int &&, TestTypes::NoCtors,
+ using V = std::variant<int, long, const int &, int &&, TestTypes::NoCtors,
std::string>;
const int x = 100;
int y = 42;
@@ -117,8 +117,8 @@ void test_basic() {
v.emplace<long>();
assert(std::get<long>(v) == 0);
// emplace a reference
- v.emplace<int const &>(x);
- assert(&std::get<int const &>(v) == &x);
+ v.emplace<const int &>(x);
+ assert(&std::get<const int &>(v) == &x);
// emplace an rvalue reference
v.emplace<int &&>(std::move(y));
assert(&std::get<int &&>(v) == &y);
diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.swap/swap.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.swap/swap.pass.cpp
index 1fb5c72e72f..416c6b4e334 100644
--- a/libcxx/test/std/utilities/variant/variant.variant/variant.swap/swap.pass.cpp
+++ b/libcxx/test/std/utilities/variant/variant.variant/variant.swap/swap.pass.cpp
@@ -30,14 +30,14 @@ void swap(NotSwappable &, NotSwappable &) = delete;
struct NotCopyable {
NotCopyable() = default;
- NotCopyable(NotCopyable const &) = delete;
- NotCopyable &operator=(NotCopyable const &) = delete;
+ NotCopyable(const NotCopyable &) = delete;
+ NotCopyable &operator=(const NotCopyable &) = delete;
};
struct NotCopyableWithSwap {
NotCopyableWithSwap() = default;
- NotCopyableWithSwap(NotCopyableWithSwap const &) = delete;
- NotCopyableWithSwap &operator=(NotCopyableWithSwap const &) = delete;
+ NotCopyableWithSwap(const NotCopyableWithSwap &) = delete;
+ NotCopyableWithSwap &operator=(const NotCopyableWithSwap &) = delete;
};
void swap(NotCopyableWithSwap &, NotCopyableWithSwap) {}
@@ -73,7 +73,7 @@ struct NothrowTypeImp {
static void reset() { move_called = move_assign_called = swap_called = 0; }
NothrowTypeImp() = default;
explicit NothrowTypeImp(int v) : value(v) {}
- NothrowTypeImp(NothrowTypeImp const &o) noexcept(NT_Copy) : value(o.value) {
+ NothrowTypeImp(const NothrowTypeImp &o) noexcept(NT_Copy) : value(o.value) {
assert(false);
} // never called by test
NothrowTypeImp(NothrowTypeImp &&o) noexcept(NT_Move) : value(o.value) {
@@ -81,7 +81,7 @@ struct NothrowTypeImp {
do_throw<!NT_Move>();
o.value = -1;
}
- NothrowTypeImp &operator=(NothrowTypeImp const &) noexcept(NT_CopyAssign) {
+ NothrowTypeImp &operator=(const NothrowTypeImp &) noexcept(NT_CopyAssign) {
assert(false);
return *this;
} // never called by the tests
diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant_reference.fail.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant_reference.fail.cpp
index 1e5b9271280..bda27f0e5eb 100644
--- a/libcxx/test/std/utilities/variant/variant.variant/variant_reference.fail.cpp
+++ b/libcxx/test/std/utilities/variant/variant.variant/variant_reference.fail.cpp
@@ -23,6 +23,6 @@ int main()
{
// expected-error@variant:* 3 {{static_assert failed}}
std::variant<int, int&> v; // expected-note {{requested here}}
- std::variant<int, int const&> v2; // expected-note {{requested here}}
+ std::variant<int, const int &> v2; // expected-note {{requested here}}
std::variant<int, int&&> v3; // expected-note {{requested here}}
}
OpenPOWER on IntegriCloud