Consider what a template is: it is a compile-time template (in the generic English sense) for generating code. A template type-alias is a template for generating type-aliases:
template <typename T>
using func = void (*) (T);
func
is not a type or even a type-alias; but func<SomeClass>
and func<SomeOtherClass>
are. Specifically, func<SomeClass>
is an alias for void (*) SomeClass
.
Now, consider what a std::map
is: it maps keys of a particular type to values of a particular type. The type of all values must be the same, so class-templates must be fully specified so that they are real types and no longer merely templates for generating types.
So, no, if you want to invoke function (or member function) pointers with different arguments, you cannot store them all in the same std::map
as values, unless you circumvent the type system, e.g. by using some kind of tagged union
of function-pointer types as your value-type for your map
.
(As a side note: it looks like you may be trying to implement something like Qt's named-signals-and-slots framework. Have you considered simply using Qt?)