tetl
0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
swap_ranges.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_SWAP_RANGES_HPP
5
#
define
TETL_ALGORITHM_SWAP_RANGES_HPP
6
7
#
include
<
etl
/
_algorithm
/
iter_swap
.
hpp
>
8
9
namespace
etl
{
10
11
/// \brief Exchanges elements between range `[first1 ,last1)` and another range
12
/// starting at `first2`.
13
///
14
/// \param first1 The first range of elements to swap.
15
/// \param last1 The first range of elements to swap.
16
/// \param first2 Beginning of the second range of elements to swap.
17
///
18
/// \returns Iterator to the element past the last element exchanged in the
19
/// range beginning with `first2`.
20
///
21
/// https://en.cppreference.com/w/cpp/algorithm/swap_ranges
22
///
23
/// \ingroup algorithm
24
template
<
typename
ForwardIt1,
typename
ForwardIt2>
25
constexpr
auto
swap_ranges
(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2) -> ForwardIt2
26
{
27
while
(first1 != last1) {
28
etl
::iter_swap(first1, first2);
29
++first1;
30
++first2;
31
}
32
33
return
first2;
34
}
35
36
}
// namespace etl
37
38
#
endif
// TETL_ALGORITHM_SWAP_RANGES_HPP
etl::swap_ranges
constexpr auto swap_ranges(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2) -> ForwardIt2
Exchanges elements between range [first1 ,last1) and another range starting at first2.
Definition
swap_ranges.hpp:25
etl
Definition
adjacent_find.hpp:9
include
etl
_algorithm
swap_ranges.hpp
Generated on Sun Sep 7 2025 19:14:47 for tetl by
1.9.8