summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/utilities
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2015-03-17 15:08:03 +0000
committerEric Fiselier <eric@efcs.ca>2015-03-17 15:08:03 +0000
commit57f00f2f9ce96f474beba7394be05be56fce720d (patch)
tree92b216d6aa603cdaa4f83f4f7a4e2815ddbe7807 /libcxx/test/std/utilities
parentcb84eebb527a63b2775dbf4628f0112977d8cec9 (diff)
downloadbcm5719-llvm-57f00f2f9ce96f474beba7394be05be56fce720d.tar.gz
bcm5719-llvm-57f00f2f9ce96f474beba7394be05be56fce720d.zip
[libcxx] Move tuple_size and tuple_element overloads for pair and array out of !defined(_LIBCPP_HAS_NO_VARIADICS) block.
Summary: There is no reason to guard `tuple_size`, `tuple_element` and `get<I>(...)` for pair and array inside of `<__tuple>` so that they are only available when we have variadic templates. This requires there be redundant declarations and definitions. It also makes it easy to get things wrong. For example the following code should compile (and does in c++11). ``` #define _LIBCPP_HAS_NO_VARIADICS #include <array> int main() { static_assert((std::tuple_size<std::array<int, 10> volatile>::value == 10), ""); } ``` This patch lifts the non-variadic parts of `tuple_size`, `tuple_types`, and `get<I>(...)` to the top of `<__tuple>` where they don't require variadic templates. This patch also removes `<__tuple_03>` because there is no longer a need for it. Reviewers: danalbert, K-ballo, mclow.lists Reviewed By: mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D7774 llvm-svn: 232492
Diffstat (limited to 'libcxx/test/std/utilities')
-rw-r--r--libcxx/test/std/utilities/utility/pairs/pair.astuple/tuple_element.pass.cpp39
-rw-r--r--libcxx/test/std/utilities/utility/pairs/pair.astuple/tuple_size.pass.cpp12
2 files changed, 44 insertions, 7 deletions
diff --git a/libcxx/test/std/utilities/utility/pairs/pair.astuple/tuple_element.pass.cpp b/libcxx/test/std/utilities/utility/pairs/pair.astuple/tuple_element.pass.cpp
index 9a303bae32f..5ac838b3742 100644
--- a/libcxx/test/std/utilities/utility/pairs/pair.astuple/tuple_element.pass.cpp
+++ b/libcxx/test/std/utilities/utility/pairs/pair.astuple/tuple_element.pass.cpp
@@ -15,16 +15,41 @@
#include <utility>
-int main()
+template <class T1, class T2>
+void test()
{
{
- typedef std::pair<int, short> P1;
- static_assert((std::is_same<std::tuple_element<0, P1>::type, int>::value), "");
- static_assert((std::is_same<std::tuple_element<1, P1>::type, short>::value), "");
+ typedef T1 Exp1;
+ typedef T2 Exp2;
+ typedef std::pair<T1, T2> P;
+ static_assert((std::is_same<typename std::tuple_element<0, P>::type, Exp1>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<1, P>::type, Exp2>::value), "");
+ }
+ {
+ typedef T1 const Exp1;
+ typedef T2 const Exp2;
+ typedef std::pair<T1, T2> const P;
+ static_assert((std::is_same<typename std::tuple_element<0, P>::type, Exp1>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<1, P>::type, Exp2>::value), "");
+ }
+ {
+ typedef T1 volatile Exp1;
+ typedef T2 volatile Exp2;
+ typedef std::pair<T1, T2> volatile P;
+ static_assert((std::is_same<typename std::tuple_element<0, P>::type, Exp1>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<1, P>::type, Exp2>::value), "");
}
{
- typedef std::pair<int*, char> P1;
- static_assert((std::is_same<std::tuple_element<0, P1>::type, int*>::value), "");
- static_assert((std::is_same<std::tuple_element<1, P1>::type, char>::value), "");
+ typedef T1 const volatile Exp1;
+ typedef T2 const volatile Exp2;
+ typedef std::pair<T1, T2> const volatile P;
+ static_assert((std::is_same<typename std::tuple_element<0, P>::type, Exp1>::value), "");
+ static_assert((std::is_same<typename std::tuple_element<1, P>::type, Exp2>::value), "");
}
}
+
+int main()
+{
+ test<int, short>();
+ test<int*, char>();
+}
diff --git a/libcxx/test/std/utilities/utility/pairs/pair.astuple/tuple_size.pass.cpp b/libcxx/test/std/utilities/utility/pairs/pair.astuple/tuple_size.pass.cpp
index 2be694e8a30..3756e963fa3 100644
--- a/libcxx/test/std/utilities/utility/pairs/pair.astuple/tuple_size.pass.cpp
+++ b/libcxx/test/std/utilities/utility/pairs/pair.astuple/tuple_size.pass.cpp
@@ -21,4 +21,16 @@ int main()
typedef std::pair<int, short> P1;
static_assert((std::tuple_size<P1>::value == 2), "");
}
+ {
+ typedef std::pair<int, short> const P1;
+ static_assert((std::tuple_size<P1>::value == 2), "");
+ }
+ {
+ typedef std::pair<int, short> volatile P1;
+ static_assert((std::tuple_size<P1>::value == 2), "");
+ }
+ {
+ typedef std::pair<int, short> const volatile P1;
+ static_assert((std::tuple_size<P1>::value == 2), "");
+ }
}
OpenPOWER on IntegriCloud