Moves the elements in the range [first,last] starting from the end into the range terminating at result.
The function begins by moving *(last-1) into *(result-1), and then follows backward by the elements preceding these, until first is reached (and including it).
BidirectionalIterator2 move_backward (BidirectionalIterator1 first, BidirectionalIterator1 last, BidirectionalIterator2 result); result Bidirectional iterator to the past-the-end position in the destination sequence. This shall not point to any element in the range [first,last]. Return Type : An iterator to the first element of the destination sequence where elements have been moved.
Input : vec1 contains : 3 4 5 7 8 vec2 contains : 8 9 6 2 4 7 Output : arr2 contains : 8 9 6 5 7 8 /*3 elements from 3rd position of vector vec1 moved to starting 4th position of vec2*/
Vector1 contains : 1 2 3 4 5 Vector2 contains : 7 7 7 7 7 Vector1 contains after std::move_backward function: 7 7 7 4 5
This article is contributed by Sachin Bisht. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- cin get() in C++ with Examples
- Difference between Increment and Decrement Operators
- Map of Vectors in C++ STL with Examples
- Problem in comparing Floating point numbers and how to compare them correctly?
- exit(0) vs exit(1) in C/C++ with Examples
- C++ program to print all Even and Odd numbers from 1 to N
- Reverse the content of a file and store it in another
- Minimum cells to be flipped to get a 2*2 submatrix with equal elements
- Nested Loops in C++ with Examples
- _Find_first() function in C++ bitset with Examples
- _Find_next() function in C++ bitset with Examples
- Left-Right traversal of all the levels of N-ary tree
- Difference between Iterators and Pointers in C/C++ with Examples
- ostream::seekp(pos) method in C++ with Exmaples
- Default Methods in C++ with Examples