I am trying to use std::is_function
to determine if a variable is a function pointer.
When running the following code
#include <iostream> #include <typeinfo> using namespace std; int main() { typedef int(*functionpointer)(); functionpointer pmain = main; cout << typeid(functionpointer).name() << " "<< is_function<functionpointer>::value << endl; cout << typeid(decltype(pmain)).name() << " " << is_function<decltype(pmain)>::value << endl; cout << typeid(decltype(main)).name() << " " << is_function<decltype(main)>::value << endl; cout << typeid(decltype(*pmain)).name() << " " << is_function<decltype(*pmain)>::value << endl; return 0; }
output
PFivE 0 PFivE 0 FivE 1 FivE 0
Can someone explain with understanding why the last std::is_function
evaluates to false?
(Code checked under g ++ 4.7, g ++ 4.8 and clang ++ 3.2)
source share