IIRC I got shot down pretty unanimously the last time I proposed a
new libmesh_error/libmesh_assert type macro, but for this proposal
I think it's worth trying again:

Would it make sense to have a few variant macros for common assertion
cases, so that when those (debug+devel-mode) assertions get tripped we
can immediately print more information about the failure?

E.g. whereas
   libmesh_assert(a < b);
fails with an error message like
   Assertion `a < b' failed
the variant
   libmesh_assert_less(a,b);
could fail with an error message like
   Assertion `a < b' failed: `a' = 3, `b' = 2

We'd have similar macros for libmesh_assert_equal(),
libmesh_assert_notequal(), and libmesh_assert_lessequal()... or maybe
libmesh_assert_equal_to(), libmesh_assert_not_equal_to() and
libmesh_assert_less_equal() if people like the <functional> header
class names.

One catch is that we'd end up evaluating a and b multiple times, which
would be bad if a or b had side effects.  But putting a term with side
effects into an assert macro is already a horrible mistake, so
slightly-more-horrible doesn't bother me.

Any other ideas/criticisms/feedback?
---
Roy

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Libmesh-devel mailing list
Libmesh-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-devel

Reply via email to