Often one wants to print out additional information if an assert
fails. A way to do that is this:
assert(vec.size() > i ||
!(std::cerr << "False: " << vec.size() << ">" << i))
This way the actual sizes are printed when the assert
fails. But it's ugly, and also it's easy to forget the !
, which will make the assertion condition true and the program will just continue.
What do people use instead to print additional information on assertion failure, like above?