Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
iter_swap.hpp
Go to the documentation of this file.
1// parasoft-begin-suppress AUTOSAR-A2_8_1-a "False positive: also defines arene::base::iter_swap"
2
3// Copyright 2024, Toyota Motor Corporation
4//
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ALGORITHM_ITER_SWAP_HPP_
7#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ALGORITHM_ITER_SWAP_HPP_
8
9// IWYU pragma: private, include "arene/base/algorithm.hpp"
10// IWYU pragma: friend "(arene/base(?!/tests)|stdlib/include/stdlib_detail)/.*"
11
12// parasoft-begin-suppress AUTOSAR-A16_2_2-a-2 "Arene Base aggregate headers permitted by A16-2-2 Permit #1"
13#include "arene/base/compiler_support/cpp14_inline.hpp"
14#include "arene/base/constraints/constraints.hpp"
15#include "arene/base/stdlib_choice/enable_if.hpp"
16#include "arene/base/type_traits/iterator_category_traits.hpp"
17#include "arene/base/utility/swap.hpp"
18// parasoft-end-suppress AUTOSAR-A16_2_2-a-2
19
20namespace arene {
21namespace base {
22namespace algorithm_detail {
23namespace iter_swap_detail {
24/// @brief function object that implements @c iter_swap
25class iter_swap_impl_fn {
26 public:
27 /// @brief Swaps the values of the elements the given iterators are pointing to.
28 /// @tparam IteratorA The type of the Iterator for the first value to swap
29 /// @tparam IteratorB The type of the Iterator for the second value to swap
30 /// @param lhs Iterator to first value to swap
31 /// @param rhs Iterator to second value to swap
32 template <
33 class IteratorA,
34 class IteratorB,
35 constraints<
36 std::enable_if_t<is_forward_iterator_v<IteratorA>>,
37 std::enable_if_t<is_forward_iterator_v<IteratorB>>> = nullptr>
38 constexpr auto operator()(IteratorA lhs, IteratorB rhs) const noexcept(noexcept(::arene::base::swap(*lhs, *rhs)))
39 -> void {
40 ::arene::base::swap(*lhs, *rhs);
41 }
42};
43} // namespace iter_swap_detail
44} // namespace algorithm_detail
45
46// parasoft-begin-suppress AUTOSAR-M7_3_3-a "An unnamed namespace is used to create a per-TU reference to a global
47// object used in multiple TUs."
48// parasoft-begin-suppress CERT_CPP-DCL59-a "An unnamed namespace is used to create a per-TU reference to a global
49// object used in multiple TUs."
50ARENE_CPP14_INLINE_VARIABLE(algorithm_detail::iter_swap_detail::iter_swap_impl_fn, iter_swap);
51// parasoft-end-suppress AUTOSAR-M7_3_3-a
52// parasoft-end-suppress CERT_CPP-DCL59-a
53
54} // namespace base
55} // namespace arene
56
57#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ALGORITHM_ITER_SWAP_HPP_
Definition array_exceptions_disabled.cpp:11
ARENE_CPP14_INLINE_VARIABLE(algorithm_detail::iter_swap_detail::iter_swap_impl_fn, iter_swap)
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10