std::get<0>([std::variant constant expression]) *is* noexcept.
Differential review: http://reviews.llvm.org/D27436 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@288760 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -36,16 +36,35 @@ void test_const_lvalue_get() {
|
|||||||
{
|
{
|
||||||
using V = std::variant<int, const long>;
|
using V = std::variant<int, const long>;
|
||||||
constexpr V v(42);
|
constexpr V v(42);
|
||||||
ASSERT_NOT_NOEXCEPT(std::get<0>(v));
|
#ifndef __clang__ // Avoid https://llvm.org/bugs/show_bug.cgi?id=15481
|
||||||
|
ASSERT_NOEXCEPT(std::get<0>(v));
|
||||||
|
#endif
|
||||||
ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &);
|
ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &);
|
||||||
static_assert(std::get<0>(v) == 42, "");
|
static_assert(std::get<0>(v) == 42, "");
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
using V = std::variant<int, const long>;
|
||||||
|
const V v(42);
|
||||||
|
ASSERT_NOT_NOEXCEPT(std::get<0>(v));
|
||||||
|
ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &);
|
||||||
|
assert(std::get<0>(v) == 42);
|
||||||
|
}
|
||||||
{
|
{
|
||||||
using V = std::variant<int, const long>;
|
using V = std::variant<int, const long>;
|
||||||
constexpr V v(42l);
|
constexpr V v(42l);
|
||||||
|
#ifndef __clang__ // Avoid https://llvm.org/bugs/show_bug.cgi?id=15481
|
||||||
|
ASSERT_NOEXCEPT(std::get<1>(v));
|
||||||
|
#endif
|
||||||
ASSERT_SAME_TYPE(decltype(std::get<1>(v)), const long &);
|
ASSERT_SAME_TYPE(decltype(std::get<1>(v)), const long &);
|
||||||
static_assert(std::get<1>(v) == 42, "");
|
static_assert(std::get<1>(v) == 42, "");
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
using V = std::variant<int, const long>;
|
||||||
|
const V v(42l);
|
||||||
|
ASSERT_NOT_NOEXCEPT(std::get<1>(v));
|
||||||
|
ASSERT_SAME_TYPE(decltype(std::get<1>(v)), const long &);
|
||||||
|
assert(std::get<1>(v) == 42);
|
||||||
|
}
|
||||||
// FIXME: Remove these once reference support is reinstated
|
// FIXME: Remove these once reference support is reinstated
|
||||||
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
|
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,16 +30,35 @@ void test_const_lvalue_get() {
|
|||||||
{
|
{
|
||||||
using V = std::variant<int, const long>;
|
using V = std::variant<int, const long>;
|
||||||
constexpr V v(42);
|
constexpr V v(42);
|
||||||
ASSERT_NOT_NOEXCEPT(std::get<int>(v));
|
#ifndef __clang__ // Avoid https://llvm.org/bugs/show_bug.cgi?id=15481
|
||||||
|
ASSERT_NOEXCEPT(std::get<int>(v));
|
||||||
|
#endif
|
||||||
ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &);
|
ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &);
|
||||||
static_assert(std::get<int>(v) == 42, "");
|
static_assert(std::get<int>(v) == 42, "");
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
using V = std::variant<int, const long>;
|
||||||
|
const V v(42);
|
||||||
|
ASSERT_NOT_NOEXCEPT(std::get<int>(v));
|
||||||
|
ASSERT_SAME_TYPE(decltype(std::get<0>(v)), const int &);
|
||||||
|
assert(std::get<int>(v) == 42);
|
||||||
|
}
|
||||||
{
|
{
|
||||||
using V = std::variant<int, const long>;
|
using V = std::variant<int, const long>;
|
||||||
constexpr V v(42l);
|
constexpr V v(42l);
|
||||||
|
#ifndef __clang__ // Avoid https://llvm.org/bugs/show_bug.cgi?id=15481
|
||||||
|
ASSERT_NOEXCEPT(std::get<const long>(v));
|
||||||
|
#endif
|
||||||
ASSERT_SAME_TYPE(decltype(std::get<const long>(v)), const long &);
|
ASSERT_SAME_TYPE(decltype(std::get<const long>(v)), const long &);
|
||||||
static_assert(std::get<const long>(v) == 42, "");
|
static_assert(std::get<const long>(v) == 42, "");
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
using V = std::variant<int, const long>;
|
||||||
|
const V v(42l);
|
||||||
|
ASSERT_NOT_NOEXCEPT(std::get<const long>(v));
|
||||||
|
ASSERT_SAME_TYPE(decltype(std::get<const long>(v)), const long &);
|
||||||
|
assert(std::get<const long>(v) == 42);
|
||||||
|
}
|
||||||
// FIXME: Remove these once reference support is reinstated
|
// FIXME: Remove these once reference support is reinstated
|
||||||
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
|
#if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user