]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Improved comparison operators for TriaAccessorBase 264/head
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Sat, 22 Nov 2014 07:08:33 +0000 (08:08 +0100)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Sat, 22 Nov 2014 07:08:33 +0000 (08:08 +0100)
The previous commit was a bit too aggressive because it is still useful to catch the case when comparing iterators to two different triangulations (leading to infinite loops).

Therefore, I now merely extended the assertion to not trigger when one of the two objects is default constructed, i.e., does contain a null pointer to tria. The comparison then does not need tria == a.tria because invalid iterators use invalid cell and level index, too (leading to !=).

include/deal.II/grid/tria_accessor.templates.h

index 97232e4268ac7f932fe7101a238b67c58f55d163..9781cc01da11515c5f1b262b3309d26d88331ae8 100644 (file)
@@ -121,8 +121,9 @@ inline
 bool
 TriaAccessorBase<structdim,dim,spacedim>::operator == (const TriaAccessorBase<structdim,dim,spacedim> &a) const
 {
-  return ((tria == a.tria) &&
-          (present_level == a.present_level) &&
+  Assert (tria == a.tria || tria == 0 || a.tria == 0,
+          TriaAccessorExceptions::ExcCantCompareIterators());
+  return ((present_level == a.present_level) &&
           (present_index == a.present_index));
 }
 
@@ -133,8 +134,9 @@ inline
 bool
 TriaAccessorBase<structdim,dim,spacedim>::operator != (const TriaAccessorBase<structdim,dim,spacedim> &a) const
 {
-  return ((tria != a.tria) ||
-          (present_level != a.present_level) ||
+  Assert (tria == a.tria || tria == 0 || a.tria == 0,
+          TriaAccessorExceptions::ExcCantCompareIterators());
+  return ((present_level != a.present_level) ||
           (present_index != a.present_index));
 }
 

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.