Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc++][test] remove tests that testing std::variant<T&> #84222

Merged
merged 3 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,6 @@ void test_const_get_if() {
static_assert(*std::get_if<1>(&v) == 42, "");
static_assert(std::get_if<0>(&v) == nullptr, "");
}
// FIXME: Remove these once reference support is reinstated
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
{
using V = std::variant<int &>;
int x = 42;
const V v(x);
ASSERT_SAME_TYPE(decltype(std::get_if<0>(&v)), int *);
assert(std::get_if<0>(&v) == &x);
}
{
using V = std::variant<int &&>;
int x = 42;
const V v(std::move(x));
ASSERT_SAME_TYPE(decltype(std::get_if<0>(&v)), int *);
assert(std::get_if<0>(&v) == &x);
}
{
using V = std::variant<const int &&>;
int x = 42;
const V v(std::move(x));
ASSERT_SAME_TYPE(decltype(std::get_if<0>(&v)), const int *);
assert(std::get_if<0>(&v) == &x);
}
#endif
}

void test_get_if() {
Expand All @@ -91,37 +67,6 @@ void test_get_if() {
assert(*std::get_if<1>(&v) == 42);
assert(std::get_if<0>(&v) == nullptr);
}
// FIXME: Remove these once reference support is reinstated
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
{
using V = std::variant<int &>;
int x = 42;
V v(x);
ASSERT_SAME_TYPE(decltype(std::get_if<0>(&v)), int *);
assert(std::get_if<0>(&v) == &x);
}
{
using V = std::variant<const int &>;
int x = 42;
V v(x);
ASSERT_SAME_TYPE(decltype(std::get_if<0>(&v)), const int *);
assert(std::get_if<0>(&v) == &x);
}
{
using V = std::variant<int &&>;
int x = 42;
V v(std::move(x));
ASSERT_SAME_TYPE(decltype(std::get_if<0>(&v)), int *);
assert(std::get_if<0>(&v) == &x);
}
{
using V = std::variant<const int &&>;
int x = 42;
V v(std::move(x));
ASSERT_SAME_TYPE(decltype(std::get_if<0>(&v)), const int *);
assert(std::get_if<0>(&v) == &x);
}
#endif
}

int main(int, char**) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,6 @@ void test_const_get_if() {
static_assert(*std::get_if<const long>(&v) == 42, "");
static_assert(std::get_if<int>(&v) == nullptr, "");
}
// FIXME: Remove these once reference support is reinstated
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
{
using V = std::variant<int &>;
int x = 42;
const V v(x);
ASSERT_SAME_TYPE(decltype(std::get_if<int &>(&v)), int *);
assert(std::get_if<int &>(&v) == &x);
}
{
using V = std::variant<int &&>;
int x = 42;
const V v(std::move(x));
ASSERT_SAME_TYPE(decltype(std::get_if<int &&>(&v)), int *);
assert(std::get_if<int &&>(&v) == &x);
}
{
using V = std::variant<const int &&>;
int x = 42;
const V v(std::move(x));
ASSERT_SAME_TYPE(decltype(std::get_if<const int &&>(&v)), const int *);
assert(std::get_if<const int &&>(&v) == &x);
}
#endif
}

void test_get_if() {
Expand All @@ -89,37 +65,6 @@ void test_get_if() {
assert(*std::get_if<const long>(&v) == 42);
assert(std::get_if<int>(&v) == nullptr);
}
// FIXME: Remove these once reference support is reinstated
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
{
using V = std::variant<int &>;
int x = 42;
V v(x);
ASSERT_SAME_TYPE(decltype(std::get_if<int &>(&v)), int *);
assert(std::get_if<int &>(&v) == &x);
}
{
using V = std::variant<const int &>;
int x = 42;
V v(x);
ASSERT_SAME_TYPE(decltype(std::get_if<const int &>(&v)), const int *);
assert(std::get_if<const int &>(&v) == &x);
}
{
using V = std::variant<int &&>;
int x = 42;
V v(std::move(x));
ASSERT_SAME_TYPE(decltype(std::get_if<int &&>(&v)), int *);
assert(std::get_if<int &&>(&v) == &x);
}
{
using V = std::variant<const int &&>;
int x = 42;
V v(std::move(x));
ASSERT_SAME_TYPE(decltype(std::get_if<const int &&>(&v)), const int *);
assert(std::get_if<const int &&>(&v) == &x);
}
#endif
}

