summaryrefslogtreecommitdiff
path: root/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-01-11 22:21:24 +0000
committerDouglas Gregor <dgregor@apple.com>2011-01-11 22:21:24 +0000
commit77d6bb9e223496aa5288294f34e7225d1f65dddc (patch)
tree4b1a6f4ac96869c95f4040a7249de878bf56c1e1 /test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp
parentb1c65ff108de47a89585ad37874bd6cb232664cd (diff)
downloadclang-77d6bb9e223496aa5288294f34e7225d1f65dddc.tar.gz
Implement partial ordering of class template partial specializations
and function templates that contain variadic templates. This involves three small-ish changes: (1) When transforming a pack expansion, if the transformed argument still contains unexpanded parameter packs, build a pack expansion. This can happen during the substitution that occurs into class template partial specialiation template arguments during partial ordering. (2) When performing template argument deduction where the argument is a pack expansion, match against the pattern of that pack expansion. (3) When performing template argument deduction against a non-pack parameter, or a non-expansion template argument, deduction fails if the argument itself is a pack expansion (C++0x [temp.deduct.type]p22). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123279 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp')
-rw-r--r--test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp
new file mode 100644
index 0000000000..116810082d
--- /dev/null
+++ b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+// Note: Partial ordering of function templates containing template
+// parameter packs is independent of the number of deduced arguments
+// for those template parameter packs.
+template<class ...> struct Tuple { };
+template<class ... Types> int &g(Tuple<Types ...>); // #1
+template<class T1, class ... Types> float &g(Tuple<T1, Types ...>); // #2
+template<class T1, class ... Types> double &g(Tuple<T1, Types& ...>); // #3
+
+void test_g() {
+ int &ir1 = g(Tuple<>());
+ float &fr1 = g(Tuple<int, float>());
+ double &dr1 = g(Tuple<int, float&>());
+ double &dr2 = g(Tuple<int>());
+}
+
+template<class ... Types> int &h(int (*)(Types ...)); // #1
+template<class T1, class ... Types> float &h(int (*)(T1, Types ...)); // #2
+template<class T1, class ... Types> double &h(int (*)(T1, Types& ...)); // #3
+
+void test_h() {
+ int &ir1 = h((int(*)())0);
+ float &fr1 = h((int(*)(int, float))0);
+ double &dr1 = h((int(*)(int, float&))0);
+ double &dr2 = h((int(*)(int))0);
+}