1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
3 // If a template-parameter of a class template or alias template has a default
4 // template-argument, each subsequent template-parameter shall either have a
5 // default template-argument supplied or be a template parameter pack.
6 template<typename
> struct vector
;
8 template<typename T
= int, typename
> struct X3t
; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}}
9 template<typename T
= int, typename
> using A3t
= int; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}}
10 template<int V
= 0, int> struct X3nt
; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}}
11 template<int V
= 0, int> using A3nt
= int; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}}
12 template<template<class> class M
= vector
, template<class> class> struct X3tt
; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}}
13 template<template<class> class M
= vector
, template<class> class> using A3tt
= int; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}}
15 template<typename T
= int, typename
...Types
> struct X2t
;
16 template<typename T
= int, typename
...Types
> using A2t
= X2t
<T
, Types
...>;
17 template<int V
= 0, int ...Values
> struct X2nt
;
18 template<int V
= 0, int ...Values
> using A2nt
= X2nt
<V
, Values
...>;
19 template<template<class> class M
= vector
, template<class> class... Metas
>
21 template<template<class> class M
= vector
, template<class> class... Metas
>
22 using A2tt
= X2tt
<M
, Metas
...>;
24 // If a template-parameter of a primary class template or alias template is a
25 // template parameter pack, it shall be the last template-parameter.
26 template<typename
...Types
, // expected-error{{template parameter pack must be the last template parameter}}
27 int After
, int After2
>
30 template<typename
...Types
, // expected-error{{template parameter pack must be the last template parameter}}
34 template<int ...Values
, // expected-error{{template parameter pack must be the last template parameter}}
37 template<int ...Values
, // expected-error{{template parameter pack must be the last template parameter}}
41 template<template<typename
> class ...Templates
, // expected-error{{template parameter pack must be the last template parameter}}
44 template<template<typename
> class ...Templates
, // expected-error{{template parameter pack must be the last template parameter}}
48 // [ Note: These are not requirements for function templates or class
49 // template partial specializations because template arguments can be
50 // deduced (14.8.2). -- end note]
51 template<typename
... Types
> struct X1t
;
52 template<typename
...Types
, typename T
> struct X1t
<T
, Types
...> { };
54 template<int... Values
> struct X1nt
;
55 template<int ...Values
, int V
> struct X1nt
<V
, Values
...> { };
57 template<template<int> class... Meta
> struct X1tt
;
58 template<template<int> class... Meta
, template<int> class M
>
59 struct X1tt
<M
, Meta
...> { };
61 template<typename
...Types
, typename T
>
62 void f1t(X1t
<T
, Types
...>);
64 template<int ...Values
, int V
>
65 void f1nt(X1nt
<V
, Values
...>);
67 template<template<int> class... Meta
, template<int> class M
>
68 void f1tt(X1tt
<M
, Meta
...>);
70 namespace DefaultTemplateArgsInFunction
{
71 template<typename T
= int, typename U
> T
&f0(U
) { T
*x
= 0; return *x
; }
74 int &ir0
= f0(3.14159);
75 int &ir1
= f0
<int>(3.14159);
76 float &fr0
= f0
<float>(3.14159);
79 template<> int &f0(int*);
80 template int &f0(double&);