| 1 |
// Contributed by Dodji Seketeli <[email protected]> |
| 2 |
// Origin PR c++/37093 |
| 3 |
|
| 4 |
template <class C, void (C::*M) ()> |
| 5 |
static |
| 6 |
void foo(void *obj) |
| 7 |
{ |
| 8 |
C *p = static_cast<C*>(obj); |
| 9 |
(p->*M)(); |
| 10 |
} |
| 11 |
|
| 12 |
template <class C> |
| 13 |
static void |
| 14 |
bar(C *c, void (C::*m) ()) |
| 15 |
{ |
| 16 |
foo<C,m>((void *)c);// { dg-error "(not a valid template arg|pointer-to-member|no matching fun|could not convert|constant)" } |
| 17 |
} |
| 18 |
|
| 19 |
struct S |
| 20 |
{ |
| 21 |
void baz () {} |
| 22 |
}; |
| 23 |
|
| 24 |
int |
| 25 |
main () |
| 26 |
{ |
| 27 |
S a; |
| 28 |
bar(&a, &S::baz); |
| 29 |
} |