2012-04-01 13:15:09 +00:00
|
|
|
#ifndef SPROUT_ITERATOR_DISTANCE_HPP
|
|
|
|
#define SPROUT_ITERATOR_DISTANCE_HPP
|
|
|
|
|
|
|
|
#include <iterator>
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/iterator/next.hpp>
|
2012-09-29 08:10:46 +00:00
|
|
|
#include <sprout/adl/not_found.hpp>
|
|
|
|
|
|
|
|
namespace sprout_adl {
|
|
|
|
sprout::adl_not_found iterator_distance(...);
|
|
|
|
} // namespace sprout_adl
|
2012-04-01 13:15:09 +00:00
|
|
|
|
|
|
|
namespace sprout {
|
2012-09-26 09:42:43 +00:00
|
|
|
namespace iterator_detail {
|
2012-04-01 13:15:09 +00:00
|
|
|
// Copyright (C) 2011 RiSK (sscrisk)
|
|
|
|
|
2012-04-04 08:48:02 +00:00
|
|
|
template<typename InputIterator>
|
2012-07-15 07:04:05 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
|
2012-09-26 09:42:43 +00:00
|
|
|
iterator_distance(InputIterator first, InputIterator last) {
|
2012-04-01 13:15:09 +00:00
|
|
|
return first == last ? 0
|
2012-09-26 09:42:43 +00:00
|
|
|
: 1 + sprout::iterator_detail::iterator_distance(sprout::next(first), last)
|
2012-04-01 13:15:09 +00:00
|
|
|
;
|
|
|
|
}
|
2012-09-26 09:42:43 +00:00
|
|
|
} // namespace iterator_detail
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
namespace sprout_iterator_detail {
|
|
|
|
template<typename InputIterator>
|
|
|
|
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
|
|
|
|
distance(InputIterator first, InputIterator last) {
|
|
|
|
using sprout::iterator_detail::iterator_distance;
|
2012-09-29 08:10:46 +00:00
|
|
|
using sprout_adl::iterator_distance;
|
2012-09-26 09:42:43 +00:00
|
|
|
return iterator_distance(first, last);
|
|
|
|
}
|
|
|
|
} // namespace sprout_iterator_detail
|
|
|
|
|
|
|
|
namespace sprout {
|
2012-04-01 13:15:09 +00:00
|
|
|
//
|
|
|
|
// distance
|
|
|
|
//
|
2012-04-04 08:48:02 +00:00
|
|
|
template<typename InputIterator>
|
2012-07-15 07:04:05 +00:00
|
|
|
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
|
2012-04-04 08:48:02 +00:00
|
|
|
distance(InputIterator first, InputIterator last) {
|
2012-09-26 09:42:43 +00:00
|
|
|
return sprout_iterator_detail::distance(first, last);
|
2012-04-01 13:15:09 +00:00
|
|
|
}
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_ITERATOR_DISTANCE_HPP
|