1 // RUN: %clang_cc1 -verify -std=c++1y %s
4 template <typename T
> constexpr T pi
= T(3.14);
5 template <typename T
> constexpr T tau
= 2 * pi
<T
>;
6 constexpr double tau_double
= tau
<double>;
7 static_assert(tau_double
== 6.28, "");
11 template<typename T
> constexpr T var
= 12345;
12 template<typename T
> constexpr T
f() { return var
<T
>; }
13 constexpr int k
= f
<int>();
14 static_assert(k
== 12345, "");
17 namespace NonDependent
{
18 template<typename T
> constexpr T a
= 0;
19 template<typename T
> constexpr T b
= a
<int>;
20 static_assert(b
<int> == 0, "");
23 namespace InstantiationDependent
{
27 template<int> constexpr int a
= 1;
28 template<typename T
> constexpr T b
= a
<sizeof(sizeof(f(T())))>; // expected-error {{invalid application of 'sizeof' to an incomplete type 'void'}}
30 static_assert(b
<int> == 1, "");
31 static_assert(b
<char> == 1, ""); // expected-note {{in instantiation of}}
33 template<typename T
> void f() {
34 int check
[a
<sizeof(sizeof(f(T())))> == 0 ? 1 : -1]; // expected-error {{array with a negative size}}
39 template<typename
> struct A
;
40 template<typename
... T
> A
<T
...> models
;
41 template<> struct B models
<>; // expected-error {{incomplete type 'struct B'}} expected-note {{forward declaration}}
44 namespace InvalidInsertPos
{
45 template<typename T
, int N
> T v
;
46 template<int N
> decltype(v
<int, N
-1>) v
<int, N
>;
47 template<> int v
<int, 0>;