mirror of https://github.com/CGAL/cgal
added a mpl struct is_same_or_equal, similar to
boost::is_same / boost::is_base_and_derived
This commit is contained in:
parent
e758f82547
commit
1996f8c159
|
|
@ -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/help/index.html svneol=native#text/html
|
||||||
Robustness/demo/Robustness/robustness.vcproj eol=crlf
|
Robustness/demo/Robustness/robustness.vcproj eol=crlf
|
||||||
STL_Extension/include/CGAL/Iterator_transform.h -text
|
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_assertions.sh eol=lf
|
||||||
Scripts/developer_scripts/create_macosx_installer -text
|
Scripts/developer_scripts/create_macosx_installer -text
|
||||||
SearchStructures/doc_tex/SearchStructures/d-range.eps -text svneol=unset#application/postscript
|
SearchStructures/doc_tex/SearchStructures/d-range.eps -text svneol=unset#application/postscript
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
#define CGAL_ALGEBRAIC_STRUCTURE_TRAITS_H
|
#define CGAL_ALGEBRAIC_STRUCTURE_TRAITS_H
|
||||||
|
|
||||||
#include <CGAL/number_type_basic.h>
|
#include <CGAL/number_type_basic.h>
|
||||||
|
#include <CGAL/type_traits.h>
|
||||||
|
|
||||||
CGAL_BEGIN_NAMESPACE
|
CGAL_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
|
@ -524,14 +525,6 @@ namespace INTERN_AST {
|
||||||
|
|
||||||
namespace CGALi{
|
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 AS>
|
template<class AS>
|
||||||
class Is_integral_domain_without_division {
|
class Is_integral_domain_without_division {
|
||||||
|
|
@ -539,7 +532,7 @@ class Is_integral_domain_without_division {
|
||||||
typedef typename AST::Algebraic_category Tag;
|
typedef typename AST::Algebraic_category Tag;
|
||||||
public :
|
public :
|
||||||
static const bool value
|
static const bool value
|
||||||
= CGAL_IS_SAME_OR_BASE_OF(Integral_domain_without_division_tag,Tag);
|
= ::CGAL::is_same_or_derived<Integral_domain_without_division_tag,Tag>::value;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class AS>
|
template<class AS>
|
||||||
|
|
@ -548,7 +541,7 @@ class Is_integral_domain {
|
||||||
typedef typename AST::Algebraic_category Tag;
|
typedef typename AST::Algebraic_category Tag;
|
||||||
public :
|
public :
|
||||||
static const bool value
|
static const bool value
|
||||||
= CGAL_IS_SAME_OR_BASE_OF(Integral_domain_tag,Tag);
|
= ::CGAL::is_same_or_derived<Integral_domain_tag,Tag>::value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -558,7 +551,7 @@ class Is_unique_factorization_domain {
|
||||||
typedef typename AST::Algebraic_category Tag;
|
typedef typename AST::Algebraic_category Tag;
|
||||||
public :
|
public :
|
||||||
static const bool value
|
static const bool value
|
||||||
= CGAL_IS_SAME_OR_BASE_OF(Unique_factorization_domain_tag,Tag);
|
= ::CGAL::is_same_or_derived<Unique_factorization_domain_tag,Tag>::value;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class AS>
|
template<class AS>
|
||||||
|
|
@ -567,7 +560,7 @@ class Is_euclidean_ring {
|
||||||
typedef typename AST::Algebraic_category Tag;
|
typedef typename AST::Algebraic_category Tag;
|
||||||
public :
|
public :
|
||||||
static const bool value
|
static const bool value
|
||||||
= CGAL_IS_SAME_OR_BASE_OF(Euclidean_ring_tag,Tag);
|
= ::CGAL::is_same_or_derived<Euclidean_ring_tag,Tag>::value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -577,7 +570,7 @@ class Is_field {
|
||||||
typedef typename AST::Algebraic_category Tag;
|
typedef typename AST::Algebraic_category Tag;
|
||||||
public :
|
public :
|
||||||
static const bool value
|
static const bool value
|
||||||
= CGAL_IS_SAME_OR_BASE_OF(Field_tag,Tag);
|
= ::CGAL::is_same_or_derived<Field_tag,Tag>::value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -587,7 +580,7 @@ class Is_field_with_sqrt {
|
||||||
typedef typename AST::Algebraic_category Tag;
|
typedef typename AST::Algebraic_category Tag;
|
||||||
public :
|
public :
|
||||||
static const bool value
|
static const bool value
|
||||||
= CGAL_IS_SAME_OR_BASE_OF(Field_with_sqrt_tag,Tag);
|
= ::CGAL::is_same_or_derived<Field_with_sqrt_tag,Tag>::value;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class AS>
|
template<class AS>
|
||||||
|
|
@ -596,9 +589,23 @@ class Is_field_with_root_of {
|
||||||
typedef typename AST::Algebraic_category Tag;
|
typedef typename AST::Algebraic_category Tag;
|
||||||
public :
|
public :
|
||||||
static const bool value
|
static const bool value
|
||||||
= CGAL_IS_SAME_OR_BASE_OF(Field_with_root_of_tag,Tag);
|
= ::CGAL::is_same_or_derived<Field_with_root_of_tag,Tag>::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<AS> AST;
|
||||||
|
typedef typename AST::Algebraic_category Tag;
|
||||||
|
public :
|
||||||
|
static const bool value
|
||||||
|
= ::CGAL::is_same_or_derived<CategoryTag,Tag>::value;
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
} // namespace CGALi
|
} // namespace CGALi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,7 @@
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
#include <boost/iterator/transform_iterator.hpp>
|
#include <boost/iterator/transform_iterator.hpp>
|
||||||
#include <boost/type_traits/is_base_and_derived.hpp>
|
#include <boost/type_traits/is_same.hpp>
|
||||||
#include <boost/mpl/if.hpp>
|
|
||||||
|
|
||||||
// Makro to define an additional operator for binary functors which takes
|
// Makro to define an additional operator for binary functors which takes
|
||||||
// two number types as parameters that are interoperable with the
|
// two number types as parameters that are interoperable with the
|
||||||
|
|
|
||||||
|
|
@ -29,14 +29,15 @@
|
||||||
#define CGAL_SQRT_EXTENSION_H
|
#define CGAL_SQRT_EXTENSION_H
|
||||||
|
|
||||||
#include <CGAL/number_type_basic.h>
|
#include <CGAL/number_type_basic.h>
|
||||||
|
#include <CGAL/type_traits.h>
|
||||||
|
|
||||||
#include <numeric> // fro std::accumulate
|
#include <numeric> // for std::accumulate
|
||||||
|
#include <boost/type_traits/is_same.hpp>
|
||||||
#include <boost/numeric/interval.hpp> // Needed by To_interval
|
#include <boost/numeric/interval.hpp> // Needed by To_interval
|
||||||
|
|
||||||
|
// FIXME: isnt boost::transform called below?
|
||||||
//#include <boost/iterator/transform_iterator.hpp>
|
//#include <boost/iterator/transform_iterator.hpp>
|
||||||
//#include <boost/mpl/if.hpp>
|
#include <boost/mpl/if.hpp>
|
||||||
|
|
||||||
//#include <CGAL/CGAL/number_type_basic.h>
|
|
||||||
|
|
||||||
// We have to define the macros befor including Polynomials,
|
// We have to define the macros befor including Polynomials,
|
||||||
// since they cause a doxygen error otherwise.. (version 1.2.4)
|
// since they cause a doxygen error otherwise.. (version 1.2.4)
|
||||||
|
|
@ -1500,14 +1501,9 @@ template <class A, class B> class CT_ext_not_to_fwsqrt;
|
||||||
//<EXT,ANY>
|
//<EXT,ANY>
|
||||||
template <class Coeff, class Root, class B>
|
template <class Coeff, class Root, class B>
|
||||||
struct Coercion_traits_for_level<Sqrt_extension<Coeff, Root>, B , CTL_SQRT_EXT>
|
struct Coercion_traits_for_level<Sqrt_extension<Coeff, Root>, B , CTL_SQRT_EXT>
|
||||||
:public ::boost::mpl::if_c<
|
:public ::boost::mpl::if_<
|
||||||
// if B is fwsqrt
|
// if B is fwsqrt
|
||||||
::boost::is_base_and_derived<
|
::CGAL::is_same_or_derived< Field_with_sqrt_tag, typename Algebraic_structure_traits<B>::Algebraic_category >
|
||||||
Field_with_sqrt_tag,
|
|
||||||
typename Algebraic_structure_traits<B>::Algebraic_category >::value ||
|
|
||||||
::boost::is_same<
|
|
||||||
Field_with_sqrt_tag,
|
|
||||||
typename Algebraic_structure_traits<B>::Algebraic_category >::value
|
|
||||||
,
|
,
|
||||||
//then take Intern::Coercion_traits for fwsqrt
|
//then take Intern::Coercion_traits for fwsqrt
|
||||||
INTERN_CT::CT_ext_to_fwsqrt<Sqrt_extension<Coeff,Root>, B>
|
INTERN_CT::CT_ext_to_fwsqrt<Sqrt_extension<Coeff,Root>, B>
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,8 @@
|
||||||
|
|
||||||
#include <CGAL/basic.h>
|
#include <CGAL/basic.h>
|
||||||
#include <CGAL/memory.h>
|
#include <CGAL/memory.h>
|
||||||
|
#include <CGAL/type_traits.h>
|
||||||
|
|
||||||
#include <boost/type_traits.hpp>
|
|
||||||
#include <boost/static_assert.hpp>
|
#include <boost/static_assert.hpp>
|
||||||
#include <boost/mpl/if.hpp>
|
#include <boost/mpl/if.hpp>
|
||||||
|
|
||||||
|
|
@ -54,10 +54,6 @@
|
||||||
|
|
||||||
//#define LiS_HANDLE_OLD_ALLOCATION
|
//#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: check whether CGAL::Handle is a subset and replacing it
|
||||||
// LiS2CGAL: Start: Copy and use it
|
// LiS2CGAL: Start: Copy and use it
|
||||||
// LiS2CGAL: Handle Package?
|
// LiS2CGAL: Handle Package?
|
||||||
|
|
@ -405,8 +401,7 @@ namespace Intern {
|
||||||
typedef ::CGAL::Reference_counted_hierarchy_with_union<Alloc>
|
typedef ::CGAL::Reference_counted_hierarchy_with_union<Alloc>
|
||||||
Reference_counted_hierarchy_with_union;
|
Reference_counted_hierarchy_with_union;
|
||||||
BOOST_STATIC_ASSERT((
|
BOOST_STATIC_ASSERT((
|
||||||
::boost::is_base_and_derived< Reference_counted_hierarchy_with_union, T >::value ||
|
::CGAL::is_same_or_derived< Reference_counted_hierarchy_with_union, T >::value ));
|
||||||
::boost::is_same < Reference_counted_hierarchy_with_union, T >::value ));
|
|
||||||
}
|
}
|
||||||
typedef T Rep;
|
typedef T Rep;
|
||||||
};
|
};
|
||||||
|
|
@ -774,8 +769,7 @@ public:
|
||||||
typedef Allocator_ Allocator;
|
typedef Allocator_ Allocator;
|
||||||
|
|
||||||
enum { is_class_hierarchy =
|
enum { is_class_hierarchy =
|
||||||
::boost::is_base_and_derived< Reference_counted_hierarchy_base, T>::value ||
|
::CGAL::is_same_or_derived< Reference_counted_hierarchy_base, T>::value };
|
||||||
::boost::is_same < Reference_counted_hierarchy_base, T>::value };
|
|
||||||
typedef typename Handle_policy::template Rep_bind< T, is_class_hierarchy > Bind;
|
typedef typename Handle_policy::template Rep_bind< T, is_class_hierarchy > Bind;
|
||||||
// instantiate Rep_bind to activate compile time check in there
|
// instantiate Rep_bind to activate compile time check in there
|
||||||
static Bind bind;
|
static Bind bind;
|
||||||
|
|
@ -812,8 +806,7 @@ private:
|
||||||
#ifdef LiS_HANDLE_OLD_ALLOCATION
|
#ifdef LiS_HANDLE_OLD_ALLOCATION
|
||||||
static Rep* new_rep( const Rep& rep) {
|
static Rep* new_rep( const Rep& rep) {
|
||||||
BOOST_STATIC_ASSERT( !(
|
BOOST_STATIC_ASSERT( !(
|
||||||
::boost::is_base_and_derived< Reference_counted_hierarchy_base, T >::value ||
|
::CGAL::is_same_or_derived< Reference_counted_hierarchy_base, T >::value ));
|
||||||
::boost::is_same < Reference_counted_hierarchy_base, T >::value ));
|
|
||||||
|
|
||||||
return new Rep(rep);
|
return new Rep(rep);
|
||||||
}
|
}
|
||||||
|
|
@ -823,8 +816,7 @@ private:
|
||||||
|
|
||||||
static Rep* new_rep( const Rep& rep) {
|
static Rep* new_rep( const Rep& rep) {
|
||||||
BOOST_STATIC_ASSERT( !(
|
BOOST_STATIC_ASSERT( !(
|
||||||
::boost::is_base_and_derived< Reference_counted_hierarchy_base, T >::value ||
|
::CGAL::is_same_or_derived< Reference_counted_hierarchy_base, T >::value ));
|
||||||
::boost::is_same < Reference_counted_hierarchy_base, T >::value ));
|
|
||||||
Rep* p = allocator.allocate(1);
|
Rep* p = allocator.allocate(1);
|
||||||
allocator.construct(p, rep);
|
allocator.construct(p, rep);
|
||||||
return p;
|
return p;
|
||||||
|
|
@ -919,8 +911,7 @@ protected:
|
||||||
//! constructor will work for class hierarchies of representations.
|
//! constructor will work for class hierarchies of representations.
|
||||||
Handle_with_policy( Rep* p) : ptr_( p) {
|
Handle_with_policy( Rep* p) : ptr_( p) {
|
||||||
BOOST_STATIC_ASSERT((
|
BOOST_STATIC_ASSERT((
|
||||||
::boost::is_base_and_derived< Reference_counted_hierarchy_base, T >::value ||
|
::CGAL::is_same_or_derived< Reference_counted_hierarchy_base, T >::value ));
|
||||||
::boost::is_same < Reference_counted_hierarchy_base, T >::value ));
|
|
||||||
Bind bind; // trigger compile-time check
|
Bind bind; // trigger compile-time check
|
||||||
(void)bind;
|
(void)bind;
|
||||||
}
|
}
|
||||||
|
|
@ -933,8 +924,7 @@ protected:
|
||||||
//! the template version with one argument.
|
//! the template version with one argument.
|
||||||
void initialize_with( Rep* p) {
|
void initialize_with( Rep* p) {
|
||||||
BOOST_STATIC_ASSERT((
|
BOOST_STATIC_ASSERT((
|
||||||
::boost::is_base_and_derived< Reference_counted_hierarchy_base, T >::value ||
|
::CGAL::is_same_or_derived< Reference_counted_hierarchy_base, T >::value ));
|
||||||
::boost::is_same < Reference_counted_hierarchy_base, T >::value ));
|
|
||||||
Bind bind; // trigger compile-time check
|
Bind bind; // trigger compile-time check
|
||||||
(void)bind;
|
(void)bind;
|
||||||
CGAL_precondition_msg( ptr_ == 0, "Handle_with_policy::initialize_with(): the "
|
CGAL_precondition_msg( ptr_ == 0, "Handle_with_policy::initialize_with(): the "
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
#ifndef CGAL_TYPE_TRAITS_H
|
||||||
|
#define CGAL_TYPE_TRAITS_H
|
||||||
|
|
||||||
|
#include <boost/type_traits/is_same.hpp>
|
||||||
|
#include <boost/type_traits/is_base_and_derived.hpp>
|
||||||
|
#include <boost/mpl/or.hpp>
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
#include <CGAL/Testsuite/assert.h>
|
||||||
|
#include <CGAL/type_traits.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue