From ad803b82b586d28bac10077a36f3cb4858ecbc68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Sun, 21 Jun 2020 12:03:53 +0200 Subject: [PATCH] Enhance is_convertible.h with boost::mpl rather than handmade enum { value = } --- STL_Extension/include/CGAL/is_iterator.h | 84 ++++++++++++++---------- 1 file changed, 48 insertions(+), 36 deletions(-) diff --git a/STL_Extension/include/CGAL/is_iterator.h b/STL_Extension/include/CGAL/is_iterator.h index 1e563aaf781..c6d25858a01 100644 --- a/STL_Extension/include/CGAL/is_iterator.h +++ b/STL_Extension/include/CGAL/is_iterator.h @@ -17,12 +17,14 @@ #ifndef CGAL_IS_ITERATOR_H #define CGAL_IS_ITERATOR_H -#include #include #include #include #include #include +#include + +#include namespace CGAL { namespace internal { @@ -35,42 +37,52 @@ BOOST_MPL_HAS_XXX_TRAIT_DEF(reference) //We request the type to be either a pointer or to //provide all 5 nested types provided by iterator_traits -template struct is_iterator_ { - enum { value = - ( has_iterator_category::value && - has_value_type::value && - has_difference_type::value && - has_pointer::value && - has_reference::value - ) - || boost::is_pointer::value }; -}; - -template ::value> -struct is_iterator_type_ { - enum { value=false }; -}; -template struct is_iterator_type_ : - //boost::is_base_of::iterator_category> - boost::is_convertible::iterator_category,U> - {}; - -} - -// NOTE: we don't want the real std::decay or functions are included -template struct is_iterator : - internal::is_iterator_::type>::type> {}; - -template struct is_iterator_type : - internal::is_iterator_type_::type>::type,Tag> {}; - -template ::value> struct is_iterator_to { - enum { value=false }; -}; -template struct is_iterator_to : - boost::is_convertible::value_type,U> +template +struct is_iterator_ + : public boost::mpl::or_< + boost::mpl::and_< + has_iterator_category, + has_value_type, + has_difference_type, + has_pointer, + has_reference >, + boost::is_pointer > { }; -} +template ::value> +struct is_iterator_type_ + : public boost::mpl::false_ +{ }; + +template +struct is_iterator_type_ + : public //boost::is_base_of::iterator_category> + boost::is_convertible::iterator_category, U> +{ }; + +} // namespace internal + +// NOTE: we don't want the real std::decay or functions are included +template +struct is_iterator + : public internal::is_iterator_::type>::type> +{ }; + +template +struct is_iterator_type + : public internal::is_iterator_type_::type>::type, Tag> +{ }; + +template ::value> +struct is_iterator_to + : public boost::mpl::false_ +{ }; + +template +struct is_iterator_to + : public boost::is_convertible::value_type, U> +{ }; + +} // namespace CGAL #endif // CGAL_IS_ITERATOR_H