tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
reverse_copy.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_ALGORITHM_REVERSE_COPY_HPP
5#define TETL_ALGORITHM_REVERSE_COPY_HPP
6
7namespace etl {
8
9/// \brief Copies the elements from the range `[first, last)` to another range
10/// beginning at d_first in such a way that the elements in the new range are in
11/// reverse order.
12/// \details If the source and destination ranges (that is, `[first, last)` and
13/// [d_first, d_first+(last-first)) respectively) overlap, the behavior is
14/// undefined.
15/// \ingroup algorithm
16template <typename BidirIt, typename OutputIt>
17constexpr auto reverse_copy(BidirIt first, BidirIt last, OutputIt destination) -> OutputIt
18{
19 for (; first != last; ++destination) {
20 *(destination) = *(--last);
21 }
22 return destination;
23}
24
25} // namespace etl
26
27#endif // TETL_ALGORITHM_REVERSE_COPY_HPP
constexpr auto reverse_copy(BidirIt first, BidirIt last, OutputIt destination) -> OutputIt
Copies the elements from the range [first, last) to another range beginning at d_first in such a way ...
Definition reverse_copy.hpp:17
Definition adjacent_find.hpp:9