tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
distance.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_ITERATOR_DISTANCE_HPP
4#define TETL_ITERATOR_DISTANCE_HPP
5
9
10namespace etl {
11
15template <typename It>
16constexpr auto distance(It first, It last) -> typename iterator_traits<It>::difference_type
17{
18 using category = typename iterator_traits<It>::iterator_category;
20
22 return last - first;
23 } else {
24 auto result = typename iterator_traits<It>::difference_type{};
25 while (first != last) {
26 ++first;
27 ++result;
28 }
29 return result;
30 }
31}
32
33} // namespace etl
34
35#endif // TETL_ITERATOR_DISTANCE_HPP
constexpr auto distance(It first, It last) -> typename iterator_traits< It >::difference_type
Returns the number of hops from first to last.
Definition distance.hpp:16
Definition adjacent_find.hpp:8
constexpr bool is_base_of_v
Definition is_base_of.hpp:39
iterator_traits is the type trait class that provides uniform interface to the properties of LegacyIt...
Definition iterator_traits.hpp:47