[cfe-commits] r123237 - /cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p21.cpp

Douglas Gregor dgregor at apple.com
Tue Jan 11 07:36:52 PST 2011


Author: dgregor
Date: Tue Jan 11 09:36:52 2011
New Revision: 123237

URL: http://llvm.org/viewvc/llvm-project?rev=123237&view=rev
Log:
Add example from C++0x [temp.deduct.type]p21, which already works

Added:
    cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p21.cpp

Added: cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p21.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p21.cpp?rev=123237&view=auto
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p21.cpp (added)
+++ cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p21.cpp Tue Jan 11 09:36:52 2011
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+// Note: Template argument deduction involving parameter packs
+// (14.5.3) can deduce zero or more arguments for each parameter pack.
+
+template<class> struct X { 
+  static const unsigned value = 0;
+}; 
+
+template<class R, class ... ArgTypes> struct X<R(int, ArgTypes ...)> { 
+  static const unsigned value = 1;
+}; 
+
+template<class ... Types> struct Y { 
+  static const unsigned value = 0;
+}; 
+
+template<class T, class ... Types> struct Y<T, Types& ...> { 
+  static const unsigned value = 1;
+};
+
+template<class ... Types> int f(void (*)(Types ...)); 
+void g(int, float);
+
+int check0[X<int>::value == 0? 1 : -1]; // uses primary template
+int check1[X<int(int, float, double)>::value == 1? 1 : -1]; // uses partial specialization
+int check2[X<int(float, int)>::value == 0? 1 : -1]; // uses primary template
+int check3[Y<>::value == 0? 1 : -1]; // uses primary template
+int check4[Y<int&, float&, double&>::value == 1? 1 : -1]; // uses partial specialization
+int check5[Y<int, float, double>::value == 0? 1 : -1]; // uses primary template
+int fv = f(g); // okay





More information about the cfe-commits mailing list