3 ms·
>In example 1 though it's just called silly. What's wrong with that one? It's arguably a point about style. The original code saved the effort of typing "asse
by jasode 10y ago
>In example 1 though it's just called silly. What's wrong with that one?
It's arguably a point about style. The original code saved the effort of typing "assert()" twice but the granularity of exactly which condition failed the assertion is lost. E.g., a MSVC error will show granularity of line# but not the subexpression[1].
So there's a benefit of improved error reporting if the programmer wraps each conditional with its own assert().
[1] https://www.google.com/search?q=c%2B%2B+assert+error&source=lnms&tbm=isch https://www.google.com/search?q=c%2B%2B+assert+error&source=...