Skip to content

Commit dfde6e8

Browse files
authored
[libc++][test] Remove tests that testing std::variant<T&> (#84222)
Fixes #83600
1 parent 308ed02 commit dfde6e8

File tree

15 files changed

+21
-695
lines changed

15 files changed

+21
-695
lines changed

libcxx/test/std/utilities/variant/variant.get/get_if_index.pass.cpp

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -44,30 +44,6 @@ void test_const_get_if() {
4444
static_assert(*std::get_if<1>(&v) == 42, "");
4545
static_assert(std::get_if<0>(&v) == nullptr, "");
4646
}
47-
// FIXME: Remove these once reference support is reinstated
48-
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
49-
{
50-
using V = std::variant<int &>;
51-
int x = 42;
52-
const V v(x);
53-
ASSERT_SAME_TYPE(decltype(std::get_if<0>(&v)), int *);
54-
assert(std::get_if<0>(&v) == &x);
55-
}
56-
{
57-
using V = std::variant<int &&>;
58-
int x = 42;
59-
const V v(std::move(x));
60-
ASSERT_SAME_TYPE(decltype(std::get_if<0>(&v)), int *);
61-
assert(std::get_if<0>(&v) == &x);
62-
}
63-
{
64-
using V = std::variant<const int &&>;
65-
int x = 42;
66-
const V v(std::move(x));
67-
ASSERT_SAME_TYPE(decltype(std::get_if<0>(&v)), const int *);
68-
assert(std::get_if<0>(&v) == &x);
69-
}
70-
#endif
7147
}
7248

7349
void test_get_if() {
@@ -91,37 +67,6 @@ void test_get_if() {
9167
assert(*std::get_if<1>(&v) == 42);
9268
assert(std::get_if<0>(&v) == nullptr);
9369
}
94-
// FIXME: Remove these once reference support is reinstated
95-
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
96-
{
97-
using V = std::variant<int &>;
98-
int x = 42;
99-
V v(x);
100-
ASSERT_SAME_TYPE(decltype(std::get_if<0>(&v)), int *);
101-
assert(std::get_if<0>(&v) == &x);
102-
}
103-
{
104-
using V = std::variant<const int &>;
105-
int x = 42;
106-
V v(x);
107-
ASSERT_SAME_TYPE(decltype(std::get_if<0>(&v)), const int *);
108-
assert(std::get_if<0>(&v) == &x);
109-
}
110-
{
111-
using V = std::variant<int &&>;
112-
int x = 42;
113-
V v(std::move(x));
114-
ASSERT_SAME_TYPE(decltype(std::get_if<0>(&v)), int *);
115-
assert(std::get_if<0>(&v) == &x);
116-
}
117-
{
118-
using V = std::variant<const int &&>;
119-
int x = 42;
120-
V v(std::move(x));
121-
ASSERT_SAME_TYPE(decltype(std::get_if<0>(&v)), const int *);
122-
assert(std::get_if<0>(&v) == &x);
123-
}
124-
#endif
12570
}
12671

12772
int main(int, char**) {

libcxx/test/std/utilities/variant/variant.get/get_if_type.pass.cpp

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,6 @@ void test_const_get_if() {
4242
static_assert(*std::get_if<const long>(&v) == 42, "");
4343
static_assert(std::get_if<int>(&v) == nullptr, "");
4444
}
45-
// FIXME: Remove these once reference support is reinstated
46-
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
47-
{
48-
using V = std::variant<int &>;
49-
int x = 42;
50-
const V v(x);
51-
ASSERT_SAME_TYPE(decltype(std::get_if<int &>(&v)), int *);
52-
assert(std::get_if<int &>(&v) == &x);
53-
}
54-
{
55-
using V = std::variant<int &&>;
56-
int x = 42;
57-
const V v(std::move(x));
58-
ASSERT_SAME_TYPE(decltype(std::get_if<int &&>(&v)), int *);
59-
assert(std::get_if<int &&>(&v) == &x);
60-
}
61-
{
62-
using V = std::variant<const int &&>;
63-
int x = 42;
64-
const V v(std::move(x));
65-
ASSERT_SAME_TYPE(decltype(std::get_if<const int &&>(&v)), const int *);
66-
assert(std::get_if<const int &&>(&v) == &x);
67-
}
68-
#endif
6945
}
7046

