c++ - is_function_pointer<> for <type_traits> -


there these in <type_traits>:

is_pointer<> is_function<> is_member_function_pointer<> 

but not this:

is_function_pointer<> 

why so?

the traits in [meta.unary.cat] intended classify each type single category. void, integral, pointer, etc. @ level, pointer-to-function no different pointer-to-int. , note pointer member not pointer. merely english homonym.

it intended every type return true 1 trait in [meta.unary.cat]. , in categorization, both function pointer , scalar pointer both return true under is_pointer.

i note did not achieve our objective. nullptr_t escapes our goal. got close. here graphical representation of current type_traits classification.

update:

this correctly working program correct output:

#include <iostream> #include <type_traits>  typedef void (*fptr)(); typedef int* intptr;  int main() {     std::cout << std::is_function<fptr>::value << '\n';     std::cout << std::is_pointer<fptr>::value << '\n';     std::cout << std::is_pointer<intptr>::value << '\n'; }  0 1 1 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -