| 1 |
// PR c++/59204 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
|
| 4 |
template< class T > |
| 5 |
using void_t = void; |
| 6 |
|
| 7 |
template< class T, class = void > |
| 8 |
struct has_type |
| 9 |
{ constexpr static bool value = false; }; |
| 10 |
|
| 11 |
template< class T > |
| 12 |
struct has_type<T, void_t<typename T::type>> |
| 13 |
{ constexpr static bool value = true; }; |
| 14 |
|
| 15 |
struct yes { using type = int; }; |
| 16 |
struct no { }; |
| 17 |
|
| 18 |
int |
| 19 |
main( ) |
| 20 |
{ |
| 21 |
static_assert( has_type<yes>::value, "false negative!" ); |
| 22 |
static_assert( not has_type<no >::value, "false positive!" ); |
| 23 |
} |