| 1 |
// PR c++/61083 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
|
| 4 |
template<typename T> T declval(); |
| 5 |
|
| 6 |
template<typename T, typename U> |
| 7 |
struct is_same { |
| 8 |
static const bool value = false; |
| 9 |
}; |
| 10 |
|
| 11 |
template<typename T> |
| 12 |
struct is_same<T, T> { |
| 13 |
static const bool value = true; |
| 14 |
}; |
| 15 |
|
| 16 |
struct true_type {}; |
| 17 |
struct false_type {}; |
| 18 |
|
| 19 |
template <typename T> |
| 20 |
struct is_foo { |
| 21 |
private: |
| 22 |
template<typename U, U> struct helper {}; |
| 23 |
|
| 24 |
template <typename Z> static auto |
| 25 |
test(Z z) -> decltype(helper<void (Z::*)() const, &Z::foo>(), true_type()); |
| 26 |
|
| 27 |
template <typename> static auto test(...) -> false_type; |
| 28 |
|
| 29 |
public: |
| 30 |
enum { value = is_same<decltype(test<T>(declval<T>())), true_type>::value }; |
| 31 |
}; |
| 32 |
|
| 33 |
struct A { |
| 34 |
int foo(); |
| 35 |
void foo() const; |
| 36 |
}; |
| 37 |
|
| 38 |
struct A1 : public A {}; |
| 39 |
|
| 40 |
static_assert (is_foo<A>::value == 1, ""); |
| 41 |
static_assert (is_foo<A1>::value == 0, ""); |