diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-01-07 16:43:16 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-01-07 16:43:16 +0000 |
commit | 12c9c00024a01819e3a70ef6d951d32efaeb9312 (patch) | |
tree | 0c6499b83aab17269756d4e65041d29374506256 /test/CXX/expr/expr.unary/expr.sizeof/p5-0x.cpp | |
parent | 170464b7c0a2c0c86f2821f14a46f0d540cb5e94 (diff) |
Implement substitution of a function parameter pack for its set of
instantiated function parameters, enabling instantiation of arbitrary
pack expansions involving function parameter packs. At this point, we
can now correctly compile a simple, variadic print() example:
#include <iostream>
#include <string>
void print() {}
template<typename Head, typename ...Tail>
void print(const Head &head, const Tail &...tail) {
std::cout << head;
print(tail...);
}
int main() {
std::string hello = "Hello";
print(hello, ", world!", " ", 2011, '\n');
}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123000 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX/expr/expr.unary/expr.sizeof/p5-0x.cpp')
-rw-r--r-- | test/CXX/expr/expr.unary/expr.sizeof/p5-0x.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/CXX/expr/expr.unary/expr.sizeof/p5-0x.cpp b/test/CXX/expr/expr.unary/expr.sizeof/p5-0x.cpp index 6ab93db77f..3824615415 100644 --- a/test/CXX/expr/expr.unary/expr.sizeof/p5-0x.cpp +++ b/test/CXX/expr/expr.unary/expr.sizeof/p5-0x.cpp @@ -13,6 +13,18 @@ template<int ...Values> struct count_ints { int check_types[count_types<short, int, long>::value == 3? 1 : -1]; int check_ints[count_ints<1, 2, 3, 4, 5>::value == 5? 1 : -1]; +// Test instantiation involving function parameter packs. +struct any { + template<typename T> any(T); +}; + +template<typename ...Inits> +void init_me(Inits ...inits) { + any array[sizeof...(inits)] = { inits... }; +} + +template void init_me<int, float, double*>(int, float, double*); + // Test parser and semantic recovery. template<int Value> struct count_ints_2 { static const unsigned value = sizeof...(Value); // expected-error{{'Value' does not refer to the name of a parameter pack}} |