summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-01-03 17:17:50 +0000
committerDouglas Gregor <dgregor@apple.com>2011-01-03 17:17:50 +0000
commite8e9dd624c88a05cf0dee727d5555464e6833902 (patch)
treecd6f3ab5b41b3d40f1bd3b79b6d62ca6d136328e /clang/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp
parent67cce9b13575240704f0305dcf4f9f0401f05f51 (diff)
downloadbcm5719-llvm-e8e9dd624c88a05cf0dee727d5555464e6833902.tar.gz
bcm5719-llvm-e8e9dd624c88a05cf0dee727d5555464e6833902.zip
Implement support for pack expansions whose pattern is a non-type
template argument (described by an expression, of course). For example: template<int...> struct int_tuple { }; template<int ...Values> struct square { typedef int_tuple<(Values*Values)...> type; }; It also lays the foundation for pack expansions in an initializer-list. llvm-svn: 122751
Diffstat (limited to 'clang/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp')
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/clang/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp b/clang/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp
index 6a5e989d1a1..d9a3b5c27fb 100644
--- a/clang/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp
+++ b/clang/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp
@@ -64,3 +64,52 @@ namespace Replace {
int check0[is_same<EverythingToInt<tuple<double, float>>::type,
tuple<int, int>>::value? 1 : -1];
}
+
+namespace Multiply {
+ template<int ...Values>
+ struct double_values {
+ typedef int_tuple<Values*2 ...> type;
+ };
+
+ int check0[is_same<double_values<1, 2, -3>::type,
+ int_tuple<2, 4, -6>>::value? 1 : -1];
+
+ template<int ...Values>
+ struct square {
+ typedef int_tuple<(Values*Values)...> type;
+ };
+
+ int check1[is_same<square<1, 2, -3>::type,
+ int_tuple<1, 4, 9>>::value? 1 : -1];
+
+ template<typename IntTuple> struct square_tuple;
+
+ template<int ...Values>
+ struct square_tuple<int_tuple<Values...>> {
+ typedef int_tuple<(Values*Values)...> type;
+ };
+
+ int check2[is_same<square_tuple<int_tuple<1, 2, -3>>::type,
+ int_tuple<1, 4, 9>>::value? 1 : -1];
+}
+
+namespace Indices {
+ template<unsigned I, unsigned N, typename IntTuple>
+ struct build_indices_impl;
+
+ template<unsigned I, unsigned N, int ...Indices>
+ struct build_indices_impl<I, N, int_tuple<Indices...> >
+ : build_indices_impl<I+1, N, int_tuple<Indices..., I> > {
+ };
+
+ template<unsigned N, int ...Indices>
+ struct build_indices_impl<N, N, int_tuple<Indices...> > {
+ typedef int_tuple<Indices...> type;
+ };
+
+ template<unsigned N>
+ struct build_indices : build_indices_impl<0, N, int_tuple<> > { };
+
+ int check0[is_same<build_indices<5>::type,
+ int_tuple<0, 1, 2, 3, 4>>::value? 1 : -1];
+}
OpenPOWER on IntegriCloud