It is a way to cast an expression to bool. In C++ though, operator! can be overloaded. Another way for C/C++:
0 != (expr)
C++ only way:
static_cast<bool>(expr)
[Edit]
Thinking more about C++ operator overloading, it make sense to avoid using operators. Libraries like Boost.Spirit and Boost.Lambda use expression templates and lazy evaluation, so that expressions like (expr) || call()
may behave not as expected. The most bullet proof version of that macro looks like this:
#define uassert(expr) if(expr) {} else { uasserted(...); }
Here, only conversion of expr
to bool is used. The else
branch is needed to protect from expressions like uassert(x) else something_else();
.