tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
prev.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2019 Tobias Hienzsch
3
4#ifndef TETL_ITERATOR_PREV_HPP
5#define TETL_ITERATOR_PREV_HPP
6
7#include <etl/_iterator/advance.hpp>
8#include <etl/_iterator/iterator_traits.hpp>
9
10namespace etl {
11
12/// Return the nth predecessor of iterator it.
13/// \ingroup iterator
14template <typename BidirIt>
15[[nodiscard]] constexpr auto prev(BidirIt it, typename iterator_traits<BidirIt>::difference_type n = 1) -> BidirIt
16{
17 etl::advance(it, -n);
18 return it;
19}
20} // namespace etl
21
22#endif // TETL_ITERATOR_PREV_HPP
constexpr auto prev(BidirIt it, typename iterator_traits< BidirIt >::difference_type n=1) -> BidirIt
Return the nth predecessor of iterator it.
Definition prev.hpp:15
Definition adjacent_find.hpp:9
iterator_traits is the type trait class that provides uniform interface to the properties of LegacyIt...
Definition iterator_traits.hpp:48