Javatpoint Logo
Javatpoint Logo

C++ Algorithm Functions copy_backward()

C++ Algorithm copy_backward() function is used for copying of elements in the backward order, it accepts three arguments and then copies the elements belonging to the range [first,last]. The copying of elements begins in the reverse order with termination point at 'result'.

Syntax

Parameter

first: It is a bidirectional iterator to the first element of the range, where the element itself is included in the range.

last: It is a bidirectional iterator to the last element of the range, where the element itself is not included in the range.

result: It is a bidirectional iterator to the final position of copied elements.

Return value

The function returns an iterator of the first element to the sequence of copied ones.

Example 1

Output:

newvector contains: 5 10 15 5 10 15 20 25

Complexity

The complexity of the function is linear starting from the first element to the last one.

Data races

Some or all of the container objects are accessed.

Exceptions

The function throws an exception if any of the container elements throws one.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA