| 1 |
// PR c++/58954 |
| 2 |
// { dg-require-effective-target c++11 } |
| 3 |
|
| 4 |
template<class T> |
| 5 |
T&& declval(); |
| 6 |
|
| 7 |
template<class T> |
| 8 |
struct foo_argument |
| 9 |
{ |
| 10 |
template<class Ret, class C, class Arg> |
| 11 |
static Arg test(Ret (C::*)(Arg)); |
| 12 |
|
| 13 |
typedef decltype(test(&T::template foo<>)) type; |
| 14 |
}; |
| 15 |
|
| 16 |
template<class T, class> |
| 17 |
struct dependent { typedef T type; }; |
| 18 |
|
| 19 |
template<class T> |
| 20 |
struct base |
| 21 |
{ |
| 22 |
template<class Ignore = void> |
| 23 |
auto foo(int i) -> decltype(declval< |
| 24 |
typename dependent<T&, Ignore>::type |
| 25 |
>().foo_impl(i)); |
| 26 |
}; |
| 27 |
|
| 28 |
struct derived : base<derived> |
| 29 |
{ |
| 30 |
friend struct base<derived>; |
| 31 |
private: |
| 32 |
int foo_impl(int i); |
| 33 |
}; |
| 34 |
|
| 35 |
int main() |
| 36 |
{ |
| 37 |
foo_argument<derived>::type var = 0; |
| 38 |
return var; |
| 39 |
} |