[cfe-commits] r122752 - /cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp

Douglas Gregor dgregor at apple.com
Mon Jan 3 09:25:02 PST 2011


Author: dgregor
Date: Mon Jan  3 11:25:02 2011
New Revision: 122752

URL: http://llvm.org/viewvc/llvm-project?rev=122752&view=rev
Log:
Another variadic template metafunction test case: summing values.

Modified:
    cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp

Modified: cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp?rev=122752&r1=122751&r2=122752&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp Mon Jan  3 11:25:02 2011
@@ -65,7 +65,7 @@
              tuple<int, int>>::value? 1 : -1];
 }
 
-namespace Multiply {
+namespace Math {
   template<int ...Values>
   struct double_values {
     typedef int_tuple<Values*2 ...> type;
@@ -89,8 +89,22 @@
     typedef int_tuple<(Values*Values)...> type;
   };
 
-  int check2[is_same<square_tuple<int_tuple<1, 2, -3>>::type, 
+  int check2[is_same<square_tuple<int_tuple<1, 2, -3> >::type, 
                      int_tuple<1, 4, 9>>::value? 1 : -1];
+
+  template<int ...Values> struct sum;
+
+  template<int First, int ...Rest> 
+  struct sum<First, Rest...> {
+    static const int value = First + sum<Rest...>::value;
+  };
+
+  template<>
+  struct sum<> {
+    static const int value = 0;
+  };
+
+  int check3[sum<1, 2, 3, 4, 5>::value == 15? 1 : -1];
 }
 
 namespace Indices {





More information about the cfe-commits mailing list