111
|
1 // { dg-do compile { target c++11 } }
|
|
2
|
|
3 // From N2235
|
|
4
|
|
5 // function template 1
|
|
6 template<typename T>
|
|
7 constexpr int bytesize(T t)
|
|
8 { return sizeof (t); } // OK
|
|
9
|
|
10 char buf[bytesize(0)]; // OK -- not C99 VLA
|
|
11
|
|
12
|
|
13 // function template 2
|
|
14 template<typename _Tp>
|
|
15 constexpr _Tp
|
|
16 square(_Tp x) { return x; }
|
|
17
|
|
18 // Explicit specialization
|
|
19 template<>
|
|
20 constexpr unsigned long
|
|
21 square(unsigned long x) { return x * x; }
|
|
22
|
|
23 // Explicit instantiation
|
|
24 template int square(int);
|
|
25
|
|
26 class A { };
|
|
27 template A square(A);
|
|
28
|
|
29 template long square(long);
|