Merge pull request #4640 from mglisse/spaceship

C++20 fixes
This commit is contained in:
Laurent Rineau 2020-05-27 16:33:33 +02:00
commit 14c3b7ec72
11 changed files with 152 additions and 236 deletions

View File

@ -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) {}

View File

@ -27,7 +27,7 @@ class Gps_circle_segment_traits_2 :
public Gps_traits_2<Arr_circle_segment_traits_2<Kernel_, Filer_> >
{
public:
Gps_circle_segment_traits_2<Kernel_, Filer_>(bool use_cache = false) :
Gps_circle_segment_traits_2(bool use_cache = false) :
Gps_traits_2<Arr_circle_segment_traits_2<Kernel_, Filer_> >()
{
this->m_use_cache = use_cache;

View File

@ -233,12 +233,11 @@ public:
~Largest_empty_iso_rectangle_2();
//! An operator=
Largest_empty_iso_rectangle_2<T>&
operator =(const Largest_empty_iso_rectangle_2<T>& ler);
Largest_empty_iso_rectangle_2&
operator =(const Largest_empty_iso_rectangle_2& ler);
//! A copy constructor
Largest_empty_iso_rectangle_2<T>(
const Largest_empty_iso_rectangle_2<T>& 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

View File

@ -34,7 +34,7 @@ struct Data_access
typedef typename Map::mapped_type Data_type;
typedef typename Map::key_type Key_type;
Data_access<Map>(const Map& m): map(m){}
Data_access(const Map& m): map(m){}
std::pair< Data_type, bool>
operator()(const Key_type& p) const

View File

@ -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;

View File

@ -438,6 +438,69 @@ public :
return *this = new Lazy_exact_Div<ET>(*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<bool> 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<bool> 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<bool> 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<bool> 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<bool> 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<bool> 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<ET>& a, const Lazy_exact_nt<ET>& b)
}
// Mixed operators with int.
template <typename ET>
bool
operator<(const Lazy_exact_nt<ET>& a, int b)
{
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
Uncertain<bool> res = a.approx() < b;
if (is_certain(res))
return res;
CGAL_BRANCH_PROFILER_BRANCH(tmp);
return a.exact() < b;
}
template <typename ET>
bool
operator>(const Lazy_exact_nt<ET>& a, int b)
{
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
Uncertain<bool> res = b < a.approx();
if (is_certain(res))
return get_certain(res);
CGAL_BRANCH_PROFILER_BRANCH(tmp);
return b < a.exact();
}
template <typename ET>
bool
operator==(const Lazy_exact_nt<ET>& a, int b)
{
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
Uncertain<bool> 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 <typename ET>
bool
operator<(const Lazy_exact_nt<ET>& a, double b)
{
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
Uncertain<bool> res = a.approx() < b;
if (is_certain(res))
return res;
CGAL_BRANCH_PROFILER_BRANCH(tmp);
return a.exact() < b;
}
template <typename ET>
bool
operator>(const Lazy_exact_nt<ET>& a, double b)
{
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
Uncertain<bool> res = b < a.approx();
if (is_certain(res))
return res;
CGAL_BRANCH_PROFILER_BRANCH(tmp);
return b < a.exact();
}
template <typename ET>
bool
operator==(const Lazy_exact_nt<ET>& a, double b)
{
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
Uncertain<bool> res = b == a.approx();
if (is_certain(res))
return res;
CGAL_BRANCH_PROFILER_BRANCH(tmp);
return b == a.exact();
}
template <typename ET1, typename ET2>
Lazy_exact_nt< typename Coercion_traits<ET1, ET2>::Type >
operator+(const Lazy_exact_nt<ET1>& a, const Lazy_exact_nt<ET2>& b)

View File

@ -27,6 +27,7 @@
#include <iostream>
#include <vector>
#include <algorithm>
#include <boost/operators.hpp>
// 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<MP_Float
#ifdef _MSC_VER
, boost::ordered_ring_operators2<MP_Float, int
, boost::ordered_ring_operators2<MP_Float, double
> >
#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);

View File

@ -129,6 +129,15 @@ class Quotient
Quotient<NT>& operator*= (const CGAL_double(NT)& r);
Quotient<NT>& 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<NT>& normalize();
const NT& numerator() const { return num; }
@ -438,31 +447,6 @@ quotient_truncation(const Quotient<NT>& r)
template <class NT>
CGAL_MEDIUM_INLINE
bool
operator==(const Quotient<NT>& x, const Quotient<NT>& y)
{ return x.num * y.den == x.den * y.num; }
template <class NT>
CGAL_MEDIUM_INLINE
bool
operator==(const Quotient<NT>& x, const NT& y)
{ return x.den * y == x.num; }
template <class NT>
inline
bool
operator==(const Quotient<NT>& x, const CGAL_int(NT) & y)
{ return x.den * y == x.num; }
template <class NT>
inline
bool
operator==(const Quotient<NT>& x, const CGAL_double(NT) & y)
{ return x.den * y == x.num; }
template <class NT>
CGAL_MEDIUM_INLINE

View File

@ -957,6 +957,52 @@ public:
}
friend Polynomial<NT> operator - <> (const Polynomial<NT>&);
//
// 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<NT_>
// Arithmetic Operators, Part III:
@ -999,102 +1045,6 @@ Polynomial<NT> operator * (const Polynomial<NT>& p1,
}
//
// Comparison Operators
//
// polynomials only
template <class NT> inline
bool operator == (const Polynomial<NT>& p1, const Polynomial<NT>& 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 <class NT> inline
bool operator < (const Polynomial<NT>& p1, const Polynomial<NT>& p2)
{ return ( p1.compare(p2) < 0 ); }
template <class NT> inline
bool operator > (const Polynomial<NT>& p1, const Polynomial<NT>& p2)
{ return ( p1.compare(p2) > 0 ); }
// operators NT
template <class NT> inline
bool operator == (const NT& num, const Polynomial<NT>& p) {
CGAL_precondition(p.degree() >= 0);
return p.degree() == 0 && p[0] == num;
}
template <class NT> inline
bool operator == (const Polynomial<NT>& p, const NT& num) {
CGAL_precondition(p.degree() >= 0);
return p.degree() == 0 && p[0] == num;
}
template <class NT> inline
bool operator < (const NT& num, const Polynomial<NT>& p)
{ return ( p.compare(num) > 0 );}
template <class NT> inline
bool operator < (const Polynomial<NT>& p,const NT& num)
{ return ( p.compare(num) < 0 );}
template <class NT> inline
bool operator > (const NT& num, const Polynomial<NT>& p)
{ return ( p.compare(num) < 0 );}
template <class NT> inline
bool operator > (const Polynomial<NT>& p,const NT& num)
{ return ( p.compare(num) > 0 );}
// compare int #################################
template <class NT> inline
bool operator == (const CGAL_int(NT)& num, const Polynomial<NT>& p) {
CGAL_precondition(p.degree() >= 0);
return p.degree() == 0 && p[0] == NT(num);
}
template <class NT> inline
bool operator == (const Polynomial<NT>& p, const CGAL_int(NT)& num) {
CGAL_precondition(p.degree() >= 0);
return p.degree() == 0 && p[0] == NT(num);
}
template <class NT> inline
bool operator < (const CGAL_int(NT)& num, const Polynomial<NT>& p)
{ return ( p.compare(NT(num)) > 0 );}
template <class NT> inline
bool operator < (const Polynomial<NT>& p, const CGAL_int(NT)& num)
{ return ( p.compare(NT(num)) < 0 );}
template <class NT> inline
bool operator > (const CGAL_int(NT)& num, const Polynomial<NT>& p)
{ return ( p.compare(NT(num)) < 0 );}
template <class NT> inline
bool operator > (const Polynomial<NT>& p, const CGAL_int(NT)& num)
{ return ( p.compare(NT(num)) > 0 );}
// compare icoeff ###################################
template <class NT> inline
bool operator == (const CGAL_icoeff(NT)& num, const Polynomial<NT>& p) {
CGAL_precondition(p.degree() >= 0);
return p.degree() == 0 && p[0] == NT(num);
}
template <class NT> inline
bool operator == (const Polynomial<NT>& p, const CGAL_icoeff(NT)& num) {
CGAL_precondition(p.degree() >= 0);
return p.degree() == 0 && p[0] == NT(num);
}
template <class NT> inline
bool operator < (const CGAL_icoeff(NT)& num, const Polynomial<NT>& p)
{ return ( p.compare(NT(num)) > 0 );}
template <class NT> inline
bool operator < (const Polynomial<NT>& p, const CGAL_icoeff(NT)& num)
{ return ( p.compare(NT(num)) < 0 );}
template <class NT> inline
bool operator > (const CGAL_icoeff(NT)& num, const Polynomial<NT>& p)
{ return ( p.compare(NT(num)) < 0 );}
template <class NT> inline
bool operator > (const Polynomial<NT>& p, const CGAL_icoeff(NT)& num)
{ return ( p.compare(NT(num)) > 0 );}
//
// Algebraically non-trivial operations
//

View File

@ -718,7 +718,7 @@ void Concurrent_compact_container<T, Allocator>::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<allocator_type>::destroy(m_alloc, pp);
}
m_alloc.deallocate(p, s);
}

View File

@ -114,8 +114,7 @@ public:
#ifdef _MSC_VER
typedef CGAL_ALLOCATOR(Union_find_struct) allocator;
#else
typedef typename A::template rebind<Union_find_struct> Rebind;
typedef typename Rebind::other allocator;
typedef typename std::allocator_traits<A>::template rebind_alloc<Union_find_struct> allocator;
#endif
private: