diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-01-11 15:36:52 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-01-11 15:36:52 +0000 |
commit | 2e996d929d2593e5131640e774d04fe433ba5f89 (patch) | |
tree | c2c559953a11925a7ab90ab51136fda3642adae4 | |
parent | 2b57aefea762f526405937b3c01901f8e1047edb (diff) |
Add example from C++0x [temp.deduct.type]p21, which already works
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123237 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p21.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p21.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p21.cpp new file mode 100644 index 0000000000..247b98113a --- /dev/null +++ b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p21.cpp @@ -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 |