1 // { dg-do compile } 2 // { dg-options "-std=gnu++0x" } 3 4 // From N2235 5 6 // function template 1 7 template<typename T> bytesize(T 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 square(_Tp x)17 square(_Tp x) { return x; } 18 19 // Explicit specialization 20 template<> 21 constexpr unsigned long square(unsigned long x)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); 31