diff --git a/Algebraic_foundations/include/CGAL/Test/_test_real_embeddable.h b/Algebraic_foundations/include/CGAL/Test/_test_real_embeddable.h index 150ac2c834e..0b2921ee0c5 100644 --- a/Algebraic_foundations/include/CGAL/Test/_test_real_embeddable.h +++ b/Algebraic_foundations/include/CGAL/Test/_test_real_embeddable.h @@ -123,11 +123,24 @@ CGAL_BEGIN_NAMESPACE } }; +// Several libraries do not want to enforce the use of std::min/max +// for the case that there is a special function for min/max +// However, this may be a problem for template CGAL::min/max in case NT is a +// CGAL type. These types have to overload CGAL::min/max. +template +void test_min_max(){ + using std:: min BOOST_PREVENT_MACRO_SUBSTITUTION ; + using std:: max BOOST_PREVENT_MACRO_SUBSTITUTION ; + NT x(1),y(2); + assert(min BOOST_PREVENT_MACRO_SUBSTITUTION (x,y)==NT(1)); + assert(max BOOST_PREVENT_MACRO_SUBSTITUTION (x,y)==NT(2)); +} //! tests if \c Type is a model for the \c RealComparable concept //! and terminates the program with an error message if not. template void test_real_embeddable() { + test_min_max(); typedef CGAL::Real_embeddable_traits RET; CGAL_SNAP_RET_FUNCTORS(RET); typedef typename RET::Is_real_embeddable Is_real_embeddable; diff --git a/Nef_2/include/CGAL/Nef_polynomial.h b/Nef_2/include/CGAL/Nef_polynomial.h index 3725c353f1f..cac5fe6e2ce 100644 --- a/Nef_2/include/CGAL/Nef_polynomial.h +++ b/Nef_2/include/CGAL/Nef_polynomial.h @@ -221,6 +221,18 @@ template class Real_embeddable_traits< Nef_polynomial > }; }; +template +inline Nef_polynomial min BOOST_PREVENT_MACRO_SUBSTITUTION +(const Nef_polynomial& x,const Nef_polynomial& y){ + return (x<=y)?x:y; +} + +template +inline Nef_polynomial max BOOST_PREVENT_MACRO_SUBSTITUTION +(const Nef_polynomial& x,const Nef_polynomial& y){ + return (x>=y)?x:y; +} + template class Fraction_traits > { public: diff --git a/Number_types/include/CGAL/Counted_number.h b/Number_types/include/CGAL/Counted_number.h index 9cde32122e6..a452e21eb31 100644 --- a/Number_types/include/CGAL/Counted_number.h +++ b/Number_types/include/CGAL/Counted_number.h @@ -768,6 +768,19 @@ public: }; }; +template inline +Counted_number min BOOST_PREVENT_MACRO_SUBSTITUTION( +const Counted_number & x, +const Counted_number & y){ + return CGAL::Min > ()(x,y); +} +template inline +Counted_number max BOOST_PREVENT_MACRO_SUBSTITUTION( +const Counted_number & x, +const Counted_number & y){ + return CGAL::Max > ()(x,y); +} + CGAL_END_NAMESPACE #endif diff --git a/Number_types/include/CGAL/GMP/Gmpq_type.h b/Number_types/include/CGAL/GMP/Gmpq_type.h index 4411d8aea6c..e1041fc4b4c 100644 --- a/Number_types/include/CGAL/GMP/Gmpq_type.h +++ b/Number_types/include/CGAL/GMP/Gmpq_type.h @@ -421,6 +421,14 @@ operator>>(std::istream& is, Gmpq &z) return is; } +inline Gmpq min BOOST_PREVENT_MACRO_SUBSTITUTION(const Gmpq& x,const Gmpq& y){ + return (x<=y)?x:y; +} +inline Gmpq max BOOST_PREVENT_MACRO_SUBSTITUTION(const Gmpq& x,const Gmpq& y){ + return (x>=y)?x:y; +} + + CGAL_END_NAMESPACE diff --git a/Number_types/include/CGAL/GMP/Gmpz_type.h b/Number_types/include/CGAL/GMP/Gmpz_type.h index 974a5ca6282..73cc54fdf3d 100644 --- a/Number_types/include/CGAL/GMP/Gmpz_type.h +++ b/Number_types/include/CGAL/GMP/Gmpz_type.h @@ -454,9 +454,18 @@ struct Split_double } }; +inline Gmpz min BOOST_PREVENT_MACRO_SUBSTITUTION(const Gmpz& x,const Gmpz& y){ + return (x<=y)?x:y; +} +inline Gmpz max BOOST_PREVENT_MACRO_SUBSTITUTION(const Gmpz& x,const Gmpz& y){ + return (x>=y)?x:y; +} + + #include #include + CGAL_END_NAMESPACE #endif // CGAL_GMPZ_TYPE_H diff --git a/Number_types/include/CGAL/GMP/Gmpzf_type.h b/Number_types/include/CGAL/GMP/Gmpzf_type.h index 71b16c92061..41ae9d18cae 100644 --- a/Number_types/include/CGAL/GMP/Gmpzf_type.h +++ b/Number_types/include/CGAL/GMP/Gmpzf_type.h @@ -573,6 +573,13 @@ bool operator>(const Gmpzf &a, int b) return operator>(a, Gmpzf(b)); } +inline Gmpzf min BOOST_PREVENT_MACRO_SUBSTITUTION(const Gmpzf& x,const Gmpzf& y){ + return (x<=y)?x:y; +} +inline Gmpzf max BOOST_PREVENT_MACRO_SUBSTITUTION(const Gmpzf& x,const Gmpzf& y){ + return (x>=y)?x:y; +} + CGAL_END_NAMESPACE #endif // CGAL_GMPZF_TYPE_H diff --git a/Number_types/include/CGAL/Interval_nt.h b/Number_types/include/CGAL/Interval_nt.h index a51d9b91d7f..b282417339f 100644 --- a/Number_types/include/CGAL/Interval_nt.h +++ b/Number_types/include/CGAL/Interval_nt.h @@ -788,9 +788,6 @@ operator/ (const Interval_nt & a, int b) } // TODO: What about these two guys? Where do they belong to? - - - template struct Min > : public std::binary_function, @@ -821,6 +818,20 @@ struct Max > } }; +template inline +Interval_nt min BOOST_PREVENT_MACRO_SUBSTITUTION( +const Interval_nt & x, +const Interval_nt & y){ + return CGAL::Min > ()(x,y); +} +template inline +Interval_nt max BOOST_PREVENT_MACRO_SUBSTITUTION( +const Interval_nt & x, +const Interval_nt & y){ + return CGAL::Max > ()(x,y); +} + + // TODO : document, when we are OK with the interface. // - should it allow other number types for the exponent ? diff --git a/Number_types/include/CGAL/Lazy_exact_nt.h b/Number_types/include/CGAL/Lazy_exact_nt.h index 7457de12675..1de188a9f77 100644 --- a/Number_types/include/CGAL/Lazy_exact_nt.h +++ b/Number_types/include/CGAL/Lazy_exact_nt.h @@ -1220,6 +1220,18 @@ struct Max > } }; +template inline +Lazy_exact_nt min BOOST_PREVENT_MACRO_SUBSTITUTION( +const Lazy_exact_nt & x, +const Lazy_exact_nt & y){ + return CGAL::Min > ()(x,y); +} +template inline +Lazy_exact_nt max BOOST_PREVENT_MACRO_SUBSTITUTION( +const Lazy_exact_nt & x, +const Lazy_exact_nt & y){ + return CGAL::Max > ()(x,y); +} template std::ostream & diff --git a/Number_types/include/CGAL/MP_Float.h b/Number_types/include/CGAL/MP_Float.h index efb70438d57..8f4f218bc7a 100644 --- a/Number_types/include/CGAL/MP_Float.h +++ b/Number_types/include/CGAL/MP_Float.h @@ -822,6 +822,14 @@ public: }; }; +inline MP_Float min BOOST_PREVENT_MACRO_SUBSTITUTION(const MP_Float& x,const MP_Float& y){ + return (x<=y)?x:y; +} +inline MP_Float max BOOST_PREVENT_MACRO_SUBSTITUTION(const MP_Float& x,const MP_Float& y){ + return (x>=y)?x:y; +} + + // TODO: // // specialization of to double functor // template<> diff --git a/Number_types/include/CGAL/Root_of_2.h b/Number_types/include/CGAL/Root_of_2.h index 8a13c2ddf9b..fcd7f2b3fd4 100644 --- a/Number_types/include/CGAL/Root_of_2.h +++ b/Number_types/include/CGAL/Root_of_2.h @@ -1362,6 +1362,17 @@ public: } }; +template +inline const Root_of_2& min BOOST_PREVENT_MACRO_SUBSTITUTION +(const Root_of_2& p, const Root_of_2& q){ + return (std::min)(p, q); +} +template +inline const Root_of_2& max BOOST_PREVENT_MACRO_SUBSTITUTION +(const Root_of_2& p, const Root_of_2& q){ + return (std::max)(p, q); +} + } // namespace CGAL #undef CGAL_int diff --git a/Number_types/include/CGAL/Sqrt_extension/Real_embeddable_traits.h b/Number_types/include/CGAL/Sqrt_extension/Real_embeddable_traits.h index b099192fcb2..26683a4928f 100644 --- a/Number_types/include/CGAL/Sqrt_extension/Real_embeddable_traits.h +++ b/Number_types/include/CGAL/Sqrt_extension/Real_embeddable_traits.h @@ -88,7 +88,6 @@ class Real_embeddable_traits< Sqrt_extension > } }; }; - CGAL_END_NAMESPACE #endif diff --git a/Number_types/include/CGAL/Sqrt_extension/Sqrt_extension_type.h b/Number_types/include/CGAL/Sqrt_extension/Sqrt_extension_type.h index 39f215446ca..72c646b327a 100644 --- a/Number_types/include/CGAL/Sqrt_extension/Sqrt_extension_type.h +++ b/Number_types/include/CGAL/Sqrt_extension/Sqrt_extension_type.h @@ -606,6 +606,20 @@ template bool operator > (CGAL_int(NT) num, const Sqrt_extension& p) { return ( p.compare(num) == CGAL::SMALLER ); } +template inline +Sqrt_extension min BOOST_PREVENT_MACRO_SUBSTITUTION( +const Sqrt_extension & x, +const Sqrt_extension & y){ + return (std::min)(x,y); +} +template inline +Sqrt_extension max BOOST_PREVENT_MACRO_SUBSTITUTION( +const Sqrt_extension & x, +const Sqrt_extension & y){ + return (std::max)(x,y); +} + + CGAL_END_NAMESPACE #undef CGAL_int