diff --git a/.gitattributes b/.gitattributes index 80af9a91b50..31b63184ad6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1815,6 +1815,8 @@ Ridges_3/test/Ridges_3/data/ellipsoid.off -text svneol=unset#application/octet-s Robustness/demo/Robustness/help/index.html svneol=native#text/html Robustness/demo/Robustness/robustness.vcproj eol=crlf STL_Extension/include/CGAL/Iterator_transform.h -text +STL_Extension/include/CGAL/type_traits.h -text +STL_Extension/test/STL_Extension/test_type_traits.cpp -text Scripts/developer_scripts/create_assertions.sh eol=lf Scripts/developer_scripts/create_macosx_installer -text SearchStructures/doc_tex/SearchStructures/d-range.eps -text svneol=unset#application/postscript diff --git a/Algebraic_foundations/include/CGAL/Algebraic_structure_traits.h b/Algebraic_foundations/include/CGAL/Algebraic_structure_traits.h index 9fca225e267..ee566ed7662 100644 --- a/Algebraic_foundations/include/CGAL/Algebraic_structure_traits.h +++ b/Algebraic_foundations/include/CGAL/Algebraic_structure_traits.h @@ -13,6 +13,7 @@ #define CGAL_ALGEBRAIC_STRUCTURE_TRAITS_H #include +#include CGAL_BEGIN_NAMESPACE @@ -524,14 +525,6 @@ namespace INTERN_AST { namespace CGALi{ -#define CGAL_IS_SAME_OR_BASE_OF(BASE,T) \ - ( \ - ::boost::is_base_and_derived< BASE , T >::value || \ - ::boost::is_same< BASE , T >::value \ - ) \ - - - template class Is_integral_domain_without_division { @@ -539,7 +532,7 @@ class Is_integral_domain_without_division { typedef typename AST::Algebraic_category Tag; public : static const bool value - = CGAL_IS_SAME_OR_BASE_OF(Integral_domain_without_division_tag,Tag); + = ::CGAL::is_same_or_derived::value; }; template @@ -548,7 +541,7 @@ class Is_integral_domain { typedef typename AST::Algebraic_category Tag; public : static const bool value - = CGAL_IS_SAME_OR_BASE_OF(Integral_domain_tag,Tag); + = ::CGAL::is_same_or_derived::value; }; @@ -558,7 +551,7 @@ class Is_unique_factorization_domain { typedef typename AST::Algebraic_category Tag; public : static const bool value - = CGAL_IS_SAME_OR_BASE_OF(Unique_factorization_domain_tag,Tag); + = ::CGAL::is_same_or_derived::value; }; template @@ -567,7 +560,7 @@ class Is_euclidean_ring { typedef typename AST::Algebraic_category Tag; public : static const bool value - = CGAL_IS_SAME_OR_BASE_OF(Euclidean_ring_tag,Tag); + = ::CGAL::is_same_or_derived::value; }; @@ -577,7 +570,7 @@ class Is_field { typedef typename AST::Algebraic_category Tag; public : static const bool value - = CGAL_IS_SAME_OR_BASE_OF(Field_tag,Tag); + = ::CGAL::is_same_or_derived::value; }; @@ -587,7 +580,7 @@ class Is_field_with_sqrt { typedef typename AST::Algebraic_category Tag; public : static const bool value - = CGAL_IS_SAME_OR_BASE_OF(Field_with_sqrt_tag,Tag); + = ::CGAL::is_same_or_derived::value; }; template @@ -596,9 +589,23 @@ class Is_field_with_root_of { typedef typename AST::Algebraic_category Tag; public : static const bool value - = CGAL_IS_SAME_OR_BASE_OF(Field_with_root_of_tag,Tag); + = ::CGAL::is_same_or_derived::value; }; +// FIXME: @Michael: what about this? feel free to remove it if it +// does not make sense + +/* +template< class AS, class CategoryTag > +class Algebraic_structure_has_category { + typedef Algebraic_structure_traits AST; + typedef typename AST::Algebraic_category Tag; +public : + static const bool value + = ::CGAL::is_same_or_derived::value; +}; +*/ + } // namespace CGALi diff --git a/Algebraic_foundations/include/CGAL/Coercion_traits.h b/Algebraic_foundations/include/CGAL/Coercion_traits.h index 2d226a1d2db..e65ccca937e 100644 --- a/Algebraic_foundations/include/CGAL/Coercion_traits.h +++ b/Algebraic_foundations/include/CGAL/Coercion_traits.h @@ -29,8 +29,7 @@ #include #include -#include -#include +#include // Makro to define an additional operator for binary functors which takes // two number types as parameters that are interoperable with the diff --git a/Number_types/include/CGAL/Sqrt_extension.h b/Number_types/include/CGAL/Sqrt_extension.h index 460385f3dda..e3bcb4910ff 100644 --- a/Number_types/include/CGAL/Sqrt_extension.h +++ b/Number_types/include/CGAL/Sqrt_extension.h @@ -29,14 +29,15 @@ #define CGAL_SQRT_EXTENSION_H #include +#include -#include // fro std::accumulate +#include // for std::accumulate +#include #include // Needed by To_interval +// FIXME: isnt boost::transform called below? //#include -//#include - -//#include +#include // We have to define the macros befor including Polynomials, // since they cause a doxygen error otherwise.. (version 1.2.4) @@ -1500,14 +1501,9 @@ template class CT_ext_not_to_fwsqrt; // template struct Coercion_traits_for_level, B , CTL_SQRT_EXT> -:public ::boost::mpl::if_c< +:public ::boost::mpl::if_< // if B is fwsqrt - ::boost::is_base_and_derived< - Field_with_sqrt_tag, -typename Algebraic_structure_traits::Algebraic_category >::value || - ::boost::is_same< - Field_with_sqrt_tag, -typename Algebraic_structure_traits::Algebraic_category >::value + ::CGAL::is_same_or_derived< Field_with_sqrt_tag, typename Algebraic_structure_traits::Algebraic_category > , //then take Intern::Coercion_traits for fwsqrt INTERN_CT::CT_ext_to_fwsqrt, B> diff --git a/STL_Extension/include/CGAL/Handle_with_policy.h b/STL_Extension/include/CGAL/Handle_with_policy.h index 8a945c3011f..cca176d5221 100644 --- a/STL_Extension/include/CGAL/Handle_with_policy.h +++ b/STL_Extension/include/CGAL/Handle_with_policy.h @@ -41,8 +41,8 @@ #include #include +#include -#include #include #include @@ -54,10 +54,6 @@ //#define LiS_HANDLE_OLD_ALLOCATION -// LiS2CGAL: there are several: -// Handle Handle_for Handle_for_virtual Ref_counted -// boost has shared_ptr -// LiS2CGAL: add it as Handle_with_policy? // LiS2CGAL: check whether CGAL::Handle is a subset and replacing it // LiS2CGAL: Start: Copy and use it // LiS2CGAL: Handle Package? @@ -405,8 +401,7 @@ namespace Intern { typedef ::CGAL::Reference_counted_hierarchy_with_union Reference_counted_hierarchy_with_union; BOOST_STATIC_ASSERT(( - ::boost::is_base_and_derived< Reference_counted_hierarchy_with_union, T >::value || - ::boost::is_same < Reference_counted_hierarchy_with_union, T >::value )); + ::CGAL::is_same_or_derived< Reference_counted_hierarchy_with_union, T >::value )); } typedef T Rep; }; @@ -774,8 +769,7 @@ public: typedef Allocator_ Allocator; enum { is_class_hierarchy = - ::boost::is_base_and_derived< Reference_counted_hierarchy_base, T>::value || - ::boost::is_same < Reference_counted_hierarchy_base, T>::value }; + ::CGAL::is_same_or_derived< Reference_counted_hierarchy_base, T>::value }; typedef typename Handle_policy::template Rep_bind< T, is_class_hierarchy > Bind; // instantiate Rep_bind to activate compile time check in there static Bind bind; @@ -812,8 +806,7 @@ private: #ifdef LiS_HANDLE_OLD_ALLOCATION static Rep* new_rep( const Rep& rep) { BOOST_STATIC_ASSERT( !( - ::boost::is_base_and_derived< Reference_counted_hierarchy_base, T >::value || - ::boost::is_same < Reference_counted_hierarchy_base, T >::value )); + ::CGAL::is_same_or_derived< Reference_counted_hierarchy_base, T >::value )); return new Rep(rep); } @@ -823,8 +816,7 @@ private: static Rep* new_rep( const Rep& rep) { BOOST_STATIC_ASSERT( !( - ::boost::is_base_and_derived< Reference_counted_hierarchy_base, T >::value || - ::boost::is_same < Reference_counted_hierarchy_base, T >::value )); + ::CGAL::is_same_or_derived< Reference_counted_hierarchy_base, T >::value )); Rep* p = allocator.allocate(1); allocator.construct(p, rep); return p; @@ -919,8 +911,7 @@ protected: //! constructor will work for class hierarchies of representations. Handle_with_policy( Rep* p) : ptr_( p) { BOOST_STATIC_ASSERT(( - ::boost::is_base_and_derived< Reference_counted_hierarchy_base, T >::value || - ::boost::is_same < Reference_counted_hierarchy_base, T >::value )); + ::CGAL::is_same_or_derived< Reference_counted_hierarchy_base, T >::value )); Bind bind; // trigger compile-time check (void)bind; } @@ -933,8 +924,7 @@ protected: //! the template version with one argument. void initialize_with( Rep* p) { BOOST_STATIC_ASSERT(( - ::boost::is_base_and_derived< Reference_counted_hierarchy_base, T >::value || - ::boost::is_same < Reference_counted_hierarchy_base, T >::value )); + ::CGAL::is_same_or_derived< Reference_counted_hierarchy_base, T >::value )); Bind bind; // trigger compile-time check (void)bind; CGAL_precondition_msg( ptr_ == 0, "Handle_with_policy::initialize_with(): the " diff --git a/STL_Extension/include/CGAL/type_traits.h b/STL_Extension/include/CGAL/type_traits.h new file mode 100644 index 00000000000..c3fc25f6b23 --- /dev/null +++ b/STL_Extension/include/CGAL/type_traits.h @@ -0,0 +1,21 @@ +#ifndef CGAL_TYPE_TRAITS_H +#define CGAL_TYPE_TRAITS_H + +#include +#include +#include + +namespace CGAL { + +template< class Base, class Derived > +struct is_same_or_derived : + public ::boost::mpl::or_< + ::boost::is_same< Base, Derived >, + ::boost::is_base_and_derived< Base, Derived > + >::type +{}; + +}; + +#endif + diff --git a/STL_Extension/test/STL_Extension/test_type_traits.cpp b/STL_Extension/test/STL_Extension/test_type_traits.cpp new file mode 100644 index 00000000000..546bbc69c05 --- /dev/null +++ b/STL_Extension/test/STL_Extension/test_type_traits.cpp @@ -0,0 +1,19 @@ +#include +#include + +struct A {}; +struct B : public A {}; +typedef A C; + +int main() { + CGAL_test_assert( ( ::CGAL::is_same_or_derived< A,A >::value == 1 ) ); + CGAL_test_assert( ( ::CGAL::is_same_or_derived< A,B >::value == 1 ) ); + CGAL_test_assert( ( ::CGAL::is_same_or_derived< B,A >::value == 0 ) ); + CGAL_test_assert( ( ::CGAL::is_same_or_derived< B,B >::value == 1 ) ); + CGAL_test_assert( ( ::CGAL::is_same_or_derived< A,C >::value == 1 ) ); + CGAL_test_assert( ( ::CGAL::is_same_or_derived< B,C >::value == 0 ) ); + CGAL_test_assert( ( ::CGAL::is_same_or_derived< C,C >::value == 1 ) ); + CGAL_test_assert( ( ::CGAL::is_same_or_derived< C,A >::value == 1 ) ); + CGAL_test_assert( ( ::CGAL::is_same_or_derived< C,B >::value == 1 ) ); + return 0; +}