From ef6168357a8a6594da8583197d55336224352e99 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Wed, 17 Nov 2010 19:22:43 +0000 Subject: [PATCH] LWG 1118 llvm-svn: 119541 --- libcxx/include/__tuple | 34 +++++++++++++++++ libcxx/include/tuple | 13 ------- .../tuple.helper/tuple_element.pass.cpp | 35 +++++++----------- .../tuple.helper/tuple_size.pass.cpp | 37 +++++++++---------- 4 files changed, 65 insertions(+), 54 deletions(-) diff --git a/libcxx/include/__tuple b/libcxx/include/__tuple index 9a932f4c6286..a2d4e02f3196 100644 --- a/libcxx/include/__tuple +++ b/libcxx/include/__tuple @@ -26,8 +26,42 @@ _LIBCPP_BEGIN_NAMESPACE_STD template class _LIBCPP_VISIBLE tuple_size; + +template +class _LIBCPP_VISIBLE tuple_size + : public tuple_size<_Tp> {}; + +template +class _LIBCPP_VISIBLE tuple_size + : public tuple_size<_Tp> {}; + +template +class _LIBCPP_VISIBLE tuple_size + : public tuple_size<_Tp> {}; + template class _LIBCPP_VISIBLE tuple_element; +template +class _LIBCPP_VISIBLE tuple_element<_Ip, const _Tp> +{ +public: + typedef typename add_const::type>::type type; +}; + +template +class _LIBCPP_VISIBLE tuple_element<_Ip, volatile _Tp> +{ +public: + typedef typename add_volatile::type>::type type; +}; + +template +class _LIBCPP_VISIBLE tuple_element<_Ip, const volatile _Tp> +{ +public: + typedef typename add_cv::type>::type type; +}; + template class _LIBCPP_VISIBLE tuple; template class _LIBCPP_VISIBLE pair; template struct _LIBCPP_VISIBLE array; diff --git a/libcxx/include/tuple b/libcxx/include/tuple index 2c294953f4cf..e134bdff5a60 100644 --- a/libcxx/include/tuple +++ b/libcxx/include/tuple @@ -127,12 +127,6 @@ class _LIBCPP_VISIBLE tuple_size> { }; -template -class _LIBCPP_VISIBLE tuple_size> - : public integral_constant -{ -}; - // tuple_element template @@ -142,13 +136,6 @@ public: typedef typename tuple_element<_Ip, __tuple_types<_Tp...>>::type type; }; -template -class _LIBCPP_VISIBLE tuple_element<_Ip, const tuple<_Tp...>> -{ -public: - typedef const typename tuple_element<_Ip, __tuple_types<_Tp...>>::type type; -}; - // __tuple_leaf template ::value> diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp index f85ecda30b9c..7b1ff8bb183d 100644 --- a/libcxx/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp +++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp @@ -21,27 +21,20 @@ #include #include +template +void test() +{ + static_assert((std::is_same::type, U>::value), ""); + 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), ""); +} int main() { - { - typedef std::tuple T; - static_assert((std::is_same::type, - int>::value), ""); - } - { - typedef std::tuple T; - static_assert((std::is_same::type, - char>::value), ""); - static_assert((std::is_same::type, - int>::value), ""); - } - { - typedef std::tuple T; - static_assert((std::is_same::type, - int*>::value), ""); - static_assert((std::is_same::type, - char>::value), ""); - static_assert((std::is_same::type, - int>::value), ""); - } + test, 0, int>(); + test, 0, char>(); + test, 1, int>(); + test, 0, int*>(); + test, 1, char>(); + test, 2, int>(); } diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp index feed76668af8..6db5823dab1d 100644 --- a/libcxx/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp +++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp @@ -18,26 +18,23 @@ #include #include +template +void test() +{ + static_assert((std::is_base_of, + std::tuple_size >::value), ""); + static_assert((std::is_base_of, + std::tuple_size >::value), ""); + static_assert((std::is_base_of, + std::tuple_size >::value), ""); + static_assert((std::is_base_of, + std::tuple_size >::value), ""); +} + int main() { - { - typedef std::tuple<> T; - static_assert((std::is_base_of, - std::tuple_size >::value), ""); - } - { - typedef std::tuple T; - static_assert((std::is_base_of, - std::tuple_size >::value), ""); - } - { - typedef std::tuple T; - static_assert((std::is_base_of, - std::tuple_size >::value), ""); - } - { - typedef std::tuple T; - static_assert((std::is_base_of, - std::tuple_size >::value), ""); - } + test, 0>(); + test, 1>(); + test, 2>(); + test, 3>(); }