Yigal Chripun wrote:
Andrei Alexandrescu wrote:
Yigal Chripun wrote:
your abstraction inversion example doesn't apply here. The problem I see is the narrowing implicit cast, i.e. int values behave like booleans. I have no problem with the reverse which is what your example is about.

An int does not convert to bool implicitly. An int can be tested with "if", which is a different thing.

Andrei

that is an implicit cast.

No. An implicit cast is this:

int a;
bool b = a; // doesn't compile

or this:

void fun(bool);
fun(5); // doesn't compile

You are mistakenly presupposing that if() takes a bool. In reality if() accepts a bool, an integral, a floating-point type, a pointer, an array, or a class reference.


Andrei

Reply via email to