mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
porting sscrisk/CEL
This commit is contained in:
parent
ad60c8c530
commit
db20f64991
181 changed files with 2531 additions and 607 deletions
40
sprout/detail/iterator_ext.hpp
Normal file
40
sprout/detail/iterator_ext.hpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
#ifndef SPROUT_DETAIL_ITERATOR_EXT_HPP
|
||||
#define SPROUT_DETAIL_ITERATOR_EXT_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
template<typename Iterator>
|
||||
SPROUT_CONSTEXPR typename std::iterator_traits<Iterator>::difference_type bidirectional_distance_impl(
|
||||
Iterator first1,
|
||||
Iterator first2,
|
||||
Iterator last,
|
||||
typename std::iterator_traits<Iterator>::difference_type current = 1
|
||||
)
|
||||
{
|
||||
return first1 == last ? current
|
||||
: first2 == last ? -current
|
||||
: sprout::detail::bidirectional_distance_impl(sprout::next(first1), sprout::prev(first2), last, current + 1)
|
||||
;
|
||||
}
|
||||
|
||||
//
|
||||
// bidirectional_distance
|
||||
//
|
||||
template<typename Iterator>
|
||||
SPROUT_CONSTEXPR typename std::iterator_traits<Iterator>::difference_type bidirectional_distance(
|
||||
Iterator first,
|
||||
Iterator last
|
||||
)
|
||||
{
|
||||
return first == last ? 0
|
||||
: sprout::detail::bidirectional_distance_impl(sprout::next(first), sprout::prev(first), last)
|
||||
;
|
||||
}
|
||||
} // namespace detail
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_DETAIL_ITERATOR_EXT_HPP
|
Loading…
Add table
Add a link
Reference in a new issue