Modifying Algorithms
C++ has many algorithms to modify elements and ranges.
Copy Elements and Ranges
You can copy ranges forward with std::copy, backward with std::copy_backward and conditionally with std::copy_if. If you want to copy n elements, you can use std::copy_n.
Copies the range:
OutIt copy(InpIt first, InpIt last, OutIt result)
FwdIt2 copy(ExePol pol, FwdIt first, FwdIt last, FowdIt2 result)
Copies n elements:
OutIt copy_n(InpIt first, Size n, OutIt result)
FwdIt2 copy_n(ExePol pol, FwdIt first, Size n, FwdIt2 result)
Copies the elements dependent on the predicate pre.
OutIt copy_if(InpIt first, InpIt last, OutIt result, UnPre pre)
FwdIt2 copy_if(ExePol pol, FwdIt first, FwdIt last, FwdIt2 result, UnPre pre)
Copies the range backward:
BiIt copy_backward(BiIt first, BiIt last, BiIt result)
The algorithms need input iterators and copy their elements to result. They return an end iterator to the destination range.