7147
void test_get_if() {
@@ -89,37 +65,6 @@ void test_get_if() {
8965
assert(*std::get_if<const long>(&v) == 42);
9066
assert(std::get_if<int>(&v) == nullptr);
9167
}
92-
// FIXME: Remove these once reference support is reinstated
93-
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
94-
{
95-
using V = std::variant<int &>;
96-
int x = 42;
97-
V v(x);
98-
ASSERT_SAME_TYPE(decltype(std::get_if<int &>(&v)), int *);
99-
assert(std::get_if<int &>(&v) == &x);
100-
}
101-
{
102-
using V = std::variant<const int &>;
103-
int x = 42;
104-
V v(x);
105-
ASSERT_SAME_TYPE(decltype(std::get_if<const int &>(&v)), const int *);
106-
assert(std::get_if<const int &>(&v) == &x);
107-
}
108-
{
109-
using V = std::variant<int &&>;
110-
int x = 42;
111-
V v(std::move(x));
112-
ASSERT_SAME_TYPE(decltype(std::get_if<int &&>(&v)), int *);
113-
assert(std::get_if<int &&>(&v) == &x);
114-
}
115-
{
116-
using V = std::variant<const int &&>;
117-
int x = 42;
118-
V v(std::move(x));
119-
ASSERT_SAME_TYPE(decltype(std::get_if<const int &&>(&v)), const int *);
120-
assert(std::get_if<const int &&>(&v) == &x);
121-
}
122-
#endif
12368
}
12469

12570
int main(int, char**) {

libcxx/test/std/utilities/variant/variant.get/get_index.pass.cpp

Lines changed: 0 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -60,30 +60,6 @@ void test_const_lvalue_get() {
6060
ASSERT_SAME_TYPE(decltype(std::get<1>(v)), const long &);
6161
assert(std::get<1>(v) == 42);
6262
}
63-
// FIXME: Remove these once reference support is reinstated
64-
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
65-
{
66-
using V = std::variant<int &>;
67-
int x = 42;
68-
const V v(x);
69-
ASSERT_SAME_TYPE(decltype(std::get<0>(v)), int &);
70-
assert(&std::get<0>(v) == &x);
71-
}
72-
{
73-
using V = std::variant<int &&>;
74-
int x = 42;
75-
const V v(std::move(x));
76-
ASSERT_SAME_TYPE(decltype(std::get<0>(v)), int &);
77-
assert(&std::get<0>(v) == &x);
78-
}
79-
{
80-
using V = std::variant<const int &&>;
81-
int x = 42;
82-
const V v(std::move(x));
83-
ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &);
84-
assert(&std::get<0>(v) == &x);
85-
}
86-
#endif
8763
}
8864

8965
void test_lvalue_get() {
@@ -100,37 +76,6 @@ void test_lvalue_get() {
10076
ASSERT_SAME_TYPE(decltype(std::get<1>(v)), const long &);
10177
assert(std::get<1>(v) == 42);
10278
}
103-
// FIXME: Remove these once reference support is reinstated
104-
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
105-
{
106-
using V = std::variant<int &>;
107-
int x = 42;
108-
V v(x);
109-
ASSERT_SAME_TYPE(decltype(std::get<0>(v)), int &);
110-
assert(&std::get<0>(v) == &x);
111-
}
112-
{
113-
using V = std::variant<const int &>;
114-
int x = 42;
115-
V v(x);
116-
ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &);
117-
assert(&std::get<0>(v) == &x);
118-
}
119-
{
120-
using V = std::variant<int &&>;
121-
int x = 42;
122-
V v(std::move(x));
123-
ASSERT_SAME_TYPE(decltype(std::get<0>(v)), int &);
124-
assert(&std::get<0>(v) == &x);
125-
}
126-
{
127-
using V = std::variant<const int &&>;
128-
int x = 42;
129-
V v(std::move(x));
130-
ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &);
131-
assert(&std::get<0>(v) == &x);
132-
}
133-
#endif
13479
}
13580

