I want to get the type of a function and create std::vector . For example, I have
int foo(int a[], int n) { return 1; } int bar(int a[], int n) { return 2; }
and such a vector of such functions will be:
std::vector< std::function<int(int[],int)> > v;
And generally, a decltype() would be better, for example:
std::vector< decltype(foo) > v;
however, this will result in a compilation error.
I think the reason is that decltype() cannot distinguish
int (*func)(int[], int) std::function<int(int[], int)>
Is there any way to fix this?
source share