The macro checks the condition. This condition must be true
, otherwise it will throw an exception. If this is true, you will put the brackets after the usual if
.
You would use it as follows:
QL_REQUIRE (x != 0, "x must not be 0") { y = 100 / x; //dividing by 0 is bad }
The macro is provided, and if it does not work, it will print this message. If this does not fail, your curly braces or single-line expressions form an else statement. The logic just changed a bit if you look at all this. When used, it is similar to if
, but if it is swapped, if
and else
will get the opposite roles.
It's kind of like saying this:
assert (x != 0 && "x must not be 0"); y = 100 / x; //dividing by 0 is bad
chris source share