diff --git a/Number_types/include/CGAL/Root_of_traits.h b/Number_types/include/CGAL/Root_of_traits.h index 9fa90959b7b..e8709e047d5 100644 --- a/Number_types/include/CGAL/Root_of_traits.h +++ b/Number_types/include/CGAL/Root_of_traits.h @@ -35,14 +35,23 @@ struct Root_of_traits_helper{ typedef Root_of_2 Root_of_2; struct Make_root_of_2{ typedef Root_of_2 result_type; - NT operator()(const NT& a, const NT& b, const NT& c){ + Root_of_2 operator()(const NT& a, const NT& b, const NT& c){ return Root_of_2(a,b,c); } - Root_of_1 operator()(const Root_of_1& a, + Root_of_2 operator()(const NT& a, const NT& b, const NT& c, bool s){ + return Root_of_2(a,b,c,s); + } + Root_of_2 operator()(const Root_of_1& a, const Root_of_1& b, const Root_of_1& c){ return Root_of_2(a,b,c); } + Root_of_2 operator()(const Root_of_1& a, + const Root_of_1& b, + const Root_of_1& c, + bool s){ + return Root_of_2(a,b,c,s); + } }; }; diff --git a/Number_types/test/Number_types/Root_of_traits.C b/Number_types/test/Number_types/Root_of_traits.C index 449d3ed2449..7815b9697ee 100644 --- a/Number_types/test/Number_types/Root_of_traits.C +++ b/Number_types/test/Number_types/Root_of_traits.C @@ -13,6 +13,13 @@ #include #include +#include +#include +#include +#include + + + template void test_root_of_traits(){ // pure type checking @@ -26,6 +33,15 @@ void test_root_of_traits(){ typedef typename RoT::Make_root_of_2 Make_root_of_2; typedef typename Make_root_of_2::result_type result_type; BOOST_STATIC_ASSERT((::boost::is_same::value)); + + Root_of_2 r = CGAL::make_root_of_2(T(0),T(-1),T(2)); //-sqrt(2) + Root_of_2 rl = CGAL::make_root_of_2(T(1),T(0),T(-2),true); //-sqrt(2); + Root_of_2 rr = CGAL::make_root_of_2(T(1),T(0),T(-2),false); //+sqrt(2) + CGAL_test_assert(r == rl); + CGAL_test_assert(rl != rr); + + CGAL_test_assert( r * Root_of_1(2) == CGAL::make_root_of_2(T(0),T(-2),T(2))); + CGAL_test_assert( r * T(2) == CGAL::make_root_of_2(T(0),T(-2),T(2))); } int main(){