diff --git a/Interval_arithmetic/changes.txt b/Interval_arithmetic/changes.txt index daa29bd073b..d78ece0a41a 100644 --- a/Interval_arithmetic/changes.txt +++ b/Interval_arithmetic/changes.txt @@ -1,3 +1,6 @@ +21 February 2006 Sylvain Pion +- Lazy_exact_nt : add some preconditions (divisor != 0) in operator/ and co. + 19 February 2006 Sylvain Pion - Add more coordinate comparison functors to Static_filters (less*, compare*). diff --git a/Interval_arithmetic/include/CGAL/Lazy_exact_nt.h b/Interval_arithmetic/include/CGAL/Lazy_exact_nt.h index 4e993ea22fb..9693bedff57 100644 --- a/Interval_arithmetic/include/CGAL/Lazy_exact_nt.h +++ b/Interval_arithmetic/include/CGAL/Lazy_exact_nt.h @@ -565,7 +565,10 @@ public : { return *this = new Lazy_exact_Mul(*this, b); } Self & operator/=(const Self& b) - { return *this = new Lazy_exact_Div(*this, b); } + { + CGAL_precondition(b != 0); + return *this = new Lazy_exact_Div(*this, b); + } // Mixed operators. (could be optimized ?) Self & operator+=(CGAL_int(ET) b) @@ -578,7 +581,10 @@ public : { return *this = new Lazy_exact_Mul(*this, b); } Self & operator/=(CGAL_int(ET) b) - { return *this = new Lazy_exact_Div(*this, b); } + { + CGAL_precondition(b != 0); + return *this = new Lazy_exact_Div(*this, b); + } Self & operator+=(CGAL_double(ET) b) { return *this = new Lazy_exact_Add(*this, b); } @@ -590,11 +596,15 @@ public : { return *this = new Lazy_exact_Mul(*this, b); } Self & operator/=(CGAL_double(ET) b) - { return *this = new Lazy_exact_Div(*this, b); } + { + CGAL_precondition(b != 0); + return *this = new Lazy_exact_Div(*this, b); + } // % kills filtering Self & operator%=(const Self& b) { + CGAL_precondition(b != 0); ET res = exact(); res %= b.exact(); return *this = Lazy_exact_nt(res); @@ -602,6 +612,7 @@ public : Self & operator%=(int b) { + CGAL_precondition(b != 0); ET res = exact(); res %= b; return *this = Lazy_exact_nt(res); @@ -723,7 +734,10 @@ template inline Lazy_exact_nt operator%(const Lazy_exact_nt& a, const Lazy_exact_nt& b) -{ return Lazy_exact_nt(a) %= b; } +{ + CGAL_precondition(b != 0); + return Lazy_exact_nt(a) %= b; +} @@ -794,6 +808,7 @@ template Lazy_exact_nt< typename Binary_operator_result::type > operator/(const Lazy_exact_nt& a, const Lazy_exact_nt& b) { + CGAL_precondition(b != 0); return new Lazy_exact_Div::type, ET1, ET2>(a, b); } @@ -867,7 +882,10 @@ template inline Lazy_exact_nt sqrt(const Lazy_exact_nt & a) -{ return new Lazy_exact_Sqrt(a); } +{ + CGAL_precondition(a >= 0); + return new Lazy_exact_Sqrt(a); +} template inline