tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
advance.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_ITERATOR_ADVANCE_HPP
4#define TETL_ITERATOR_ADVANCE_HPP
5
9
10namespace etl {
11
21template <typename It, typename Distance>
22constexpr auto advance(It& it, Distance n) -> void
23{
24 using category = typename iterator_traits<It>::iterator_category;
26
27 auto dist = typename iterator_traits<It>::difference_type(n);
29 it += dist;
30 } else {
31 while (dist > 0) {
32 --dist;
33 ++it;
34 }
36 while (dist < 0) {
37 ++dist;
38 --it;
39 }
40 }
41 }
42}
43
44} // namespace etl
45
46#endif // TETL_ITERATOR_ADVANCE_HPP
constexpr auto advance(It &it, Distance n) -> void
Increments given iterator it by n elements.
Definition advance.hpp:22
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