From ef89e8ca1cfe3b18861ca227ef827c7188cb6eaf Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Fri, 30 Apr 2021 15:52:26 -0400 Subject: [PATCH] [libc++] Fix constexpr-ness of std::tuple's constructor Mentioned in https://reviews.llvm.org/D96523. --- libcxx/include/tuple | 6 +++--- .../utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/libcxx/include/tuple b/libcxx/include/tuple index 9a58d6a..fa0b6a0 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...>::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 b89a5d4..7428d01 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; + constexpr std::tuple t(pair_t(0, 'a')); + static_assert(std::get<0>(t) == 0, ""); + static_assert(std::get<1>(t) == 'a', ""); + } +#endif + return 0; } -- 2.7.4