A
Aries Sun
The following code can be compiled without error:
typedef char True; // sizeof(True) == 1
typedef struct { char a[2]; } False; // sizeof(False) > 1
//...
template <typename T> True isPtr( T * );
template <typename T> False isPtr(T);
#define is_ptr( e ) (sizeof(isPtr(e))==sizeof(True))
int main() {
int *a;
cout << is_ptr(a) << endl;
}
why the following can compile:
int test();
int main() {
cout << sizeof(test);
}
typedef char True; // sizeof(True) == 1
typedef struct { char a[2]; } False; // sizeof(False) > 1
//...
template <typename T> True isPtr( T * );
template <typename T> False isPtr(T);
#define is_ptr( e ) (sizeof(isPtr(e))==sizeof(True))
int main() {
int *a;
cout << is_ptr(a) << endl;
}
why the following can compile:
int test();
int main() {
cout << sizeof(test);
}