On Sunday, July 31, 2016 21:45:25 Cauterite via Digitalmars-d wrote:
> On Saturday, 30 July 2016 at 00:55:11 UTC, Charles Hixson wrote:
> > FWIW, in that case I always use
> > assert (false, "...");
> > I try to never use integers for booleans.  But this may well be
> > a common usage.
>
> I suspect `assert(0)` is really `assert(<any logically-false
> constexpr>)`, so you should be fine. Both styles are used in
> Phobos.

assert(false) is definitely equivalent to assert(0) as is any other
assertion where the compiler decides that the condition is known to be false
at compile time. However, it's not like enum or static where the condition
is forced to be evaluated at compile time. So, I don't know where it draws
the line between determining the condition at compile time and letting that
expression be evaluated at runtime. I wouldn't advise relying on it being
compile time for stuff beyond 0 or false even though there are other cases
where the compiler will decide that it knows that it's false at compile
time.

- Jonathan M Davis

Reply via email to