I have some class C
and want to pass address of its instance and method to some functor in a test function Test_C_Foo1()
. Functor is a template class
It's good. It's legal and localized.
IMHO, if the typedef
is just to avoid typing or to make the pointer-to-member-function less cumbersome, as your example shows, thenit is fine.
But if the typedef
reveals some particular concept, then it should be visible outside of the function.
A quick test to check it is the name of the typedef
:
typedef int(C::*MEMFN1)(const std::string&); //OK: as local typedef, just an abbreviation
typedef int(C::*ACTION)(const std::string&); //Not so OK: Action is a new concept