From 2f8eeb0db30f9bedf542c8db672a450d649e7e94 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 9 May 2019 15:05:23 +0200 Subject: [PATCH] Fix the headers dependency-hell around gmpxx in Number_types --- .../CGAL/Arr_circular_line_arc_traits_2.h | 2 + ...ternal_functions_on_circular_arc_point_3.h | 2 +- .../Feature/Vertical_dispersion.h | 1 + Generator/include/CGAL/point_generators_d.h | 1 + .../CGAL/Modular_arithmetic/Residue_type.h | 6 ++- .../include/CGAL/Modular_traits.h | 6 +-- Modular_arithmetic/include/CGAL/Residue.h | 1 - Number_types/include/CGAL/Lazy_exact_nt.h | 8 ++-- Number_types/include/CGAL/Quotient.h | 2 - Number_types/include/CGAL/gmpxx.h | 2 - .../include/CGAL/gmpxx_coercion_traits.h | 2 +- Number_types/include/CGAL/mpq_class.h | 38 ++++++++++++------- Number_types/include/CGAL/mpz_class.h | 36 +++++++++++++----- Number_types/test/Number_types/checked_NT.h | 3 ++ 14 files changed, 69 insertions(+), 41 deletions(-) diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_circular_line_arc_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_circular_line_arc_traits_2.h index 463588b9b1f..9d6967e4b46 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_circular_line_arc_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_circular_line_arc_traits_2.h @@ -43,6 +43,8 @@ #include #include +#include + namespace CGAL { namespace VariantFunctors{ diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_circular_arc_point_3.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_circular_arc_point_3.h index 3d5008954a0..ef5c1c0cc5e 100644 --- a/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_circular_arc_point_3.h +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_circular_arc_point_3.h @@ -27,7 +27,7 @@ #define CGAL_SPHERICAL_KERNEL_PREDICATES_ON_CIRCULAR_ARC_POINT_3_H #include - +#include namespace CGAL { namespace SphericalFunctors { diff --git a/Classification/include/CGAL/Classification/Feature/Vertical_dispersion.h b/Classification/include/CGAL/Classification/Feature/Vertical_dispersion.h index 2c23f4046f1..13713b414dc 100644 --- a/Classification/include/CGAL/Classification/Feature/Vertical_dispersion.h +++ b/Classification/include/CGAL/Classification/Feature/Vertical_dispersion.h @@ -32,6 +32,7 @@ #include #include #include +#include #include namespace CGAL { diff --git a/Generator/include/CGAL/point_generators_d.h b/Generator/include/CGAL/point_generators_d.h index c7f40cbf5a7..2016eacc4dd 100644 --- a/Generator/include/CGAL/point_generators_d.h +++ b/Generator/include/CGAL/point_generators_d.h @@ -28,6 +28,7 @@ #include #include #include +#include namespace CGAL { diff --git a/Modular_arithmetic/include/CGAL/Modular_arithmetic/Residue_type.h b/Modular_arithmetic/include/CGAL/Modular_arithmetic/Residue_type.h index d2ddb6a8dcc..ebf593071a9 100644 --- a/Modular_arithmetic/include/CGAL/Modular_arithmetic/Residue_type.h +++ b/Modular_arithmetic/include/CGAL/Modular_arithmetic/Residue_type.h @@ -22,10 +22,14 @@ #ifndef CGAL_RESIDUE_TYPE_H #define CGAL_RESIDUE_TYPE_H -#include #include +#include +#include +#include +#include #include +#include #include diff --git a/Modular_arithmetic/include/CGAL/Modular_traits.h b/Modular_arithmetic/include/CGAL/Modular_traits.h index 6eca13370e1..a663e6daaa9 100644 --- a/Modular_arithmetic/include/CGAL/Modular_traits.h +++ b/Modular_arithmetic/include/CGAL/Modular_traits.h @@ -21,11 +21,7 @@ #ifndef CGAL_MODULAR_TRAITS_H #define CGAL_MODULAR_TRAITS_H 1 -#include -#include -#include -#include - +#include namespace CGAL { diff --git a/Modular_arithmetic/include/CGAL/Residue.h b/Modular_arithmetic/include/CGAL/Residue.h index 549b6c14886..2df43fcce9a 100644 --- a/Modular_arithmetic/include/CGAL/Residue.h +++ b/Modular_arithmetic/include/CGAL/Residue.h @@ -28,7 +28,6 @@ #ifndef CGAL_RESIDUE_H #define CGAL_RESIDUE_H 1 -#include #include #include diff --git a/Number_types/include/CGAL/Lazy_exact_nt.h b/Number_types/include/CGAL/Lazy_exact_nt.h index d1ffc105ccf..65ca10df62d 100644 --- a/Number_types/include/CGAL/Lazy_exact_nt.h +++ b/Number_types/include/CGAL/Lazy_exact_nt.h @@ -22,11 +22,6 @@ #ifndef CGAL_LAZY_EXACT_NT_H #define CGAL_LAZY_EXACT_NT_H -#define CGAL_int(T) typename First_if_different::Type -#define CGAL_double(T) typename First_if_different::Type -#define CGAL_To_interval(T) To_interval - - #include #include @@ -53,6 +48,9 @@ #include +#define CGAL_int(T) typename First_if_different::Type +#define CGAL_double(T) typename First_if_different::Type +#define CGAL_To_interval(T) To_interval /* * This file contains the definition of the number type Lazy_exact_nt, diff --git a/Number_types/include/CGAL/Quotient.h b/Number_types/include/CGAL/Quotient.h index 800620d7c0e..d3a137aafa4 100644 --- a/Number_types/include/CGAL/Quotient.h +++ b/Number_types/include/CGAL/Quotient.h @@ -32,8 +32,6 @@ // The include is done before the protect macro on purpose, because // of a cyclic dependency. -#include - #ifndef CGAL_QUOTIENT_H #define CGAL_QUOTIENT_H diff --git a/Number_types/include/CGAL/gmpxx.h b/Number_types/include/CGAL/gmpxx.h index 8dda7655099..09cde667238 100644 --- a/Number_types/include/CGAL/gmpxx.h +++ b/Number_types/include/CGAL/gmpxx.h @@ -39,8 +39,6 @@ #ifndef CGAL_GMPXX_H #define CGAL_GMPXX_H -#include - #include // needed by GMP 4.1.4 since misses it. #include #include diff --git a/Number_types/include/CGAL/gmpxx_coercion_traits.h b/Number_types/include/CGAL/gmpxx_coercion_traits.h index 82790ff8d93..151615bafb4 100644 --- a/Number_types/include/CGAL/gmpxx_coercion_traits.h +++ b/Number_types/include/CGAL/gmpxx_coercion_traits.h @@ -28,7 +28,7 @@ #ifndef CGAL_GMPXX_COERCION_TRAITS_H #define CGAL_GMPXX_COERCION_TRAITS_H 1 -#include +#include #include #include // needed by GMP 4.1.4 since misses it. diff --git a/Number_types/include/CGAL/mpq_class.h b/Number_types/include/CGAL/mpq_class.h index ec3dbc9cdfd..6d2426129c3 100644 --- a/Number_types/include/CGAL/mpq_class.h +++ b/Number_types/include/CGAL/mpq_class.h @@ -26,10 +26,13 @@ #ifndef CGAL_MPQ_CLASS_H #define CGAL_MPQ_CLASS_H -#include +#include +#include +#include +#include #include -#include // for GCD in Type traits #include +#include // This file gathers the necessary adaptors so that the following // C++ number types that come with GMP can be used by CGAL : @@ -40,7 +43,7 @@ // Reading gmpxx.h shows that ::__gmp_expr is the mp[zqf]_class proper, // while ::__gmp_expr is the others "expressions". -#define CGAL_CHECK_GMP_EXPR \ +#define CGAL_CHECK_GMP_EXPR_MPQ_CLASS \ CGAL_static_assertion( \ (::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 > { template bool operator()( const ::__gmp_expr< T , U >& x) const { - CGAL_CHECK_GMP_EXPR; + CGAL_CHECK_GMP_EXPR_MPQ_CLASS; 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 > { template bool operator()( const ::__gmp_expr< T , U >& x) const { - CGAL_CHECK_GMP_EXPR; + CGAL_CHECK_GMP_EXPR_MPQ_CLASS; return x == 1; } }; @@ -98,7 +101,7 @@ class Algebraic_structure_traits< mpq_class > mpq_class operator()( const ::__gmp_expr< T , U1 >& x, const ::__gmp_expr< T , U2 > & y) const { - CGAL_CHECK_GMP_EXPR; + CGAL_CHECK_GMP_EXPR_MPQ_CLASS; mpq_class result = x / y; CGAL_precondition_msg( result * y == x, "'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 > { template bool operator()( const ::__gmp_expr< T , U >& x) const { - CGAL_CHECK_GMP_EXPR; + CGAL_CHECK_GMP_EXPR_MPQ_CLASS; return ::sgn(x) == 0; } }; struct Is_finite: public CGAL::cpp98::unary_function { template bool operator()( const ::__gmp_expr< T , U >&) const { - CGAL_CHECK_GMP_EXPR; + CGAL_CHECK_GMP_EXPR_MPQ_CLASS; return true; } }; @@ -149,7 +152,7 @@ class Real_embeddable_traits< mpq_class > struct Is_positive: public CGAL::cpp98::unary_function< mpq_class , bool > { template bool operator()( const ::__gmp_expr< T , U >& x) const { - CGAL_CHECK_GMP_EXPR; + CGAL_CHECK_GMP_EXPR_MPQ_CLASS; 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 > { template bool operator()( const ::__gmp_expr< T , U >& x) const { - CGAL_CHECK_GMP_EXPR; + CGAL_CHECK_GMP_EXPR_MPQ_CLASS; 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 > { template mpq_class operator()( const ::__gmp_expr< T , U >& x) const { - CGAL_CHECK_GMP_EXPR; + CGAL_CHECK_GMP_EXPR_MPQ_CLASS; return ::abs(x); } }; @@ -176,7 +179,7 @@ class Real_embeddable_traits< mpq_class > template ::CGAL::Sign operator()( const ::__gmp_expr< T , U >& x ) const { - CGAL_CHECK_GMP_EXPR; + CGAL_CHECK_GMP_EXPR_MPQ_CLASS; return (::CGAL::Sign) ::sgn( x ); } }; @@ -188,7 +191,7 @@ class Real_embeddable_traits< mpq_class > Comparison_result operator()( const ::__gmp_expr< T , U1 >& x, 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... return (Comparison_result) CGAL_NTS sign( ::cmp(x, y) ); } @@ -241,6 +244,13 @@ class Real_embeddable_traits< mpq_class > }; }; +} // namespace CGAL + +#include // for GCD in Type traits +#include + +namespace CGAL { + /*! \ingroup NiX_Fraction_traits_spec * \brief Specialization of Fraction_traits for mpq_class */ @@ -310,6 +320,6 @@ namespace internal { } //namespace CGAL -#undef CGAL_CHECK_GMP_EXPR +#undef CGAL_CHECK_GMP_EXPR_MPQ_CLASS #endif // CGAL_MPQ_CLASS_H diff --git a/Number_types/include/CGAL/mpz_class.h b/Number_types/include/CGAL/mpz_class.h index bad8b60e6b9..d83aae9a274 100644 --- a/Number_types/include/CGAL/mpz_class.h +++ b/Number_types/include/CGAL/mpz_class.h @@ -26,12 +26,6 @@ #ifndef CGAL_MPZ_CLASS_H #define CGAL_MPZ_CLASS_H -#include -#include -#include -#include - - // This file gathers the necessary adaptors so that the following // C++ number types that come with GMP can be used by CGAL : // - mpz_class @@ -41,6 +35,15 @@ // Reading gmpxx.h shows that ::__gmp_expr is the mp[zqf]_class proper, // while ::__gmp_expr is the others "expressions". +#include +#include +#include +#include +#include +#include +#include +#include +#include #define CGAL_CHECK_GMP_EXPR \ CGAL_static_assertion( \ @@ -53,6 +56,7 @@ namespace CGAL { template<> class Algebraic_structure_traits< mpz_class > :public Algebraic_structure_traits_base< mpz_class , Euclidean_ring_tag > { + public: typedef mpz_class Type; typedef Euclidean_ring_tag Algebraic_category; @@ -192,6 +196,13 @@ public: };*/ }; +} //namespace CGAL + +#include +#include // for `sign( ::cmp(x, y) )`, below + +namespace CGAL { + // RET for mpz_class template<> class Real_embeddable_traits< mpz_class > @@ -301,14 +312,18 @@ public: }; }; +} //namespace CGAL + +#include +#include + +namespace CGAL { + /*! \ingroup NiX_Modular_traits_spec * \brief a model of concept ModularTraits, * specialization of NiX::Modular_traits. */ -template -class Modular_traits; - template<> class Modular_traits< mpz_class > { public: @@ -328,8 +343,11 @@ public: } }; }; +} //namespace CGAL +#include +namespace CGAL { template <> struct Split_double { diff --git a/Number_types/test/Number_types/checked_NT.h b/Number_types/test/Number_types/checked_NT.h index 6c66b24cce0..26b4a913e08 100644 --- a/Number_types/test/Number_types/checked_NT.h +++ b/Number_types/test/Number_types/checked_NT.h @@ -2,8 +2,11 @@ #include #include #include +#include +#include #include #include +#include namespace CGAL { template