int main(int, char**) {
Expand Down
121 changes: 0 additions & 121 deletions libcxx/test/std/utilities/variant/variant.get/get_index.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,6 @@ void test_const_lvalue_get() {
ASSERT_SAME_TYPE(decltype(std::get<1>(v)), const long &);
assert(std::get<1>(v) == 42);
}
// FIXME: Remove these once reference support is reinstated
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
{
using V = std::variant<int &>;
int x = 42;
const V v(x);
ASSERT_SAME_TYPE(decltype(std::get<0>(v)), int &);
assert(&std::get<0>(v) == &x);
}
{
using V = std::variant<int &&>;
int x = 42;
const V v(std::move(x));
ASSERT_SAME_TYPE(decltype(std::get<0>(v)), int &);
assert(&std::get<0>(v) == &x);
}
{
using V = std::variant<const int &&>;
int x = 42;
const V v(std::move(x));
ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &);
assert(&std::get<0>(v) == &x);
}
#endif
}

void test_lvalue_get() {
Expand All @@ -100,37 +76,6 @@ void test_lvalue_get() {
ASSERT_SAME_TYPE(decltype(std::get<1>(v)), const long &);
assert(std::get<1>(v) == 42);
}
// FIXME: Remove these once reference support is reinstated
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
{
using V = std::variant<int &>;
int x = 42;
V v(x);
ASSERT_SAME_TYPE(decltype(std::get<0>(v)), int &);
assert(&std::get<0>(v) == &x);
}
{
using V = std::variant<const int &>;
int x = 42;
V v(x);
ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &);
assert(&std::get<0>(v) == &x);
}
{
using V = std::variant<int &&>;
int x = 42;
V v(std::move(x));
ASSERT_SAME_TYPE(decltype(std::get<0>(v)), int &);
assert(&std::get<0>(v) == &x);
}
{
using V = std::variant<const int &&>;
int x = 42;
V v(std::move(x));
ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &);
assert(&std::get<0>(v) == &x);
}
#endif
}

void test_rvalue_get() {
Expand All @@ -147,39 +92,6 @@ void test_rvalue_get() {
ASSERT_SAME_TYPE(decltype(std::get<1>(std::move(v))), const long &&);
assert(std::get<1>(std::move(v)) == 42);
}
// FIXME: Remove these once reference support is reinstated
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
{
using V = std::variant<int &>;
int x = 42;
V v(x);
ASSERT_SAME_TYPE(decltype(std::get<0>(std::move(v))), int &);
assert(&std::get<0>(std::move(v)) == &x);
}
{
using V = std::variant<const int &>;
int x = 42;
V v(x);
ASSERT_SAME_TYPE(decltype(std::get<0>(std::move(v))), const int &);
assert(&std::get<0>(std::move(v)) == &x);
}
{
using V = std::variant<int &&>;
int x = 42;
V v(std::move(x));
ASSERT_SAME_TYPE(decltype(std::get<0>(std::move(v))), int &&);
int &&xref = std::get<0>(std::move(v));
assert(&xref == &x);
}
{
using V = std::variant<const int &&>;
int x = 42;
V v(std::move(x));
ASSERT_SAME_TYPE(decltype(std::get<0>(std::move(v))), const int &&);
const int &&xref = std::get<0>(std::move(v));
assert(&xref == &x);
}
#endif
}

void test_const_rvalue_get() {
Expand All @@ -196,39 +108,6 @@ void test_const_rvalue_get() {
ASSERT_SAME_TYPE(decltype(std::get<1>(std::move(v))), const long &&);
assert(std::get<1>(std::move(v)) == 42);
}
// FIXME: Remove these once reference support is reinstated
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
{
using V = std::variant<int &>;
int x = 42;
const V v(x);
ASSERT_SAME_TYPE(decltype(std::get<0>(std::move(v))), int &);
assert(&std::get<0>(std::move(v)) == &x);
}
{
using V = std::variant<const int &>;
int x = 42;
const V v(x);
ASSERT_SAME_TYPE(decltype(std::get<0>(std::move(v))), const int &);
assert(&std::get<0>(std::move(v)) == &x);
}
{
using V = std::variant<int &&>;
int x = 42;
const V v(std::move(x));
ASSERT_SAME_TYPE(decltype(std::get<0>(std::move(v))), int &&);
int &&xref = std::get<0>(std::move(v));
assert(&xref == &x);
}
{
using V = std::variant<const int &&>;
int x = 42;
const V v(std::move(x));
ASSERT_SAME_TYPE(decltype(std::get<0>(std::move(v))), const int &&);
const int &&xref = std::get<0>(std::move(v));
assert(&xref == &x);
}
#endif
}

template <std::size_t I> using Idx = std::integral_constant<std::size_t, I>;
Expand Down
Loading
Loading