[libcxx-commits] [libcxx] ef89e8c - [libc++] Fix constexpr-ness of std::tuple's constructor

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri Apr 30 12:55:12 PDT 2021


Author: Louis Dionne
Date: 2021-04-30T15:55:10-04:00
New Revision: ef89e8ca1cfe3b18861ca227ef827c7188cb6eaf

URL: https://github.com/llvm/llvm-project/commit/ef89e8ca1cfe3b18861ca227ef827c7188cb6eaf
DIFF: https://github.com/llvm/llvm-project/commit/ef89e8ca1cfe3b18861ca227ef827c7188cb6eaf.diff

LOG: [libc++] Fix constexpr-ness of std::tuple's constructor

Mentioned in https://reviews.llvm.org/D96523.

Added: 
    

Modified: 
    libcxx/include/tuple
    libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/include/tuple b/libcxx/include/tuple
index 9a58d6af7dad2..fa0b6a03cc740 100644
--- a/libcxx/include/tuple
+++ b/libcxx/include/tuple
@@ -466,7 +466,7 @@ public:
             _IsImpDefault<_Tp>... // explicit check
         >::value
     , int> = 0>
-    _LIBCPP_INLINE_VISIBILITY constexpr
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
     tuple()
         _NOEXCEPT_(_And<is_nothrow_default_constructible<_Tp>...>::value)
     { }
@@ -896,7 +896,7 @@ public:
             _EnableImplicitMoveFromPair<_Up1, _Up2, _Tp...>
         >::value
     , int> = 0>
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
     tuple(pair<_Up1, _Up2>&& __p)
         _NOEXCEPT_((_And<
             is_nothrow_constructible<_FirstType<_Tp...>, _Up1>,
@@ -911,7 +911,7 @@ public:
             _EnableExplicitMoveFromPair<_Up1, _Up2, _Tp...>
         >::value
     , int> = 0>
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
     explicit tuple(pair<_Up1, _Up2>&& __p)
         _NOEXCEPT_((_And<
             is_nothrow_constructible<_FirstType<_Tp...>, _Up1>,

diff  --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp
index b89a5d4be653e..7428d01de0438 100644
--- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp
+++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp
@@ -47,5 +47,14 @@ int main(int, char**)
         assert(std::get<1>(t1)->id_ == 3);
     }
 
+#if TEST_STD_VER > 11
+    {
+        using pair_t = std::pair<int, char>;
+        constexpr std::tuple<long, long> t(pair_t(0, 'a'));
+        static_assert(std::get<0>(t) == 0, "");
+        static_assert(std::get<1>(t) == 'a', "");
+    }
+#endif
+
   return 0;
 }


        


More information about the libcxx-commits mailing list