Converted counting_iterator to rely on TypeTraits instead of MPL.

This commit is contained in:
Andrey Semashev 2022-01-13 16:49:28 +03:00
parent 7a200905dd
commit abe6fbfd4b
2 changed files with 23 additions and 24 deletions

View File

@ -15,12 +15,11 @@
# include <boost/type_traits/is_arithmetic.hpp> # include <boost/type_traits/is_arithmetic.hpp>
# endif # endif
# include <boost/type_traits/is_integral.hpp> # include <boost/type_traits/is_integral.hpp>
# include <boost/iterator/iterator_adaptor.hpp> # include <boost/type_traits/type_identity.hpp>
# include <boost/type_traits/conditional.hpp>
# include <boost/type_traits/integral_constant.hpp>
# include <boost/detail/numeric_traits.hpp> # include <boost/detail/numeric_traits.hpp>
# include <boost/mpl/bool.hpp> # include <boost/iterator/iterator_adaptor.hpp>
# include <boost/mpl/if.hpp>
# include <boost/mpl/identity.hpp>
# include <boost/mpl/eval_if.hpp>
namespace boost { namespace boost {
namespace iterators { namespace iterators {
@ -63,23 +62,23 @@ namespace detail
template <class T> template <class T>
struct is_numeric struct is_numeric
: mpl::bool_<(::boost::iterators::detail::is_numeric_impl<T>::value)> : boost::integral_constant<bool, ::boost::iterators::detail::is_numeric_impl<T>::value>
{}; {};
# if defined(BOOST_HAS_LONG_LONG) # if defined(BOOST_HAS_LONG_LONG)
template <> template <>
struct is_numeric< ::boost::long_long_type> struct is_numeric< ::boost::long_long_type>
: mpl::true_ {}; : boost::true_type {};
template <> template <>
struct is_numeric< ::boost::ulong_long_type> struct is_numeric< ::boost::ulong_long_type>
: mpl::true_ {}; : boost::true_type {};
# endif # endif
// Some compilers fail to have a numeric_limits specialization // Some compilers fail to have a numeric_limits specialization
template <> template <>
struct is_numeric<wchar_t> struct is_numeric<wchar_t>
: mpl::true_ {}; : true_type {};
template <class T> template <class T>
struct numeric_difference struct numeric_difference
@ -92,20 +91,20 @@ namespace detail
{ {
typedef typename detail::ia_dflt_help< typedef typename detail::ia_dflt_help<
CategoryOrTraversal CategoryOrTraversal
, mpl::eval_if< , typename boost::conditional<
is_numeric<Incrementable> is_numeric<Incrementable>::value
, mpl::identity<random_access_traversal_tag> , boost::type_identity<random_access_traversal_tag>
, iterator_traversal<Incrementable> , iterator_traversal<Incrementable>
> >::type
>::type traversal; >::type traversal;
typedef typename detail::ia_dflt_help< typedef typename detail::ia_dflt_help<
Difference Difference
, mpl::eval_if< , typename boost::conditional<
is_numeric<Incrementable> is_numeric<Incrementable>::value
, numeric_difference<Incrementable> , numeric_difference<Incrementable>
, iterator_difference<Incrementable> , iterator_difference<Incrementable>
> >::type
>::type difference; >::type difference;
typedef iterator_adaptor< typedef iterator_adaptor<
@ -201,13 +200,13 @@ class counting_iterator
difference_type difference_type
distance_to(counting_iterator<OtherIncrementable, CategoryOrTraversal, Difference> const& y) const distance_to(counting_iterator<OtherIncrementable, CategoryOrTraversal, Difference> const& y) const
{ {
typedef typename mpl::if_< typedef typename boost::conditional<
detail::is_numeric<Incrementable> detail::is_numeric<Incrementable>::value
, detail::number_distance<difference_type, Incrementable, OtherIncrementable> , detail::number_distance<difference_type, Incrementable, OtherIncrementable>
, detail::iterator_distance<difference_type, Incrementable, OtherIncrementable> , detail::iterator_distance<difference_type, Incrementable, OtherIncrementable>
>::type d; >::type d;
return d::distance(this->base(), y.base()); return d::distance(this->base(), y.base());
} }
}; };

View File

@ -30,7 +30,7 @@
#include <boost/iterator/new_iterator_tests.hpp> #include <boost/iterator/new_iterator_tests.hpp>
#include <boost/next_prior.hpp> #include <boost/next_prior.hpp>
#include <boost/mpl/if.hpp> #include <boost/type_traits/conditional.hpp>
#include <boost/detail/workaround.hpp> #include <boost/detail/workaround.hpp>
#include <boost/limits.hpp> #include <boost/limits.hpp>
@ -68,7 +68,7 @@ struct unsigned_assert_nonnegative
template <class T> template <class T>
struct assert_nonnegative struct assert_nonnegative
: boost::mpl::if_c< : boost::conditional<
std::numeric_limits<T>::is_signed std::numeric_limits<T>::is_signed
, signed_assert_nonnegative<T> , signed_assert_nonnegative<T>
, unsigned_assert_nonnegative<T> , unsigned_assert_nonnegative<T>