With this code (valid C++11):
#include <stdio.h>
#include <typeinfo>
bool my_awesome_func(int param) {
return (param > 1);
}
int main(int argc, char const *argv[]) {
fprintf(stderr, "type of my_awesome_func: %s\n",
typeid(my_awesome_func).name());
if (my_awesome_func) {
fprintf(stderr, "WHAT???\n");
}
return 0;
}
The question is inside of the if
statement. While typeid
returns me something that looks like FbiE
(which I think is gcc language for function type) I do not understand why this type is being implicitly converted into bool
(just an example, also works with int
).
Why does the if
statement compile and evaluate true?