Copies exactly
nvalues from the range beginning at
firstto the range beginning at
resultby performing
*(result + i) = *(first + i)for each integer in
[
â0â,
n)
. The behavior is undefined if
resultis within the range
[
first,
first + n)
(
ranges::copy_backwardmight be used instead in this case).
The function-like entities described on this page are algorithm function objects (informally known as niebloids), that is:
ranges::copy_n_result{first + n, result + n} or more formally, a value of type ranges::in_out_result that contains an input_iterator
iterator equals to ranges::next(first, n) and a weakly_incrementable
iterator equals to ranges::next(result, n).
Exactly n assignments.
[edit] NotesIn practice, implementations of std::ranges::copy_n
may avoid multiple assignments and use bulk copy functions such as std::memmove if the value type is TriviallyCopyable and the iterator types satisfy contiguous_iterator
. Alternatively, such copy acceleration can be injected during an optimization phase of a compiler.
When copying overlapping ranges, std::ranges::copy_n
is appropriate when copying to the left (beginning of the destination range is outside the source range) while std::ranges::copy_backward is appropriate when copying to the right (end of the destination range is outside the source range).
Output:
"ABCD" in[5] = 'F' out[5] = 'f'[edit] See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4