Fix the headers dependency-hell around gmpxx in Number_types

This commit is contained in:
Laurent Rineau 2019-05-09 15:05:23 +02:00
parent b29e3f996f
commit 2f8eeb0db3
14 changed files with 69 additions and 41 deletions

View File

@ -43,6 +43,8 @@
#include <boost/variant.hpp> #include <boost/variant.hpp>
#include <CGAL/Arr_tags.h> #include <CGAL/Arr_tags.h>
#include <vector>
namespace CGAL { namespace CGAL {
namespace VariantFunctors{ namespace VariantFunctors{

View File

@ -27,7 +27,7 @@
#define CGAL_SPHERICAL_KERNEL_PREDICATES_ON_CIRCULAR_ARC_POINT_3_H #define CGAL_SPHERICAL_KERNEL_PREDICATES_ON_CIRCULAR_ARC_POINT_3_H
#include <CGAL/license/Circular_kernel_3.h> #include <CGAL/license/Circular_kernel_3.h>
#include <CGAL/float.h>
namespace CGAL { namespace CGAL {
namespace SphericalFunctors { namespace SphericalFunctors {

View File

@ -32,6 +32,7 @@
#include <boost/algorithm/minmax_element.hpp> #include <boost/algorithm/minmax_element.hpp>
#include <CGAL/Classification/Feature_base.h> #include <CGAL/Classification/Feature_base.h>
#include <CGAL/int.h> #include <CGAL/int.h>
#include <CGAL/float.h>
#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple.hpp>
namespace CGAL { namespace CGAL {

View File

@ -28,6 +28,7 @@
#include <CGAL/generators.h> #include <CGAL/generators.h>
#include <CGAL/number_type_basic.h> #include <CGAL/number_type_basic.h>
#include <cmath> #include <cmath>
#include <vector>
namespace CGAL { namespace CGAL {

View File

@ -22,10 +22,14 @@
#ifndef CGAL_RESIDUE_TYPE_H #ifndef CGAL_RESIDUE_TYPE_H
#define CGAL_RESIDUE_TYPE_H #define CGAL_RESIDUE_TYPE_H
#include <CGAL/basic.h>
#include <CGAL/tss.h> #include <CGAL/tss.h>
#include <CGAL/FPU.h>
#include <CGAL/Real_embeddable_traits.h>
#include <CGAL/double.h>
#include <iostream>
#include <cfloat> #include <cfloat>
#include <cmath>
#include <boost/operators.hpp> #include <boost/operators.hpp>

View File

@ -21,11 +21,7 @@
#ifndef CGAL_MODULAR_TRAITS_H #ifndef CGAL_MODULAR_TRAITS_H
#define CGAL_MODULAR_TRAITS_H 1 #define CGAL_MODULAR_TRAITS_H 1
#include <CGAL/basic.h> #include <CGAL/tags.h>
#include <CGAL/Residue.h>
#include <CGAL/Modular_arithmetic/Residue_type.h>
#include <vector>
namespace CGAL { namespace CGAL {

View File

@ -28,7 +28,6 @@
#ifndef CGAL_RESIDUE_H #ifndef CGAL_RESIDUE_H
#define CGAL_RESIDUE_H 1 #define CGAL_RESIDUE_H 1
#include <CGAL/basic.h>
#include <CGAL/Modular_arithmetic/Residue_type.h> #include <CGAL/Modular_arithmetic/Residue_type.h>
#include <CGAL/Coercion_traits.h> #include <CGAL/Coercion_traits.h>

View File

@ -22,11 +22,6 @@
#ifndef CGAL_LAZY_EXACT_NT_H #ifndef CGAL_LAZY_EXACT_NT_H
#define CGAL_LAZY_EXACT_NT_H #define CGAL_LAZY_EXACT_NT_H
#define CGAL_int(T) typename First_if_different<int, T>::Type
#define CGAL_double(T) typename First_if_different<double, T>::Type
#define CGAL_To_interval(T) To_interval<T>
#include <CGAL/number_type_basic.h> #include <CGAL/number_type_basic.h>
#include <CGAL/assertions.h> #include <CGAL/assertions.h>
@ -53,6 +48,9 @@
#include <CGAL/IO/io.h> #include <CGAL/IO/io.h>
#define CGAL_int(T) typename First_if_different<int, T>::Type
#define CGAL_double(T) typename First_if_different<double, T>::Type
#define CGAL_To_interval(T) To_interval<T>
/* /*
* This file contains the definition of the number type Lazy_exact_nt<ET>, * This file contains the definition of the number type Lazy_exact_nt<ET>,

View File

@ -32,8 +32,6 @@
// The include is done before the protect macro on purpose, because // The include is done before the protect macro on purpose, because
// of a cyclic dependency. // of a cyclic dependency.
#include <CGAL/number_type_basic.h>
#ifndef CGAL_QUOTIENT_H #ifndef CGAL_QUOTIENT_H
#define CGAL_QUOTIENT_H #define CGAL_QUOTIENT_H

View File

@ -39,8 +39,6 @@
#ifndef CGAL_GMPXX_H #ifndef CGAL_GMPXX_H
#define CGAL_GMPXX_H #define CGAL_GMPXX_H
#include <CGAL/number_type_basic.h>
#include <cstring> // needed by GMP 4.1.4 since <gmpxx.h> misses it. #include <cstring> // needed by GMP 4.1.4 since <gmpxx.h> misses it.
#include <gmpxx.h> #include <gmpxx.h>
#include <utility> #include <utility>

View File

@ -28,7 +28,7 @@
#ifndef CGAL_GMPXX_COERCION_TRAITS_H #ifndef CGAL_GMPXX_COERCION_TRAITS_H
#define CGAL_GMPXX_COERCION_TRAITS_H 1 #define CGAL_GMPXX_COERCION_TRAITS_H 1
#include <CGAL/number_type_basic.h> #include <CGAL/gmpxx.h>
#include <CGAL/Coercion_traits.h> #include <CGAL/Coercion_traits.h>
#include <cstring> // needed by GMP 4.1.4 since <gmpxx.h> misses it. #include <cstring> // needed by GMP 4.1.4 since <gmpxx.h> misses it.

View File

@ -26,10 +26,13 @@
#ifndef CGAL_MPQ_CLASS_H #ifndef CGAL_MPQ_CLASS_H
#define CGAL_MPQ_CLASS_H #define CGAL_MPQ_CLASS_H
#include <CGAL/number_type_basic.h> #include <CGAL/Algebraic_structure_traits.h>
#include <CGAL/Real_embeddable_traits.h>
#include <CGAL/number_utils.h>
#include <CGAL/double.h>
#include <CGAL/gmpxx_coercion_traits.h> #include <CGAL/gmpxx_coercion_traits.h>
#include <CGAL/mpz_class.h> // for GCD in Type traits
#include <CGAL/IO/io.h> #include <CGAL/IO/io.h>
#include <mpfr.h>
// This file gathers the necessary adaptors so that the following // This file gathers the necessary adaptors so that the following
// C++ number types that come with GMP can be used by CGAL : // C++ number types that come with GMP can be used by CGAL :
@ -40,7 +43,7 @@
// Reading gmpxx.h shows that ::__gmp_expr<T, T> is the mp[zqf]_class proper, // Reading gmpxx.h shows that ::__gmp_expr<T, T> is the mp[zqf]_class proper,
// while ::__gmp_expr<T, U> is the others "expressions". // while ::__gmp_expr<T, U> is the others "expressions".
#define CGAL_CHECK_GMP_EXPR \ #define CGAL_CHECK_GMP_EXPR_MPQ_CLASS \
CGAL_static_assertion( \ CGAL_static_assertion( \
(::boost::is_same< ::__gmp_expr< T , T >,Type>::value )); (::boost::is_same< ::__gmp_expr< T , T >,Type>::value ));
@ -60,7 +63,7 @@ class Algebraic_structure_traits< mpq_class >
struct Is_zero: public CGAL::cpp98::unary_function< mpq_class , bool > { struct Is_zero: public CGAL::cpp98::unary_function< mpq_class , bool > {
template <class T, class U> template <class T, class U>
bool operator()( const ::__gmp_expr< T , U >& x) const { bool operator()( const ::__gmp_expr< T , U >& x) const {
CGAL_CHECK_GMP_EXPR; CGAL_CHECK_GMP_EXPR_MPQ_CLASS;
return ::sgn(x) == 0; return ::sgn(x) == 0;
} }
}; };
@ -68,7 +71,7 @@ class Algebraic_structure_traits< mpq_class >
struct Is_one: public CGAL::cpp98::unary_function< mpq_class , bool > { struct Is_one: public CGAL::cpp98::unary_function< mpq_class , bool > {
template <typename T, typename U> template <typename T, typename U>
bool operator()( const ::__gmp_expr< T , U >& x) const { bool operator()( const ::__gmp_expr< T , U >& x) const {
CGAL_CHECK_GMP_EXPR; CGAL_CHECK_GMP_EXPR_MPQ_CLASS;
return x == 1; return x == 1;
} }
}; };
@ -98,7 +101,7 @@ class Algebraic_structure_traits< mpq_class >
mpq_class operator()( mpq_class operator()(
const ::__gmp_expr< T , U1 >& x, const ::__gmp_expr< T , U1 >& x,
const ::__gmp_expr< T , U2 > & y) const { const ::__gmp_expr< T , U2 > & y) const {
CGAL_CHECK_GMP_EXPR; CGAL_CHECK_GMP_EXPR_MPQ_CLASS;
mpq_class result = x / y; mpq_class result = x / y;
CGAL_precondition_msg( result * y == x, CGAL_precondition_msg( result * y == x,
"'x' must be divisible by 'y' in " "'x' must be divisible by 'y' in "
@ -134,14 +137,14 @@ class Real_embeddable_traits< mpq_class >
struct Is_zero: public CGAL::cpp98::unary_function< mpq_class , bool > { struct Is_zero: public CGAL::cpp98::unary_function< mpq_class , bool > {
template <typename T, typename U> template <typename T, typename U>
bool operator()( const ::__gmp_expr< T , U >& x) const { bool operator()( const ::__gmp_expr< T , U >& x) const {
CGAL_CHECK_GMP_EXPR; CGAL_CHECK_GMP_EXPR_MPQ_CLASS;
return ::sgn(x) == 0; return ::sgn(x) == 0;
} }
}; };
struct Is_finite: public CGAL::cpp98::unary_function<mpq_class,bool> { struct Is_finite: public CGAL::cpp98::unary_function<mpq_class,bool> {
template <typename T, typename U> template <typename T, typename U>
bool operator()( const ::__gmp_expr< T , U >&) const { bool operator()( const ::__gmp_expr< T , U >&) const {
CGAL_CHECK_GMP_EXPR; CGAL_CHECK_GMP_EXPR_MPQ_CLASS;
return true; return true;
} }
}; };
@ -149,7 +152,7 @@ class Real_embeddable_traits< mpq_class >
struct Is_positive: public CGAL::cpp98::unary_function< mpq_class , bool > { struct Is_positive: public CGAL::cpp98::unary_function< mpq_class , bool > {
template <typename T, typename U> template <typename T, typename U>
bool operator()( const ::__gmp_expr< T , U >& x) const { bool operator()( const ::__gmp_expr< T , U >& x) const {
CGAL_CHECK_GMP_EXPR; CGAL_CHECK_GMP_EXPR_MPQ_CLASS;
return ::sgn(x) > 0; return ::sgn(x) > 0;
} }
}; };
@ -157,7 +160,7 @@ class Real_embeddable_traits< mpq_class >
struct Is_negative: public CGAL::cpp98::unary_function< mpq_class , bool > { struct Is_negative: public CGAL::cpp98::unary_function< mpq_class , bool > {
template <typename T, typename U> template <typename T, typename U>
bool operator()( const ::__gmp_expr< T , U >& x) const { bool operator()( const ::__gmp_expr< T , U >& x) const {
CGAL_CHECK_GMP_EXPR; CGAL_CHECK_GMP_EXPR_MPQ_CLASS;
return ::sgn(x) < 0; return ::sgn(x) < 0;
} }
}; };
@ -165,7 +168,7 @@ class Real_embeddable_traits< mpq_class >
struct Abs: public CGAL::cpp98::unary_function< mpq_class , mpq_class > { struct Abs: public CGAL::cpp98::unary_function< mpq_class , mpq_class > {
template <typename T, typename U> template <typename T, typename U>
mpq_class operator()( const ::__gmp_expr< T , U >& x) const { mpq_class operator()( const ::__gmp_expr< T , U >& x) const {
CGAL_CHECK_GMP_EXPR; CGAL_CHECK_GMP_EXPR_MPQ_CLASS;
return ::abs(x); return ::abs(x);
} }
}; };
@ -176,7 +179,7 @@ class Real_embeddable_traits< mpq_class >
template <typename T, typename U> template <typename T, typename U>
::CGAL::Sign ::CGAL::Sign
operator()( const ::__gmp_expr< T , U >& x ) const { operator()( const ::__gmp_expr< T , U >& x ) const {
CGAL_CHECK_GMP_EXPR; CGAL_CHECK_GMP_EXPR_MPQ_CLASS;
return (::CGAL::Sign) ::sgn( x ); return (::CGAL::Sign) ::sgn( x );
} }
}; };
@ -188,7 +191,7 @@ class Real_embeddable_traits< mpq_class >
Comparison_result operator()( Comparison_result operator()(
const ::__gmp_expr< T , U1 >& x, const ::__gmp_expr< T , U1 >& x,
const ::__gmp_expr< T , U2 >& y ) const { const ::__gmp_expr< T , U2 >& y ) const {
CGAL_CHECK_GMP_EXPR; CGAL_CHECK_GMP_EXPR_MPQ_CLASS;
// cmp returns any int value, not just -1/0/1... // cmp returns any int value, not just -1/0/1...
return (Comparison_result) CGAL_NTS sign( ::cmp(x, y) ); return (Comparison_result) CGAL_NTS sign( ::cmp(x, y) );
} }
@ -241,6 +244,13 @@ class Real_embeddable_traits< mpq_class >
}; };
}; };
} // namespace CGAL
#include <CGAL/mpz_class.h> // for GCD in Type traits
#include <CGAL/Fraction_traits.h>
namespace CGAL {
/*! \ingroup NiX_Fraction_traits_spec /*! \ingroup NiX_Fraction_traits_spec
* \brief Specialization of Fraction_traits for mpq_class * \brief Specialization of Fraction_traits for mpq_class
*/ */
@ -310,6 +320,6 @@ namespace internal {
} //namespace CGAL } //namespace CGAL
#undef CGAL_CHECK_GMP_EXPR #undef CGAL_CHECK_GMP_EXPR_MPQ_CLASS
#endif // CGAL_MPQ_CLASS_H #endif // CGAL_MPQ_CLASS_H

View File

@ -26,12 +26,6 @@
#ifndef CGAL_MPZ_CLASS_H #ifndef CGAL_MPZ_CLASS_H
#define CGAL_MPZ_CLASS_H #define CGAL_MPZ_CLASS_H
#include <CGAL/number_type_basic.h>
#include <CGAL/gmpxx_coercion_traits.h>
#include <CGAL/Modular_traits.h>
#include <CGAL/Residue.h>
// This file gathers the necessary adaptors so that the following // This file gathers the necessary adaptors so that the following
// C++ number types that come with GMP can be used by CGAL : // C++ number types that come with GMP can be used by CGAL :
// - mpz_class // - mpz_class
@ -41,6 +35,15 @@
// Reading gmpxx.h shows that ::__gmp_expr<T, T> is the mp[zqf]_class proper, // Reading gmpxx.h shows that ::__gmp_expr<T, T> is the mp[zqf]_class proper,
// while ::__gmp_expr<T, U> is the others "expressions". // while ::__gmp_expr<T, U> is the others "expressions".
#include <CGAL/number_type_config.h>
#include <CGAL/functional.h>
#include <CGAL/Algebraic_structure_traits.h>
#include <CGAL/Real_embeddable_traits.h>
#include <CGAL/number_utils.h>
#include <CGAL/double.h>
#include <boost/type_traits/is_same.hpp>
#include <mpfr.h>
#include <gmpxx.h>
#define CGAL_CHECK_GMP_EXPR \ #define CGAL_CHECK_GMP_EXPR \
CGAL_static_assertion( \ CGAL_static_assertion( \
@ -53,6 +56,7 @@ namespace CGAL {
template<> template<>
class Algebraic_structure_traits< mpz_class > class Algebraic_structure_traits< mpz_class >
:public Algebraic_structure_traits_base< mpz_class , Euclidean_ring_tag > { :public Algebraic_structure_traits_base< mpz_class , Euclidean_ring_tag > {
public: public:
typedef mpz_class Type; typedef mpz_class Type;
typedef Euclidean_ring_tag Algebraic_category; typedef Euclidean_ring_tag Algebraic_category;
@ -192,6 +196,13 @@ public:
};*/ };*/
}; };
} //namespace CGAL
#include <CGAL/gmpxx_coercion_traits.h>
#include <CGAL/int.h> // for `sign( ::cmp(x, y) )`, below
namespace CGAL {
// RET for mpz_class // RET for mpz_class
template<> template<>
class Real_embeddable_traits< mpz_class > class Real_embeddable_traits< mpz_class >
@ -301,14 +312,18 @@ public:
}; };
}; };
} //namespace CGAL
#include <CGAL/Residue.h>
#include <CGAL/Modular_traits.h>
namespace CGAL {
/*! \ingroup NiX_Modular_traits_spec /*! \ingroup NiX_Modular_traits_spec
* \brief a model of concept ModularTraits, * \brief a model of concept ModularTraits,
* specialization of NiX::Modular_traits. * specialization of NiX::Modular_traits.
*/ */
template <typename T>
class Modular_traits;
template<> template<>
class Modular_traits< mpz_class > { class Modular_traits< mpz_class > {
public: public:
@ -328,8 +343,11 @@ public:
} }
}; };
}; };
} //namespace CGAL
#include <CGAL/Quotient.h>
namespace CGAL {
template <> template <>
struct Split_double<mpz_class> struct Split_double<mpz_class>
{ {

View File

@ -2,8 +2,11 @@
#include <iostream> #include <iostream>
#include <utility> #include <utility>
#include <CGAL/functional.h> #include <CGAL/functional.h>
#include <CGAL/Algebraic_structure_traits.h>
#include <CGAL/Real_embeddable_traits.h>
#include <CGAL/number_utils.h> #include <CGAL/number_utils.h>
#include <CGAL/enum.h> #include <CGAL/enum.h>
#include <boost/utility/enable_if.hpp>
namespace CGAL { namespace CGAL {
template <class NT1, class NT2> template <class NT1, class NT2>