summaryrefslogtreecommitdiffstats
path: root/libcxx/test/utilities/tuple
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2010-11-17 19:22:43 +0000
committerHoward Hinnant <hhinnant@apple.com>2010-11-17 19:22:43 +0000
commitef6168357a8a6594da8583197d55336224352e99 (patch)
treed9a99f3fd440ca1e16a8943dc0d4707611c4f389 /libcxx/test/utilities/tuple
parent56e879d1da7be76e85b4bbbf37aaf4527ba0fb35 (diff)
downloadbcm5719-llvm-ef6168357a8a6594da8583197d55336224352e99.tar.gz
bcm5719-llvm-ef6168357a8a6594da8583197d55336224352e99.zip
LWG 1118
llvm-svn: 119541
Diffstat (limited to 'libcxx/test/utilities/tuple')
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp35
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp37
2 files changed, 31 insertions, 41 deletions
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 f85ecda30b9..7b1ff8bb183 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 <tuple>
#include <type_traits>
+template <class T, std::size_t N, class U>
+void test()
+{
+ static_assert((std::is_same<typename std::tuple_element<N, T>::type, U>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<N, const T>::type, const U>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<N, volatile T>::type, volatile U>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<N, const volatile T>::type, const volatile U>::value), "");
+}
int main()
{
- {
- typedef std::tuple<int> T;
- static_assert((std::is_same<std::tuple_element<0, T>::type,
- int>::value), "");
- }
- {
- typedef std::tuple<char, int> T;
- static_assert((std::is_same<std::tuple_element<0, T>::type,
- char>::value), "");
- static_assert((std::is_same<std::tuple_element<1, T>::type,
- int>::value), "");
- }
- {
- typedef std::tuple<int*, char, int> T;
- static_assert((std::is_same<std::tuple_element<0, T>::type,
- int*>::value), "");
- static_assert((std::is_same<std::tuple_element<1, T>::type,
- char>::value), "");
- static_assert((std::is_same<std::tuple_element<2, T>::type,
- int>::value), "");
- }
+ test<std::tuple<int>, 0, int>();
+ test<std::tuple<char, int>, 0, char>();
+ test<std::tuple<char, int>, 1, int>();
+ test<std::tuple<int*, char, int>, 0, int*>();
+ test<std::tuple<int*, char, int>, 1, char>();
+ test<std::tuple<int*, char, int>, 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 feed76668af..6db5823dab1 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 <tuple>
#include <type_traits>
+template <class T, std::size_t N>
+void test()
+{
+ static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
+ std::tuple_size<T> >::value), "");
+ static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
+ std::tuple_size<const T> >::value), "");
+ static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
+ std::tuple_size<volatile T> >::value), "");
+ static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
+ std::tuple_size<const volatile T> >::value), "");
+}
+
int main()
{
- {
- typedef std::tuple<> T;
- static_assert((std::is_base_of<std::integral_constant<std::size_t, 0>,
- std::tuple_size<T> >::value), "");
- }
- {
- typedef std::tuple<int> T;
- static_assert((std::is_base_of<std::integral_constant<std::size_t, 1>,
- std::tuple_size<T> >::value), "");
- }
- {
- typedef std::tuple<char, int> T;
- static_assert((std::is_base_of<std::integral_constant<std::size_t, 2>,
- std::tuple_size<T> >::value), "");
- }
- {
- typedef std::tuple<char, char*, int> T;
- static_assert((std::is_base_of<std::integral_constant<std::size_t, 3>,
- std::tuple_size<T> >::value), "");
- }
+ test<std::tuple<>, 0>();
+ test<std::tuple<int>, 1>();
+ test<std::tuple<char, int>, 2>();
+ test<std::tuple<char, char*, int>, 3>();
}
OpenPOWER on IntegriCloud