diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-12-22 21:19:48 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-12-22 21:19:48 +0000 |
commit | e02e26293cf8e3bad1059b39cea75c6582896da6 (patch) | |
tree | e7e1852ce7aeaea89a2db8f5bdcbf2c2f07c41c3 /lib/AST/TemplateBase.cpp | |
parent | e6913d385e2401f4f680b7ae1ca3bf360879c786 (diff) |
Implement template argument deduction for pack expansions whose
pattern is a template argument, which involves repeatedly deducing
template arguments using the pattern of the pack expansion, then
bundling the resulting deductions into an argument pack.
We can now handle a variety of simple list-handling metaprograms using
variadic templates. See, e.g., the new "count" metaprogram.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122439 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/TemplateBase.cpp')
-rw-r--r-- | lib/AST/TemplateBase.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/AST/TemplateBase.cpp b/lib/AST/TemplateBase.cpp index bfc834f090..04e8a389cf 100644 --- a/lib/AST/TemplateBase.cpp +++ b/lib/AST/TemplateBase.cpp @@ -191,6 +191,28 @@ bool TemplateArgument::structurallyEquals(const TemplateArgument &Other) const { return false; } +TemplateArgument TemplateArgument::getPackExpansionPattern() const { + assert(isPackExpansion()); + + switch (getKind()) { + case Type: + return getAsType()->getAs<PackExpansionType>()->getPattern(); + + case Expression: + case Template: + // FIXME: Variadic templates. + llvm_unreachable("Expression and template pack expansions unsupported"); + + case Declaration: + case Integral: + case Pack: + case Null: + return TemplateArgument(); + } + + return TemplateArgument(); +} + void TemplateArgument::print(const PrintingPolicy &Policy, llvm::raw_ostream &Out) const { switch (getKind()) { |