tetl
0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
move_backward.hpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: BSL-1.0
2
// SPDX-FileCopyrightText: Copyright (C) 2020 Tobias Hienzsch
3
4
#
ifndef
TETL_ALGORITHM_MOVE_BACKWARD_HPP
5
#
define
TETL_ALGORITHM_MOVE_BACKWARD_HPP
6
7
#
include
<
etl
/
_utility
/
move
.
hpp
>
8
9
namespace
etl
{
10
11
/// Moves the elements from the range `[first, last)`, to another range
12
/// ending at destination. The elements are moved in reverse order (the last
13
/// element is moved first), but their relative order is preserved.
14
///
15
/// https://en.cppreference.com/w/cpp/algorithm/move_backward
16
///
17
/// \returns Iterator in the destination range, pointing at the last element moved.
18
///
19
/// \param first The range of elements to move.
20
/// \param last The range of elements to move.
21
/// \param destination End of the destination range.
22
///
23
/// \ingroup algorithm
24
template
<
typename
BidirIt1,
typename
BidirIt2>
25
constexpr
auto
move_backward
(BidirIt1 first, BidirIt1 last, BidirIt2 destination) -> BidirIt2
26
{
27
for
(; first != last;) {
28
--last;
29
*(--destination) =
etl
::move(*last);
30
}
31
return
destination;
32
}
33
34
}
// namespace etl
35
36
#
endif
// TETL_ALGORITHM_MOVE_BACKWARD_HPP
etl::move_backward
constexpr auto move_backward(BidirIt1 first, BidirIt1 last, BidirIt2 destination) -> BidirIt2
Moves the elements from the range [first, last), to another range ending at destination....
Definition
move_backward.hpp:25
etl
Definition
adjacent_find.hpp:9
include
etl
_algorithm
move_backward.hpp
Generated on Sun Sep 7 2025 19:14:46 for tetl by
1.9.8