STL supposedly does this for functors right, algorithms use identifiers of functions/lambda expressions that return a boolean and get passed two arguments.
I want to do something similar.
I could take a function identifier as argument for another function using templates like so:
Code:
template <typename T>
void call_function(T func_name) {
func_name();
std::cout << "\n\n" << typeid(T).name();
// type = bool (__cdecl*)(void)
}
void print() {
std::cout << "hey";
}
int main()
{
call_function(print);
std::cin.get();
}
But how do I do this without templates? Suppose I want to allow only void functions that take no values?
From that cout statement I got to know that T evaluated to bool (__cdecl*)(void)
But I can't use bool (__cdecl*)(void) as a type for an argument.