| 1 |
// PR c++/90711 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
|
| 4 |
namespace test { |
| 5 |
void EXISTS(int); |
| 6 |
} |
| 7 |
|
| 8 |
template<typename... ARGS> |
| 9 |
struct stub_void { |
| 10 |
typedef void type; |
| 11 |
}; |
| 12 |
template<typename... ARGS> |
| 13 |
using stub_void_t = typename stub_void<ARGS...>::type; |
| 14 |
|
| 15 |
#if !defined(SUPPRESS) |
| 16 |
template<typename O, typename = void> |
| 17 |
struct has_to_string { |
| 18 |
static constexpr bool value = false; |
| 19 |
}; |
| 20 |
|
| 21 |
template<typename O> |
| 22 |
struct has_to_string<O, stub_void_t<decltype(EXISTS(O{}))>> { |
| 23 |
static constexpr bool value = true; |
| 24 |
}; |
| 25 |
#endif |
| 26 |
|
| 27 |
template<typename O, typename = void> |
| 28 |
struct has_std_to_string { |
| 29 |
static constexpr bool value = false; |
| 30 |
}; |
| 31 |
|
| 32 |
template<typename O> |
| 33 |
struct has_std_to_string<O, stub_void_t<decltype(test::EXISTS(O{}))>> { |
| 34 |
static constexpr bool value = true; |
| 35 |
}; |
| 36 |
|
| 37 |
static_assert (has_std_to_string<int>::value, ""); |
| 38 |
|