OSDN Git Service

/cp
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / cpp0x / constexpr-function3.C
1 // { dg-do compile }
2 // { dg-options "-std=gnu++0x" }
3
4 // From N2235
5
6 // function template 1
7 template<typename T>
8   constexpr int bytesize(T t)
9   { return sizeof (t); }        // OK
10
11 char buf[bytesize(0)];          // OK -- not C99 VLA
12
13
14 // function template 2
15 template<typename _Tp>
16   constexpr _Tp
17   square(_Tp x) { return x; }
18
19 // Explicit specialization
20 template<>
21   constexpr unsigned long
22   square(unsigned long x) { return x * x; }
23
24 // Explicit instantiation
25 template int square(int);
26
27 class A { };
28 template A square(A);
29
30 template long square(long);