| View previous topic :: View next topic |
| Author |
Message |
peter.keane@citigroup.com Guest
|
Posted: Sun Feb 12, 2006 6:06 pm Post subject: Taking Address of Member Function Template |
|
|
Hi
Does anyone know if this is possible ?
class MyClass
{
public:
template<typename T> void memberFunction(T a);
};
// pointer to member function
void (MyClass::*ptrFun)(int);
ptrFun = MyClass::memberFunction;
ptrFun = &MyClass::memberFunction<int>;
Neither of above 2 methods will compile
Thanks and Regards
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
Valentin Samko Guest
|
Posted: Mon Feb 13, 2006 12:06 am Post subject: Re: Taking Address of Member Function Template |
|
|
peter.keane (AT) citigroup (DOT) com wrote:
| Quote: | class MyClass
{
public:
template<typename T> void memberFunction(T a);
};
void (MyClass::*ptrFun)(int);
ptrFun = MyClass::memberFunction;
this is ill formed
ptrFun = &MyClass::memberFunction<int>;
This is fine and it compiles fine, but fails to link as you did not define memberFunction. |
--
Valentin Samko - http://www.valentinsamko.com
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
Thomas Maeder Guest
|
Posted: Mon Feb 13, 2006 12:06 am Post subject: Re: Taking Address of Member Function Template |
|
|
"peter.keane (AT) citigroup (DOT) com" <keanep (AT) netvigator (DOT) com> writes:
| Quote: | class MyClass
{
public:
template<typename T> void memberFunction(T a);
};
// pointer to member function
void (MyClass::*ptrFun)(int);
ptrFun = MyClass::memberFunction;
ptrFun = &MyClass::memberFunction<int>;
Neither of above 2 methods will compile
|
The second one should.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
|