What I\'d like to do is something like this:
template
DataType myFunc(DataType in)
{
...
}
typedef myFunc myFunc_i;
myFunc
Try this:
typedef int (*myFunc_i_type)(int);
myFunc_i_type const myFunc_i = &myFunc;
This will trigger a compiler error if the signature of myFunc
ever changes. Making it const
also prohibits reassigning. Function pointers are also callable like any normal function: myFunc_i(5)
.
If you don't want a compiler error but rather have it update itself, use auto
(again with const
):
auto const myFunc_i = &myFunc;