Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
swap_ranges.hpp
Go to the documentation of this file.
1
// Copyright 2024, Toyota Motor Corporation
2
//
3
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5
#
ifndef
INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ALGORITHM_SWAP_RANGES_HPP_
6
#
define
INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ALGORITHM_SWAP_RANGES_HPP_
7
8
// IWYU pragma: private, include "arene/base/algorithm.hpp"
9
// IWYU pragma: friend "(arene/base(?!/tests)|stdlib/include/stdlib_detail)/.*"
10
11
// parasoft-begin-suppress AUTOSAR-A16_2_2-a-2 "Arene Base aggregate headers permitted by A16-2-2 Permit #1"
12
#
include
"arene/base/algorithm/iter_swap.hpp"
13
#
include
"arene/base/constraints/constraints.hpp"
14
#
include
"arene/base/stdlib_choice/enable_if.hpp"
15
#
include
"arene/base/type_traits/iterator_category_traits.hpp"
16
// parasoft-end-suppress AUTOSAR-A16_2_2-a-2
17
18
namespace
arene
{
19
namespace
base
{
20
21
/// @brief Exchanges elements between range [first1, last1) and another range
22
/// starting at first2.
23
/// Precondition: the two ranges [first1, last1) and [first2, last2) do not
24
/// overlap, where last2 = std::next(first2, std::distance(first1, last1)).
25
/// @tparam SourceIterator The type of the Iterator for the first range
26
/// @tparam DestIterator The type of the Iterator for the second range
27
/// @param first1 Beginning of the first range of elements to swap
28
/// @param last1 End of the first range of elements to swap
29
/// @param first2 Beginning of the second range of elements to swap
30
/// @return End of the second range of swapped elements // CODEQLFP(EXP52-CPP) // CODEQLFP(DCL51-CPP)
31
template
<
32
class
SourceIterator
,
33
class
DestIterator
,
34
constraints
<
35
std
::
enable_if_t
<
is_input_iterator_v
<
SourceIterator
>>,
36
std
::
enable_if_t
<
is_input_iterator_v
<
DestIterator
>>,
37
std
::
enable_if_t
<
is_output_iterator_v
<
SourceIterator
>>,
38
std
::
enable_if_t
<
is_output_iterator_v
<
DestIterator
>>> =
nullptr
>
39
constexpr
auto
swap_ranges
(
SourceIterator
first1
,
SourceIterator
last1
,
DestIterator
first2
)
noexcept
(
40
noexcept
(::
arene
::
base
::
iter_swap
(
first1
++,
first2
++)) &&
noexcept
(
first1
!=
last1
)
41
) ->
DestIterator
{
42
while
(
first1
!=
last1
) {
43
::
arene
::
base
::
iter_swap
(
first1
++,
first2
++);
44
}
// CODEQLFP(A5-0-2)
45
return
first2
;
46
}
47
48
}
// namespace base
49
}
// namespace arene
50
51
#
endif
// INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ALGORITHM_SWAP_RANGES_HPP_
arene::base
Definition
array_exceptions_disabled.cpp:11
arene
Copyright 2026, Toyota Motor Corporation.
Definition
array_exceptions_disabled.cpp:10
arene
base
algorithm
swap_ranges.hpp
Generated by
1.13.2