tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
copy_n.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_ALGORITHM_COPY_N_HPP
4#define TETL_ALGORITHM_COPY_N_HPP
5
6namespace etl {
7
16template <typename InputIt, typename Size, typename OutputIt>
17constexpr auto copy_n(InputIt first, Size count, OutputIt result) -> OutputIt
18{
19 if (count > 0) {
20 *result = *first;
21 for (Size i = 1; i < count; ++i) {
22 *(++result) = *(++first);
23 }
24 }
25 return result;
26}
27
28} // namespace etl
29
30#endif // TETL_ALGORITHM_COPY_N_HPP
constexpr auto count(InputIt first, InputIt last, T const &value) -> typename iterator_traits< InputIt >::difference_type
Returns the number of elements in the range [first, last) satisfying specific criteria....
Definition count.hpp:21
constexpr auto copy_n(InputIt first, Size count, OutputIt result) -> OutputIt
Copies exactly count values from the range beginning at first to the range beginning at result....
Definition copy_n.hpp:17
Definition adjacent_find.hpp:8