Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
copy.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_COPY_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ALGORITHM_COPY_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"
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"
18// parasoft-end-suppress AUTOSAR-A16_2_2-a-2
19
20namespace arene {
21namespace base {
22
23// parasoft-begin-suppress AUTOSAR-M3_3_2-a "False positive: this function does not have internal linkage"
24// parasoft-begin-suppress AUTOSAR-M5_0_15-a "False positive: this is generic iterator arithmetic, not pointer-specific"
25
26/// @brief Copies the elements in the range, defined by <tt>[first, last)</tt>,
27/// to another range beginning at @c output.
28/// @tparam InputIterator The type of the Source iterator
29/// @tparam OutputIterator The type of the Destination iterator
30/// @param first Start of the range of elements to copy from
31/// @param last End (non-inclusive) of the range of elements to copy from
32/// @param output Start of the range of elements to copy into
33/// @return OutputIterator An iterator after the last copied item
34template <
35 class InputIterator,
36 class OutputIterator,
40constexpr auto copy(InputIterator first, InputIterator last, OutputIterator output) noexcept(
41 noexcept(*(++output)) && noexcept(*(++first)) && noexcept(first != last) &&
45) -> OutputIterator {
46 while (first != last) {
47 *output = *first;
48 ++first;
49 ++output;
50 }
51
52 return output;
53}
54
55// parasoft-end-suppress AUTOSAR-M3_3_2-a
56// parasoft-end-suppress AUTOSAR-M5_0_15-a
57
58} // namespace base
59} // namespace arene
60
61#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ALGORITHM_COPY_HPP_
Type trait to detect if an instance of To is assignable to from arguments of From without throwing.
Definition is_assignable.hpp:78
provides a uniform interface to the properties of an iterator
Definition iterator_traits.hpp:90
Definition accumulate.hpp:37
constexpr auto copy(InputIterator first, InputIterator last, OutputIterator output) noexcept(noexcept(*(++output)) &&noexcept(*(++first)) &&noexcept(first !=last) &&std::is_nothrow_assignable<, typename std::iterator_traits< InputIterator >::reference >::value) -> OutputIterator
Copies the elements in the range, defined by [first, last), to another range beginning at output.
Definition copy.hpp:40
typename constraints_impl::constraints< EnableIfs... >::type constraints
Helper used to express template constraints in a consistent way using std::enable_if_t.
Definition constraints.hpp:51
Definition accumulate.hpp:36
typename enable_if< Condition, Type >::type enable_if_t
Type alias to support constraining templates. Is an alias for the specified type if the Condition is ...
Definition enable_if.hpp:41
auto declval() noexcept -> T &&
A dummy function that is declared but not defined, with a user-specified return type,...