From 50fe0c7d61131dd693fce234573e30441eb35b38 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Mon, 3 Mar 2014 06:18:11 +0000 Subject: [PATCH] Implement LWG Paper n3887: Consistent Metafunction Aliases. This adds std::tuple_element_t<> as an alias for tuple_element<>::type. Clean up the synopsis for tuple_element in as well. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@202673 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/tuple | 9 ++++++- include/utility | 24 +++++++++---------- .../tuple.helper/tuple_element.pass.cpp | 7 ++++++ www/cxx1y_status.html | 2 +- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/include/tuple b/include/tuple index 30a958abc..3a1752ee1 100644 --- a/include/tuple +++ b/include/tuple @@ -82,13 +82,15 @@ template class tuple_size; // undefined template class tuple_size>; template class tuple_element; // undefined template class tuple_element>; +template + using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type; // C++14 // 20.4.1.5, element access: template typename tuple_element>::type& get(tuple&) noexcept; // constexpr in C++14 template - typename tuple_element>::type const& + typename const tuple_element>::type & get(const tuple&) noexcept; // constexpr in C++14 template typename tuple_element>::type&& @@ -152,6 +154,11 @@ public: typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type; }; +#if _LIBCPP_STD_VER > 11 +template +using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type; +#endif + // __tuple_leaf template ::value diff --git a/include/utility b/include/utility index 0a1a7f1d9..8a7e1dcb9 100644 --- a/include/utility +++ b/include/utility @@ -101,30 +101,30 @@ constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t(); template class tuple_size; template class tuple_element; -template struct tuple_size >; -template struct tuple_element<0, std::pair >; -template struct tuple_element<1, std::pair >; +template struct tuple_size >; +template struct tuple_element<0, pair >; +template struct tuple_element<1, pair >; template - typename tuple_element >::type& - get(std::pair&) noexcept; // constexpr in C++14 + typename tuple_element >::type& + get(pair&) noexcept; // constexpr in C++14 template - const typename const tuple_element >::type& - get(const std::pair&) noexcept; // constexpr in C++14 + const typename const tuple_element >::type& + get(const pair&) noexcept; // constexpr in C++14 template - typename tuple_element >::type&& - get(std::pair&&) noexcept; // constexpr in C++14 + typename tuple_element >::type&& + get(pair&&) noexcept; // constexpr in C++14 template - constexpr T1& get(std::pair&) noexcept; // C++14 + constexpr T1& get(pair&) noexcept; // C++14 template - constexpr T1 const& get(std::pair const &) noexcept; // C++14 + constexpr T1 const& get(pair const &) noexcept; // C++14 template - constexpr T1&& get(std::pair&&) noexcept; // C++14 + constexpr T1&& get(pair&&) noexcept; // C++14 // C++14 diff --git a/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp b/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp index 7b1ff8bb1..f3f8f2b10 100644 --- a/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp +++ b/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp @@ -28,7 +28,14 @@ void test() static_assert((std::is_same::type, const U>::value), ""); static_assert((std::is_same::type, volatile U>::value), ""); static_assert((std::is_same::type, const volatile U>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, U>::value), ""); + static_assert((std::is_same, const U>::value), ""); + static_assert((std::is_same, volatile U>::value), ""); + static_assert((std::is_same, const volatile U>::value), ""); +#endif } + int main() { test, 0, int>(); diff --git a/www/cxx1y_status.html b/www/cxx1y_status.html index c698463a8..d1632c50a 100644 --- a/www/cxx1y_status.html +++ b/www/cxx1y_status.html @@ -100,7 +100,7 @@ 3924LWGDiscouraging rand() in C++14Issaquah - 3887LWGConsistent Metafunction AliasesIssaquah + 3887LWGConsistent Metafunction AliasesIssaquahComplete