In terms of practical usage what differences are there between
a) copy_backward
b) copy with reverse_iterators for source and destination
In particular is one more generally applicable than the other? Are there any other differences?
Update: If there's really no difference, then any reference in C++ literature to this equivalence is appreciated. The motivation behind this question is to understand if this was by design or one of those slip ups (like missing copy_if)
std::copy. Copies the elements in the range [first,last) into the range beginning at result . The function returns an iterator to the end of the destination range (which points to the element following the last element copied).
COPYING AN ORIGINAL IN REVERSE PAGE ORDER (REVERSE ORDER)The Reverse Order function outputs printed sheets in top-to-bottom order with the printed side facing up, resulting in a set of copies stacked in the opposite order to the original.
C++ STL std::copy() function copy() function is a library function of algorithm header, it is used to copy the elements of a container, it copies the elements of a container from given range to another container from a given beginning position.
http://www.cplusplus.com/reference/algorithm/copy/ has a implementation of std::copy
http://www.cplusplus.com/reference/algorithm/copy_backward/ has a implementation of std::copy_backward
You can see the differences by yourself.
Note: If I were you I would use std::copy_backward
, because calling std::copy
with the std::reverse_iterator<T>
class might be a little slower (it needs more memory than a bidirectional iterator)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With