tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
rend.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2021 Tobias Hienzsch
3
4#ifndef TETL_ITERATOR_REND_HPP
5#define TETL_ITERATOR_REND_HPP
6
7#include <etl/_iterator/begin.hpp>
8
9namespace etl {
10
11template <typename Iter>
12struct reverse_iterator;
13
14/// Returns an iterator to the reverse-end of the given container.
15/// \ingroup iterator
16template <typename Container>
17constexpr auto rend(Container& c) -> decltype(c.rend())
18{
19 return c.rend();
20}
21
22/// \ingroup iterator
23template <typename Container>
24constexpr auto rend(Container const& c) -> decltype(c.rend())
25{
26 return c.rend();
27}
28
29/// \ingroup iterator
30template <typename T, size_t N>
31constexpr auto rend(T (&array)[N]) -> reverse_iterator<T*>
32{
33 return reverse_iterator<T*>(begin(array));
34}
35
36/// Returns an iterator to the reverse-end of the given container.
37/// \ingroup iterator
38template <typename Container>
39constexpr auto crend(Container const& c) -> decltype(rend(c))
40{
41 return rend(c);
42}
43
44} // namespace etl
45
46#endif // TETL_ITERATOR_REND_HPP
constexpr auto rend(Container const &c) -> decltype(c.rend())
Definition rend.hpp:24
constexpr auto rend(Container &c) -> decltype(c.rend())
Returns an iterator to the reverse-end of the given container.
Definition rend.hpp:17
constexpr auto rend(T(&array)[N]) -> reverse_iterator< T * >
Definition rend.hpp:31
constexpr auto crend(Container const &c) -> decltype(rend(c))
Returns an iterator to the reverse-end of the given container.
Definition rend.hpp:39
Definition adjacent_find.hpp:9