is it possible, like this:
template< typename C,
typename R,
typename A,
typename F=R (C::*)(A) >
class MemberFuncPtr { ...
is it possible, like this:
template< typename C,
typename R,
typename A,
typename F=R (C::*)(A) >
class MemberFuncPtr { ...
Actually,it seems pretty right to me, I do not get any errors for this piece of code:
You can observe the code here.
Yes, it is perfectly valid.
Build succeeded.
Corrected Sad_man's code with some C++0x magic: http://ideone.com/rng6V (probably not gonna work for you, as not many compilers has C++0x :-|)
Works with rvalues and there is example how to achieve what you want with lambda functions.
At first you can write template wrapper:
then write you class this way:
then make
MemberFuncPtr< CWrapper <C>, R> memFuncPtr;
Using
typedef
will make your code more user-friendly. Justtypedef
pointer to function, then use it as other types.