| 1 |
// { dg-do compile } |
| 2 |
|
| 3 |
// Copyright (C) 2001 Free Software Foundation, Inc. |
| 4 |
// Contributed by Nathan Sidwell 31 Dec 2001 <[email protected]> |
| 5 |
|
| 6 |
// PR 3716 tsubsting a pointer to member function did not create a |
| 7 |
// pointer to member function. |
| 8 |
|
| 9 |
template <class C, class T, T C::*M> |
| 10 |
struct Closure |
| 11 |
{ |
| 12 |
T operator() (C & c) const { return (c.*M); } |
| 13 |
}; |
| 14 |
|
| 15 |
template <class C, class T, T (C::* M)()> |
| 16 |
struct Closure<C, T (), M> |
| 17 |
{ |
| 18 |
T operator()(C & c) const { return (c.*M)(); } |
| 19 |
}; |
| 20 |
|
| 21 |
struct A |
| 22 |
{ |
| 23 |
int get(); |
| 24 |
}; |
| 25 |
|
| 26 |
static Closure<A, int (), & A::get> get_closure; |
| 27 |
|
| 28 |
|
| 29 |
void Foo () |
| 30 |
{ |
| 31 |
A a; |
| 32 |
get_closure (a); |
| 33 |
} |