From c206dcd8e1ccd1c4e8fa1661dbb7d94e3bfbf452 Mon Sep 17 00:00:00 2001 From: Sylvain Pion Date: Thu, 17 Aug 2006 11:05:53 +0000 Subject: [PATCH] Fix ambiguities in constructors of PointH?, as convertibility between RT<->FT<->int was a problem. Use enable_if<> and is_convertible<> for this. --- .../include/CGAL/Homogeneous/PointH2.h | 10 +++--- .../include/CGAL/Homogeneous/PointH3.h | 9 ++--- .../CGAL/Homogeneous/function_objects.h | 36 +++++-------------- 3 files changed, 19 insertions(+), 36 deletions(-) diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/PointH2.h b/Homogeneous_kernel/include/CGAL/Homogeneous/PointH2.h index f30d5388fb5..5639293ea88 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/PointH2.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/PointH2.h @@ -28,6 +28,8 @@ #include #include #include +#include +#include CGAL_BEGIN_NAMESPACE @@ -58,12 +60,12 @@ public: PointH2(const Origin &) : base (RT(0), RT(0), RT(1)) {} - PointH2(int x, int y) + template < typename Tx, typename Ty > + PointH2(const Tx & x, const Ty & y, + typename boost::enable_if_c::value && + boost::is_convertible::value >::type* dummy = 0) : base(x, y, RT(1)) {} - PointH2(const RT& hx, const RT& hy ) - : base (hx, hy, RT(1)) {} - PointH2(const FT& x, const FT& y) : base(Rat_traits().numerator(x) * Rat_traits().denominator(y), Rat_traits().numerator(y) * Rat_traits().denominator(x), diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/PointH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/PointH3.h index 5c66e6c6954..2a81b257dcd 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/PointH3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/PointH3.h @@ -57,10 +57,11 @@ public: PointH3(const Origin &) : base (RT(0), RT(0), RT(0), RT(1)) { } - PointH3(int x, int y, int z) - : base(x, y, z, RT(1)) {} - - PointH3(const RT& x, const RT& y, const RT& z) + template < typename Tx, typename Ty, typename Tz > + PointH3(const Tx & x, const Ty & y, const Tz & z, + typename boost::enable_if_c::value && + boost::is_convertible::value && + boost::is_convertible::value >::type* dummy = 0) : base(x, y, z, RT(1)) {} PointH3(const FT& x, const FT& y, const FT& z) diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h b/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h index 4cc1a463337..dc35513619c 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h @@ -2965,16 +2965,9 @@ namespace HomogeneousKernelFunctors { operator()(Return_base_tag, Origin o) const { return Rep(o); } + template < typename Tx, typename Ty > Rep // Point_2 - operator()(Return_base_tag, int x, int y) const - { return Rep(x, y); } - - Rep // Point_2 - operator()(Return_base_tag, const RT& x, const RT& y) const - { return Rep(x, y); } - - Rep // Point_2 - operator()(Return_base_tag, const FT& x, const FT& y) const + operator()(Return_base_tag, const Tx & x, const Ty & y) const { return Rep(x, y); } Rep // Point_2 @@ -3007,16 +3000,9 @@ namespace HomogeneousKernelFunctors { operator()(Origin o) const { return this->operator()(Return_base_tag(), o); } + template < typename Tx, typename Ty > Point_2 - operator()(int x, int y) const - { return this->operator()(Return_base_tag(), x, y); } - - Point_2 - operator()(const RT& x, const RT& y) const - { return this->operator()(Return_base_tag(), x, y); } - - Point_2 - operator()(const FT& x, const FT& y) const + operator()(const Tx & x, const Ty & y) const { return this->operator()(Return_base_tag(), x, y); } Point_2 @@ -3039,12 +3025,9 @@ namespace HomogeneousKernelFunctors { operator()(Return_base_tag, Origin o) const { return Rep(o); } + template < typename Tx, typename Ty, typename Tz > Rep // Point_3 - operator()(Return_base_tag, int x, int y, int z) const - { return Rep(x, y, z); } - - Rep // Point_3 - operator()(Return_base_tag, const RT& x, const RT& y, const RT& z) const + operator()(Return_base_tag, const Tx& x, const Ty& y, const Tz& z) const { return Rep(x, y, z); } Rep // Point_3 @@ -3060,12 +3043,9 @@ namespace HomogeneousKernelFunctors { operator()(Origin o) const { return this->operator()(Return_base_tag(), o); } + template < typename Tx, typename Ty, typename Tz > Point_3 - operator()(int x, int y, int z) const - { return this->operator()(Return_base_tag(), x, y, z); } - - Point_3 - operator()(const RT& x, const RT& y, const RT& z) const + operator()(const Tx& x, const Ty& y, const Tz& z) const { return this->operator()(Return_base_tag(), x, y, z); } Point_3