c++ - value of a condition
- Christof Meerwald <cmeerw web.de> Jan 10 2002
- "Walter" <walter digitalmars.com> Jan 10 2002
Hi,
According to the C++ standard (6.4 Selection statements [stmt.select]) "the
value of a condition that is an expression is the value of the expression,
implicitly converted to bool for statements other than switch". But it seems
that DM uses the value of the expression implicitly converted to int (the
following test-case prints "false"):
#include <stdio.h>
struct A
{
inline operator int()
{
return 0;
}
inline operator bool()
{
return true;
}
};
int main(int argc, char *argv[])
{
A a;
if (a)
{
printf("true\n");
return 0;
}
else
{
printf("false\n");
return 1;
}
}
bye, Christof
Jan 10 2002
Ok, I'll get it fixed. Thanks for the great bug reports! -Walter "Christof Meerwald" <cmeerw web.de> wrote in message news:a1k5q7$2v33$1 digitaldaemon.com...Hi, According to the C++ standard (6.4 Selection statements [stmt.select])
value of a condition that is an expression is the value of the expression, implicitly converted to bool for statements other than switch". But it
that DM uses the value of the expression implicitly converted to int (the following test-case prints "false"): #include <stdio.h> struct A { inline operator int() { return 0; } inline operator bool() { return true; } }; int main(int argc, char *argv[]) { A a; if (a) { printf("true\n"); return 0; } else { printf("false\n"); return 1; } } bye, Christof
Jan 10 2002








"Walter" <walter digitalmars.com>