5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ITERATOR_DISTANCE_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ITERATOR_DISTANCE_HPP_
12#include "arene/base/stdlib_choice/iterator_tags.hpp"
13#include "arene/base/stdlib_choice/iterator_traits.hpp"
18namespace distance_impl {
29template <
typename Iterator>
30constexpr auto do_distance(
33 std::random_access_iterator_tag
34)
noexcept(
noexcept(last - first))
35 ->
typename std::iterator_traits<Iterator>::difference_type {
48template <
typename Iterator>
49constexpr auto do_distance(
52 std::input_iterator_tag
53)
noexcept(
noexcept(first != last) &&
noexcept(++first))
54 ->
typename std::iterator_traits<Iterator>::difference_type {
55 typename std::iterator_traits<Iterator>::difference_type result{0};
56 while (first != last) {
78template <
typename Iterator>
79constexpr auto distance(Iterator first, Iterator last)
noexcept(
provides a uniform interface to the properties of an iterator
Definition iterator_traits.hpp:90
Definition accumulate.hpp:37
constexpr auto distance(Iterator first, Iterator last) noexcept(noexcept(distance_impl::do_distance(first, last, typename std::iterator_traits< Iterator >::iterator_category{}))) -> typename std::iterator_traits< Iterator >::difference_type
Find the number of elements between first and last.
Definition distance.hpp:79
Definition accumulate.hpp:36