From abe6fbfd4b8b69c1ac9c7cb43452a2a5f74ec708 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Thu, 13 Jan 2022 16:49:28 +0300 Subject: [PATCH] Converted counting_iterator to rely on TypeTraits instead of MPL. --- include/boost/iterator/counting_iterator.hpp | 43 ++++++++++---------- test/counting_iterator_test.cpp | 4 +- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/include/boost/iterator/counting_iterator.hpp b/include/boost/iterator/counting_iterator.hpp index 89dbe99..45d4c83 100644 --- a/include/boost/iterator/counting_iterator.hpp +++ b/include/boost/iterator/counting_iterator.hpp @@ -15,12 +15,11 @@ # include # endif # include -# include +# include +# include +# include # include -# include -# include -# include -# include +# include namespace boost { namespace iterators { @@ -63,23 +62,23 @@ namespace detail template struct is_numeric - : mpl::bool_<(::boost::iterators::detail::is_numeric_impl::value)> + : boost::integral_constant::value> {}; # if defined(BOOST_HAS_LONG_LONG) template <> struct is_numeric< ::boost::long_long_type> - : mpl::true_ {}; + : boost::true_type {}; template <> struct is_numeric< ::boost::ulong_long_type> - : mpl::true_ {}; + : boost::true_type {}; # endif // Some compilers fail to have a numeric_limits specialization template <> struct is_numeric - : mpl::true_ {}; + : true_type {}; template struct numeric_difference @@ -92,20 +91,20 @@ namespace detail { typedef typename detail::ia_dflt_help< CategoryOrTraversal - , mpl::eval_if< - is_numeric - , mpl::identity + , typename boost::conditional< + is_numeric::value + , boost::type_identity , iterator_traversal - > + >::type >::type traversal; typedef typename detail::ia_dflt_help< Difference - , mpl::eval_if< - is_numeric + , typename boost::conditional< + is_numeric::value , numeric_difference , iterator_difference - > + >::type >::type difference; typedef iterator_adaptor< @@ -201,13 +200,13 @@ class counting_iterator difference_type distance_to(counting_iterator const& y) const { - typedef typename mpl::if_< - detail::is_numeric - , detail::number_distance - , detail::iterator_distance - >::type d; + typedef typename boost::conditional< + detail::is_numeric::value + , detail::number_distance + , detail::iterator_distance + >::type d; - return d::distance(this->base(), y.base()); + return d::distance(this->base(), y.base()); } }; diff --git a/test/counting_iterator_test.cpp b/test/counting_iterator_test.cpp index 0b1db7b..ac382f0 100644 --- a/test/counting_iterator_test.cpp +++ b/test/counting_iterator_test.cpp @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include @@ -68,7 +68,7 @@ struct unsigned_assert_nonnegative template struct assert_nonnegative - : boost::mpl::if_c< + : boost::conditional< std::numeric_limits::is_signed , signed_assert_nonnegative , unsigned_assert_nonnegative