c++ - std::is_function does not recognize template argument as function -


i passing pointer function function template:

int f(int a) { return a+1; }  template<typename f> void use(f f) {     static_assert(std::is_function<f>::value, "function required");  }  int main() {     use(&f); // plain f not work either. } 

but template argument f not recognized is_function function , static assertion fails. compiler error message says f int(*)(int) pointer function. why behave that? how can recognize function or pointer function in case?

f pointer function (regardless of whether pass f or &f). remove pointer:

std::is_function<typename std::remove_pointer<f>::type>::value 

(ironically, std::is_function<std::function<ft>> == false ;-))


Comments