13681
void test_rvalue_get() {
@@ -147,39 +92,6 @@ void test_rvalue_get() {
14792
ASSERT_SAME_TYPE(decltype(std::get<1>(std::move(v))), const long &&);
14893
assert(std::get<1>(std::move(v)) == 42);
14994
}
150-
// FIXME: Remove these once reference support is reinstated
151-
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
152-
{
153-
using V = std::variant<int &>;
154-
int x = 42;
155-
V v(x);
156-
ASSERT_SAME_TYPE(decltype(std::get<0>(std::move(v))), int &);
157-
assert(&std::get<0>(std::move(v)) == &x);
158-
}
159-
{
160-
using V = std::variant<const int &>;
161-
int x = 42;
162-
V v(x);
163-
ASSERT_SAME_TYPE(decltype(std::get<0>(std::move(v))), const int &);
164-
assert(&std::get<0>(std::move(v)) == &x);
165-
}
166-
{
167-
using V = std::variant<int &&>;
168-
int x = 42;
169-
V v(std::move(x));
170-
ASSERT_SAME_TYPE(decltype(std::get<0>(std::move(v))), int &&);
171-
int &&xref = std::get<0>(std::move(v));
172-
assert(&xref == &x);
173-
}
174-
{
175-
using V = std::variant<const int &&>;
176-
int x = 42;
177-
V v(std::move(x));
178-
ASSERT_SAME_TYPE(decltype(std::get<0>(std::move(v))), const int &&);
179-
const int &&xref = std::get<0>(std::move(v));
180-
assert(&xref == &x);
181-
}
182-
#endif
18395
}
18496

18597
void test_const_rvalue_get() {
@@ -196,39 +108,6 @@ void test_const_rvalue_get() {
196108
ASSERT_SAME_TYPE(decltype(std::get<1>(std::move(v))), const long &&);
197109
assert(std::get<1>(std::move(v)) == 42);
198110
}
199-
// FIXME: Remove these once reference support is reinstated
200-
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
201-
{
202-
using V = std::variant<int &>;
203-
int x = 42;
204-
const V v(x);
205-
ASSERT_SAME_TYPE(decltype(std::get<0>(std::move(v))), int &);
206-
assert(&std::get<0>(std::move(v)) == &x);
207-
}
208-
{
209-
using V = std::variant<const int &>;
210-
int x = 42;
211-
const V v(x);
212-
ASSERT_SAME_TYPE(decltype(std::get<0>(std::move(v))), const int &);
213-
assert(&std::get<0>(std::move(v)) == &x);
214-
}
215-
{
216-
using V = std::variant<int &&>;
217-
int x = 42;
218-
const V v(std::move(x));
219-
ASSERT_SAME_TYPE(decltype(std::get<0>(std::move(v))), int &&);
220-
int &&xref = std::get<0>(std::move(v));
221-
assert(&xref == &x);
222-
}
223-
{
224-
using V = std::variant<const int &&>;
225-
int x = 42;
226-
const V v(std::move(x));
227-
ASSERT_SAME_TYPE(decltype(std::get<0>(std::move(v))), const int &&);
228-
const int &&xref = std::get<0>(std::move(v));
229-
assert(&xref == &x);
230-
}
231-
#endif
232111
}
233112

234113
template <std::size_t I> using Idx = std::integral_constant<std::size_t, I>;

0 commit comments

Comments
 (0)