[libcxx] r288760 - std::get<0>([std::variant constant expression]) *is* noexcept.

Casey Carter via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 5 18:28:19 PST 2016


Author: caseycarter
Date: Mon Dec  5 20:28:19 2016
New Revision: 288760

URL: http://llvm.org/viewvc/llvm-project?rev=288760&view=rev
Log:
std::get<0>([std::variant constant expression]) *is* noexcept.

Differential review: http://reviews.llvm.org/D27436

Modified:
    libcxx/trunk/test/std/utilities/variant/variant.get/get_index.pass.cpp
    libcxx/trunk/test/std/utilities/variant/variant.get/get_type.pass.cpp

Modified: libcxx/trunk/test/std/utilities/variant/variant.get/get_index.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.get/get_index.pass.cpp?rev=288760&r1=288759&r2=288760&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/variant/variant.get/get_index.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/variant/variant.get/get_index.pass.cpp Mon Dec  5 20:28:19 2016
@@ -36,16 +36,35 @@ void test_const_lvalue_get() {
   {
     using V = std::variant<int, const long>;
     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 &);
     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>;
     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 &);
     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
 #if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
   {

Modified: libcxx/trunk/test/std/utilities/variant/variant.get/get_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.get/get_type.pass.cpp?rev=288760&r1=288759&r2=288760&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/variant/variant.get/get_type.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/variant/variant.get/get_type.pass.cpp Mon Dec  5 20:28:19 2016
@@ -30,16 +30,35 @@ void test_const_lvalue_get() {
   {
     using V = std::variant<int, const long>;
     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 &);
     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>;
     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 &);
     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
 #if !defined(TEST_VARIANT_HAS_NO_REFERENCES)
   {




More information about the cfe-commits mailing list