1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
3 // Test parsing + semantic analysis
4 template<typename
...Types
> struct count_types
{
5 static const unsigned value
= sizeof...(Types
);
8 template<int ...Values
> struct count_ints
{
9 static const unsigned value
= sizeof...(Values
);
13 int check_types
[count_types
<short, int, long>::value
== 3? 1 : -1];
14 int check_ints
[count_ints
<1, 2, 3, 4, 5>::value
== 5? 1 : -1];
16 // Test instantiation involving function parameter packs.
18 template<typename T
> any(T
);
21 template<typename
...Inits
>
22 void init_me(Inits
...inits
) {
23 any array
[sizeof...(inits
)] = { inits
... };
26 template void init_me
<int, float, double*>(int, float, double*);
28 // Test parser and semantic recovery.
29 template<int Value
> struct count_ints_2
{
30 static const unsigned value
= sizeof...(Value
); // expected-error{{'Value' does not refer to the name of a parameter pack}}
33 template<typename
...Types
> // expected-note{{parameter pack 'Types' declared here}}
34 struct count_types_2
{
35 static const unsigned value
= sizeof... Type
; // expected-error{{missing parentheses around the size of parameter pack 'Type'}} \
36 // expected-error{{Type' does not refer to the name of a parameter pack; did you mean 'Types'?}}