]> https://gitweb.dealii.org/ - dealii.git/commitdiff
New AssertIndexRange to abbreviate these assertions
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Wed, 14 Nov 2007 00:17:24 +0000 (00:17 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Wed, 14 Nov 2007 00:17:24 +0000 (00:17 +0000)
git-svn-id: https://svn.dealii.org/trunk@15494 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/exceptions.h

index 99ef2988be2fa19f6d44f27bdf7a83dfac33177f..ccbb20de67581031b47b2856c593f9a2becb65d1 100644 (file)
@@ -919,6 +919,20 @@ namespace StandardExceptions
 #define AssertDimension(dim1,dim2) Assert((dim1) == (dim2), \
   ExcDimensionMismatch((dim1),(dim2)))
 
+/**
+ * Special assertion for index range of nonnegative indices.
+ *
+ * Since this is used very often and always repeats the arguments, we
+ * introduce this special assertion for ExcIndexRange in order
+ * to keep the user codes shorter.
+ *
+ * Called wit arguments <tt>index</tt> and <tt>range</tt> it asserts
+ * that <tt>index&lt;range</tt> and throws
+ * ExcIndexRange(index,0,range) if it fails.
+ */
+#define AssertIndexRange(index,range) Assert((index) < (range), \
+  ExcIndexRange((index),0,(range)))
+
 
 /*
  * Unfortunately, the following must be repeated for each library,

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.