Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
move.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_MOVE_HPP_
6
#
define
INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ALGORITHM_MOVE_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/constraints/constraints.hpp"
13
#
include
"arene/base/stdlib_choice/declval.hpp"
14
#
include
"arene/base/stdlib_choice/enable_if.hpp"
15
#
include
"arene/base/stdlib_choice/is_assignable.hpp"
16
#
include
"arene/base/stdlib_choice/iterator_traits.hpp"
17
#
include
"arene/base/stdlib_choice/move.hpp"
18
#
include
"arene/base/type_traits/iterator_category_traits.hpp"
19
#
include
"arene/base/utility/make_subrange.hpp"
20
// parasoft-end-suppress AUTOSAR-A16_2_2-a-2
21
22
namespace
arene
{
23
namespace
base
{
24
25
// parasoft-begin-suppress AUTOSAR-M3_3_2-a-2 "False positive: inline function used in multiple translation units"
26
/// @brief Moves the elements in the range <tt>[first, last)</tt>, to another
27
/// range beginning at @c output, starting from @c first and proceeding to
28
/// <tt>last - 1</tt>. After this operation the elements in the moved-from range
29
/// will still contain valid values of the appropriate type, but not necessarily
30
/// the same values as before the move.
31
/// @tparam InIterator The type of the Iterator for the range to take items from
32
/// @tparam OutIterator The type of the Iterator for the range to put items into
33
/// @param first Start of the range to take items from
34
/// @param last End (exclusive) of the range to take items from
35
/// @param output Start of the range to put items into
36
/// @return OutIterator for the element past the last moved item
37
template
<
38
class
InIterator
,
39
class
OutIterator
,
40
constraints
<
41
std
::
enable_if_t
<
base
::
is_input_iterator_v
<
InIterator
>>,
42
std
::
enable_if_t
<
base
::
is_output_iterator_v
<
OutIterator
>>,
43
std
::
enable_if_t
<
std
::
is_assignable
<
44
decltype
(*
std
::
declval
<
OutIterator
>()),
45
typename
std
::
iterator_traits
<
InIterator
>::
value_type
&&>::
value
>> =
nullptr
>
46
constexpr
auto
move
(
47
InIterator
first
,
48
InIterator
last
,
// CODEQLFP(DCL51-CPP) CODEQLFP(A15-4-4)
49
OutIterator
output
50
)
//
51
noexcept
(
52
noexcept
(*
first
++) &&
noexcept
(
output
++) &&
// CODEQLFP(EXP52-CPP) CODEQLFP(A5-2-6)
53
noexcept
(
first
!=
last
) &&
// CODEQLFP(A5-2-6)
54
std
::
is_nothrow_assignable
<
55
decltype
(*
std
::
declval
<
OutIterator
>()),
56
typename
std
::
iterator_traits
<
InIterator
>::
value_type
>::
value
57
) ->
OutIterator
{
// CODEQLFP(M5-3-1)
58
for
(
auto
&
element
:
arene
::
base
::
make_subrange
(
first
,
last
)) {
// CODEQLFP(A7-1-1) CODEQLFP(A7-1-2)
59
// parasoft-begin-suppress AUTOSAR-A18_9_3-a-2 "False Positive: Generic code, 'element' is not explicitly const"
60
*
output
++ =
std
::
move
(
element
);
// CODEQLFP(CTR55-CPP) CODEQLFP(A4-7-1) CODEQLFP(M5-2-10)
61
// parasoft-end-suppress AUTOSAR-A18_9_3-a-2
62
}
// CODEQLFP(A5-0-2)
63
return
output
;
64
}
65
// parasoft-end-suppress AUTOSAR-M3_3_2-a-2
66
67
}
// namespace base
68
}
// namespace arene
69
70
#
endif
// INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ALGORITHM_MOVE_HPP_
arene::base
Definition
array_exceptions_disabled.cpp:11
arene
Copyright 2026, Toyota Motor Corporation.
Definition
array_exceptions_disabled.cpp:10
arene
base
algorithm
move.hpp
Generated by
1.13.2