// Copyright (c) 1997 // Utrecht University (The Netherlands), // ETH Zurich (Switzerland), // INRIA Sophia-Antipolis (France), // Max-Planck-Institute Saarbruecken (Germany), // and Tel-Aviv University (Israel). All rights reserved. // // This file is part of CGAL (www.cgal.org) // // $URL: https://github.com/CGAL/cgal/blob/v5.1/Algebraic_foundations/include/CGAL/number_utils_classes.h $ // $Id: number_utils_classes.h 0779373 2020-03-26T13:31:46+01:00 Sébastien Loriot // SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Michael Hoffmann // : Michael Hemmer // to be included by number_utils.h #ifndef CGAL_NUMBER_UTILS_CLASSES_H #define CGAL_NUMBER_UTILS_CLASSES_H 1 #include #include #include #include namespace CGAL { /* Defines functors: - Is_zero - Is_one - Is_negative - Is_positive - Sgn - Abs - Compare - Square - Sqrt - Div - Gcd - To_double - To_interval */ template < class NT > struct Is_negative : Real_embeddable_traits::Is_negative {}; template < class NT > struct Is_positive : Real_embeddable_traits::Is_positive {}; template < class NT > struct Abs : Real_embeddable_traits::Abs{}; template < class NT > struct To_double : Real_embeddable_traits::To_double{}; template < class NT > struct To_interval : Real_embeddable_traits::To_interval{}; // Sign would result in a name clash with enum.h template < class NT > struct Sgn : Real_embeddable_traits::Sgn {}; template < class NT > struct Square : Algebraic_structure_traits::Square{}; template < class NT > struct Sqrt : Algebraic_structure_traits::Sqrt {}; template < class NT > struct Div : Algebraic_structure_traits::Div{}; template < class NT > struct Gcd : Algebraic_structure_traits::Gcd{}; template < class NT > struct Is_one : Algebraic_structure_traits::Is_one {}; // This is due to the fact that Is_zero may be provided by // Algebraic_structure_traits as well as Real_embeddable_traits // Of course it is not possible to derive from both since this // would cause an ambiguity. namespace internal{ template struct Is_zero_base : AST_Is_zero {} ; template struct Is_zero_base : RET_Is_zero {} ; } // namespace internal template < class NT > struct Is_zero : internal::Is_zero_base ::Is_zero, typename Real_embeddable_traits::Is_zero>{}; // This is due to the fact that CGAL::Compare is used for other // non-realembeddable types as well. // In this case we try to provide a default implementation namespace internal { template struct Compare_base: public Compare {}; template struct Compare_base :public CGAL::cpp98::binary_function< NT, NT, Comparison_result > { Comparison_result operator()( const NT& x, const NT& y) const { if (x < y) return SMALLER; if (x > y) return LARGER; CGAL_postcondition(x == y); return EQUAL; } }; } // namespace internal template < class NT > struct Compare :public internal::Compare_base ::Compare>{}; } //namespace CGAL #endif // CGAL_NUMBER_UTILS_CLASSES_H