
On 6/18/2011 6:23 AM, Frédéric Bron wrote:
The following code gives a compile time error (g++ and msvc): int const lhs=1; int* rhs=0; lhs == rhs;
Expected.
But the following code gives no error: int const lhs=0; int* rhs=0; lhs == rhs; because a const int with 0 value is a valid null pointer!
Or you could say: 0 == rhs which is valid.
Then there is no way to predict if it is possible to compare lhs and rhs based only on their types.
Why do you write this ? Just because 0 can be an integer or a null pointer in C++ does not mean the above.
The general rule is that it is not possible so that this is what I propose to use for the type trait extension detecting the possibility to call comparison operators on given types.
To what does "this" refer in your previous sentence ?