mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-25 21:35:41 +00:00
42 lines
1.3 KiB
C++
42 lines
1.3 KiB
C++
#ifndef SPROUT_ITERATOR_DISTANCE_HPP
|
|
#define SPROUT_ITERATOR_DISTANCE_HPP
|
|
|
|
#include <iterator>
|
|
#include <sprout/config.hpp>
|
|
#include <sprout/iterator/next.hpp>
|
|
|
|
namespace sprout {
|
|
namespace iterator_detail {
|
|
// Copyright (C) 2011 RiSK (sscrisk)
|
|
|
|
template<typename InputIterator>
|
|
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
|
|
iterator_distance(InputIterator first, InputIterator last) {
|
|
return first == last ? 0
|
|
: 1 + sprout::iterator_detail::iterator_distance(sprout::next(first), last)
|
|
;
|
|
}
|
|
} // 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;
|
|
return iterator_distance(first, last);
|
|
}
|
|
} // namespace sprout_iterator_detail
|
|
|
|
namespace sprout {
|
|
//
|
|
// distance
|
|
//
|
|
template<typename InputIterator>
|
|
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
|
|
distance(InputIterator first, InputIterator last) {
|
|
return sprout_iterator_detail::distance(first, last);
|
|
}
|
|
} // namespace sprout
|
|
|
|
#endif // #ifndef SPROUT_ITERATOR_DISTANCE_HPP
|