diff --git a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Polygon_2_curve_iterator.h b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Polygon_2_curve_iterator.h index 39a5e7dd34a..833f9afd571 100644 --- a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Polygon_2_curve_iterator.h +++ b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Polygon_2_curve_iterator.h @@ -60,9 +60,9 @@ public: Edge_const_iterator m_curr_edge; // points to the current edge iterator public: - Polygon_2_curve_iterator< X_monotone_curve_2_, Polygon_ >(){} + Polygon_2_curve_iterator(){} - Polygon_2_curve_iterator< X_monotone_curve_2_, Polygon_ > + Polygon_2_curve_iterator (const Polygon* pgn, Edge_const_iterator ci) : m_pgn(pgn), m_curr_edge(ci) {} diff --git a/Boolean_set_operations_2/include/CGAL/Gps_circle_segment_traits_2.h b/Boolean_set_operations_2/include/CGAL/Gps_circle_segment_traits_2.h index 1d29214e267..4b88536cf14 100644 --- a/Boolean_set_operations_2/include/CGAL/Gps_circle_segment_traits_2.h +++ b/Boolean_set_operations_2/include/CGAL/Gps_circle_segment_traits_2.h @@ -27,7 +27,7 @@ class Gps_circle_segment_traits_2 : public Gps_traits_2 > { public: - Gps_circle_segment_traits_2(bool use_cache = false) : + Gps_circle_segment_traits_2(bool use_cache = false) : Gps_traits_2 >() { this->m_use_cache = use_cache; diff --git a/Inscribed_areas/include/CGAL/Largest_empty_iso_rectangle_2.h b/Inscribed_areas/include/CGAL/Largest_empty_iso_rectangle_2.h index 601f4d3e9d6..382c80e2c0b 100644 --- a/Inscribed_areas/include/CGAL/Largest_empty_iso_rectangle_2.h +++ b/Inscribed_areas/include/CGAL/Largest_empty_iso_rectangle_2.h @@ -233,12 +233,11 @@ public: ~Largest_empty_iso_rectangle_2(); //! An operator= - Largest_empty_iso_rectangle_2& - operator =(const Largest_empty_iso_rectangle_2& ler); + Largest_empty_iso_rectangle_2& + operator =(const Largest_empty_iso_rectangle_2& ler); //! A copy constructor - Largest_empty_iso_rectangle_2( - const Largest_empty_iso_rectangle_2& ler); + Largest_empty_iso_rectangle_2(const Largest_empty_iso_rectangle_2& ler); struct Internal_point { Point_2 x_part;// the x coordinate of the point diff --git a/Interpolation/include/CGAL/interpolation_functions.h b/Interpolation/include/CGAL/interpolation_functions.h index 58780776458..0c672580504 100644 --- a/Interpolation/include/CGAL/interpolation_functions.h +++ b/Interpolation/include/CGAL/interpolation_functions.h @@ -34,7 +34,7 @@ struct Data_access typedef typename Map::mapped_type Data_type; typedef typename Map::key_type Key_type; - Data_access(const Map& m): map(m){} + Data_access(const Map& m): map(m){} std::pair< Data_type, bool> operator()(const Key_type& p) const diff --git a/Number_types/include/CGAL/GMP/Gmpq_type.h b/Number_types/include/CGAL/GMP/Gmpq_type.h index 54776eb5b78..451d2b00cdd 100644 --- a/Number_types/include/CGAL/GMP/Gmpq_type.h +++ b/Number_types/include/CGAL/GMP/Gmpq_type.h @@ -223,7 +223,7 @@ public: Gmpq& operator/=(const Gmpq &q); bool operator==(const Gmpq &q) const noexcept { return mpq_equal(this->mpq(), q.mpq()) != 0;} - bool operator< (const Gmpq &q) const noexcept { return mpq_cmp(this->mpq(), q.mpq()) < 0; } + bool operator< (const Gmpq &q) const { return mpq_cmp(this->mpq(), q.mpq()) < 0; } double to_double() const noexcept; Sign sign() const noexcept; diff --git a/Number_types/include/CGAL/Lazy_exact_nt.h b/Number_types/include/CGAL/Lazy_exact_nt.h index b0c401a3797..1a511325de9 100644 --- a/Number_types/include/CGAL/Lazy_exact_nt.h +++ b/Number_types/include/CGAL/Lazy_exact_nt.h @@ -438,6 +438,69 @@ public : return *this = new Lazy_exact_Div(*this, b); } + // Mixed comparisons with int. + friend bool operator<(const Lazy_exact_nt& a, int b) + { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Uncertain res = a.approx() < b; + if (is_certain(res)) + return res; + CGAL_BRANCH_PROFILER_BRANCH(tmp); + return a.exact() < b; + } + + friend bool operator>(const Lazy_exact_nt& a, int b) + { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Uncertain res = b < a.approx(); + if (is_certain(res)) + return get_certain(res); + CGAL_BRANCH_PROFILER_BRANCH(tmp); + return b < a.exact(); + } + + friend bool operator==(const Lazy_exact_nt& a, int b) + { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Uncertain res = b == a.approx(); + if (is_certain(res)) + return get_certain(res); + CGAL_BRANCH_PROFILER_BRANCH(tmp); + return b == a.exact(); + } + + + // Mixed comparisons with double. + friend bool operator<(const Lazy_exact_nt& a, double b) + { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Uncertain res = a.approx() < b; + if (is_certain(res)) + return res; + CGAL_BRANCH_PROFILER_BRANCH(tmp); + return a.exact() < b; + } + + friend bool operator>(const Lazy_exact_nt& a, double b) + { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Uncertain res = b < a.approx(); + if (is_certain(res)) + return res; + CGAL_BRANCH_PROFILER_BRANCH(tmp); + return b < a.exact(); + } + + friend bool operator==(const Lazy_exact_nt& a, double b) + { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Uncertain res = b == a.approx(); + if (is_certain(res)) + return res; + CGAL_BRANCH_PROFILER_BRANCH(tmp); + return b == a.exact(); + } + // % kills filtering Self & operator%=(const Self& b) { @@ -562,84 +625,6 @@ operator%(const Lazy_exact_nt& a, const Lazy_exact_nt& b) } - -// Mixed operators with int. -template -bool -operator<(const Lazy_exact_nt& a, int b) -{ - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); - Uncertain res = a.approx() < b; - if (is_certain(res)) - return res; - CGAL_BRANCH_PROFILER_BRANCH(tmp); - return a.exact() < b; -} - -template -bool -operator>(const Lazy_exact_nt& a, int b) -{ - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); - Uncertain res = b < a.approx(); - if (is_certain(res)) - return get_certain(res); - CGAL_BRANCH_PROFILER_BRANCH(tmp); - return b < a.exact(); -} - -template -bool -operator==(const Lazy_exact_nt& a, int b) -{ - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); - Uncertain res = b == a.approx(); - if (is_certain(res)) - return get_certain(res); - CGAL_BRANCH_PROFILER_BRANCH(tmp); - return b == a.exact(); -} - - -// Mixed operators with double. -template -bool -operator<(const Lazy_exact_nt& a, double b) -{ - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); - Uncertain res = a.approx() < b; - if (is_certain(res)) - return res; - CGAL_BRANCH_PROFILER_BRANCH(tmp); - return a.exact() < b; -} - -template -bool -operator>(const Lazy_exact_nt& a, double b) -{ - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); - Uncertain res = b < a.approx(); - if (is_certain(res)) - return res; - CGAL_BRANCH_PROFILER_BRANCH(tmp); - return b < a.exact(); -} - -template -bool -operator==(const Lazy_exact_nt& a, double b) -{ - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); - Uncertain res = b == a.approx(); - if (is_certain(res)) - return res; - CGAL_BRANCH_PROFILER_BRANCH(tmp); - return b == a.exact(); -} - - - template Lazy_exact_nt< typename Coercion_traits::Type > operator+(const Lazy_exact_nt& a, const Lazy_exact_nt& b) diff --git a/Number_types/include/CGAL/MP_Float.h b/Number_types/include/CGAL/MP_Float.h index 56e22b7e39b..68cfdecde44 100644 --- a/Number_types/include/CGAL/MP_Float.h +++ b/Number_types/include/CGAL/MP_Float.h @@ -27,6 +27,7 @@ #include #include #include +#include // MP_Float : multiprecision scaled integers. @@ -106,7 +107,13 @@ MP_Float operator*(const MP_Float &a, const MP_Float &b); MP_Float operator%(const MP_Float &a, const MP_Float &b); -class MP_Float +class MP_Float : boost::totally_ordered1 > +#endif + > { public: typedef short limb; @@ -223,6 +230,22 @@ public: MP_Float& operator*=(const MP_Float &a) { return *this = *this * a; } MP_Float& operator%=(const MP_Float &a) { return *this = *this % a; } + friend bool operator<(const MP_Float &a, const MP_Float &b) + { return INTERN_MP_FLOAT::compare(a, b) == SMALLER; } + + friend bool operator==(const MP_Float &a, const MP_Float &b) + { return (a.v == b.v) && (a.v.empty() || (a.exp == b.exp)); } + +#ifdef _MSC_VER + // Needed because without /permissive-, it makes hidden friends visible (from Quotient) + friend bool operator==(const MP_Float &a, int b) { return a == MP_Float(b); } + friend bool operator==(const MP_Float &a, double b) { return a == MP_Float(b); } + friend bool operator< (const MP_Float &a, int b) { return a < MP_Float(b); } + friend bool operator< (const MP_Float &a, double b) { return a < MP_Float(b); } + friend bool operator> (const MP_Float &a, int b) { return a > MP_Float(b); } + friend bool operator> (const MP_Float &a, double b) { return a > MP_Float(b); } +#endif + exponent_type max_exp() const { return exponent_type(v.size()) + exp; @@ -365,30 +388,6 @@ inline void swap(MP_Float &m, MP_Float &n) { m.swap(n); } -inline -bool operator<(const MP_Float &a, const MP_Float &b) -{ return INTERN_MP_FLOAT::compare(a, b) == SMALLER; } - -inline -bool operator>(const MP_Float &a, const MP_Float &b) -{ return b < a; } - -inline -bool operator>=(const MP_Float &a, const MP_Float &b) -{ return ! (a < b); } - -inline -bool operator<=(const MP_Float &a, const MP_Float &b) -{ return ! (a > b); } - -inline -bool operator==(const MP_Float &a, const MP_Float &b) -{ return (a.v == b.v) && (a.v.empty() || (a.exp == b.exp)); } - -inline -bool operator!=(const MP_Float &a, const MP_Float &b) -{ return ! (a == b); } - MP_Float approximate_sqrt(const MP_Float &d); diff --git a/Number_types/include/CGAL/Quotient.h b/Number_types/include/CGAL/Quotient.h index 38e5f834768..9e5ac07cb59 100644 --- a/Number_types/include/CGAL/Quotient.h +++ b/Number_types/include/CGAL/Quotient.h @@ -129,6 +129,15 @@ class Quotient Quotient& operator*= (const CGAL_double(NT)& r); Quotient& operator/= (const CGAL_double(NT)& r); + friend bool operator==(const Quotient& x, const Quotient& y) + { return x.num * y.den == x.den * y.num; } + friend bool operator==(const Quotient& x, const NT& y) + { return x.den * y == x.num; } + friend inline bool operator==(const Quotient& x, const CGAL_int(NT) & y) + { return x.den * y == x.num; } + friend inline bool operator==(const Quotient& x, const CGAL_double(NT) & y) + { return x.den * y == x.num; } // Uh? + Quotient& normalize(); const NT& numerator() const { return num; } @@ -438,31 +447,6 @@ quotient_truncation(const Quotient& r) -template -CGAL_MEDIUM_INLINE -bool -operator==(const Quotient& x, const Quotient& y) -{ return x.num * y.den == x.den * y.num; } - -template -CGAL_MEDIUM_INLINE -bool -operator==(const Quotient& x, const NT& y) -{ return x.den * y == x.num; } - -template -inline -bool -operator==(const Quotient& x, const CGAL_int(NT) & y) -{ return x.den * y == x.num; } - -template -inline -bool -operator==(const Quotient& x, const CGAL_double(NT) & y) -{ return x.den * y == x.num; } - - template CGAL_MEDIUM_INLINE diff --git a/Polynomial/include/CGAL/Polynomial/Polynomial_type.h b/Polynomial/include/CGAL/Polynomial/Polynomial_type.h index b30cf524458..540f17bd203 100644 --- a/Polynomial/include/CGAL/Polynomial/Polynomial_type.h +++ b/Polynomial/include/CGAL/Polynomial/Polynomial_type.h @@ -957,6 +957,52 @@ public: } friend Polynomial operator - <> (const Polynomial&); + + // + // Comparison Operators + // + + // polynomials only + friend bool operator == (const Polynomial& p1, const Polynomial& p2) { + CGAL_precondition(p1.degree() >= 0); + CGAL_precondition(p2.degree() >= 0); + if (p1.is_identical(p2)) return true; + if (p1.degree() != p2.degree()) return false; + for (int i = p1.degree(); i >= 0; i--) if (p1[i] != p2[i]) return false; + return true; + } + friend bool operator < (const Polynomial& p1, const Polynomial& p2) + { return ( p1.compare(p2) < 0 ); } + + // operators NT + friend bool operator == (const Polynomial& p, const NT& num) { + CGAL_precondition(p.degree() >= 0); + return p.degree() == 0 && p[0] == num; + } + friend bool operator < (const Polynomial& p,const NT& num) + { return ( p.compare(num) < 0 );} + friend bool operator > (const Polynomial& p,const NT& num) + { return ( p.compare(num) > 0 );} + + // compare int ################################# + friend bool operator == (const Polynomial& p, const CGAL_int(NT)& num) { + CGAL_precondition(p.degree() >= 0); + return p.degree() == 0 && p[0] == NT(num); + } + friend bool operator < (const Polynomial& p, const CGAL_int(NT)& num) + { return ( p.compare(NT(num)) < 0 );} + friend bool operator > (const Polynomial& p, const CGAL_int(NT)& num) + { return ( p.compare(NT(num)) > 0 );} + + // compare icoeff ################################### + friend bool operator == (const Polynomial& p, const CGAL_icoeff(NT)& num) { + CGAL_precondition(p.degree() >= 0); + return p.degree() == 0 && p[0] == NT(num); + } + friend bool operator < (const Polynomial& p, const CGAL_icoeff(NT)& num) + { return ( p.compare(NT(num)) < 0 );} + friend bool operator > (const Polynomial& p, const CGAL_icoeff(NT)& num) + { return ( p.compare(NT(num)) > 0 );} }; // class Polynomial // Arithmetic Operators, Part III: @@ -999,102 +1045,6 @@ Polynomial operator * (const Polynomial& p1, } -// -// Comparison Operators -// - -// polynomials only -template inline -bool operator == (const Polynomial& p1, const Polynomial& p2) { - CGAL_precondition(p1.degree() >= 0); - CGAL_precondition(p2.degree() >= 0); - if (p1.is_identical(p2)) return true; - if (p1.degree() != p2.degree()) return false; - for (int i = p1.degree(); i >= 0; i--) if (p1[i] != p2[i]) return false; - return true; -} -template inline -bool operator < (const Polynomial& p1, const Polynomial& p2) -{ return ( p1.compare(p2) < 0 ); } -template inline -bool operator > (const Polynomial& p1, const Polynomial& p2) -{ return ( p1.compare(p2) > 0 ); } - -// operators NT -template inline -bool operator == (const NT& num, const Polynomial& p) { - CGAL_precondition(p.degree() >= 0); - return p.degree() == 0 && p[0] == num; -} -template inline -bool operator == (const Polynomial& p, const NT& num) { - CGAL_precondition(p.degree() >= 0); - return p.degree() == 0 && p[0] == num; -} -template inline -bool operator < (const NT& num, const Polynomial& p) -{ return ( p.compare(num) > 0 );} -template inline -bool operator < (const Polynomial& p,const NT& num) -{ return ( p.compare(num) < 0 );} -template inline -bool operator > (const NT& num, const Polynomial& p) -{ return ( p.compare(num) < 0 );} -template inline -bool operator > (const Polynomial& p,const NT& num) -{ return ( p.compare(num) > 0 );} - - -// compare int ################################# -template inline -bool operator == (const CGAL_int(NT)& num, const Polynomial& p) { - CGAL_precondition(p.degree() >= 0); - return p.degree() == 0 && p[0] == NT(num); -} -template inline -bool operator == (const Polynomial& p, const CGAL_int(NT)& num) { - CGAL_precondition(p.degree() >= 0); - return p.degree() == 0 && p[0] == NT(num); -} -template inline -bool operator < (const CGAL_int(NT)& num, const Polynomial& p) -{ return ( p.compare(NT(num)) > 0 );} -template inline -bool operator < (const Polynomial& p, const CGAL_int(NT)& num) -{ return ( p.compare(NT(num)) < 0 );} -template inline -bool operator > (const CGAL_int(NT)& num, const Polynomial& p) -{ return ( p.compare(NT(num)) < 0 );} -template inline -bool operator > (const Polynomial& p, const CGAL_int(NT)& num) -{ return ( p.compare(NT(num)) > 0 );} - -// compare icoeff ################################### -template inline -bool operator == (const CGAL_icoeff(NT)& num, const Polynomial& p) { - CGAL_precondition(p.degree() >= 0); - return p.degree() == 0 && p[0] == NT(num); -} -template inline -bool operator == (const Polynomial& p, const CGAL_icoeff(NT)& num) { - CGAL_precondition(p.degree() >= 0); - return p.degree() == 0 && p[0] == NT(num); -} -template inline -bool operator < (const CGAL_icoeff(NT)& num, const Polynomial& p) -{ return ( p.compare(NT(num)) > 0 );} -template inline -bool operator < (const Polynomial& p, const CGAL_icoeff(NT)& num) -{ return ( p.compare(NT(num)) < 0 );} - - -template inline -bool operator > (const CGAL_icoeff(NT)& num, const Polynomial& p) -{ return ( p.compare(NT(num)) < 0 );} -template inline -bool operator > (const Polynomial& p, const CGAL_icoeff(NT)& num) -{ return ( p.compare(NT(num)) > 0 );} - // // Algebraically non-trivial operations // diff --git a/STL_Extension/include/CGAL/Concurrent_compact_container.h b/STL_Extension/include/CGAL/Concurrent_compact_container.h index 5ab9eca6790..2cf395fdba6 100644 --- a/STL_Extension/include/CGAL/Concurrent_compact_container.h +++ b/STL_Extension/include/CGAL/Concurrent_compact_container.h @@ -718,7 +718,7 @@ void Concurrent_compact_container::clear() size_type s = it->second; for (pointer pp = p + 1; pp != p + s - 1; ++pp) { if (type(pp) == USED) - m_alloc.destroy(pp); + std::allocator_traits::destroy(m_alloc, pp); } m_alloc.deallocate(p, s); } diff --git a/Union_find/include/CGAL/Union_find.h b/Union_find/include/CGAL/Union_find.h index a76cf515856..16dc14bdb74 100644 --- a/Union_find/include/CGAL/Union_find.h +++ b/Union_find/include/CGAL/Union_find.h @@ -114,8 +114,7 @@ public: #ifdef _MSC_VER typedef CGAL_ALLOCATOR(Union_find_struct) allocator; #else - typedef typename A::template rebind Rebind; - typedef typename Rebind::other allocator; + typedef typename std::allocator_traits::template rebind_alloc allocator; #endif private: