| 1 |
// { dg-do run { target c++11 } } |
| 2 |
// { dg-skip-if "requires hosted libstdc++ for cassert" { ! hostedlib } } |
| 3 |
|
| 4 |
#include <cassert> |
| 5 |
|
| 6 |
template<bool, typename _Tp = void> struct enable_if { }; |
| 7 |
template<typename _Tp> struct enable_if<true, _Tp> { typedef _Tp type; }; |
| 8 |
|
| 9 |
|
| 10 |
template <char... c> |
| 11 |
constexpr typename enable_if<sizeof...(c) == 2, int>::type operator""_t () |
| 12 |
{ |
| 13 |
return 2; |
| 14 |
} |
| 15 |
|
| 16 |
template <char... c> |
| 17 |
constexpr typename enable_if<sizeof...(c) == 1, int>::type operator""_t () |
| 18 |
{ |
| 19 |
return 1; |
| 20 |
} |
| 21 |
|
| 22 |
template <char... c> |
| 23 |
constexpr typename enable_if<sizeof...(c) >= 3, int>::type operator""_t () |
| 24 |
{ |
| 25 |
return 100; |
| 26 |
} |
| 27 |
|
| 28 |
int operator""_t (long double) |
| 29 |
{ |
| 30 |
return 200; |
| 31 |
} |
| 32 |
|
| 33 |
int main () |
| 34 |
{ |
| 35 |
assert (45_t == 2); |
| 36 |
assert (4_t == 1); |
| 37 |
assert (100000_t == 100); |
| 38 |
assert (200.0_t == 200); |
| 39 |
} |