mirror of
https://github.com/boostorg/iterator.git
synced 2025-05-11 05:23:52 +00:00
Converted counting_iterator to rely on TypeTraits instead of MPL.
This commit is contained in:
parent
7a200905dd
commit
abe6fbfd4b
@ -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());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user