std :: move
Moves the elements in the range [first,last] into the range beginning at result.
The value of the elements in the [first,last] is transferred to the elements pointed by result. After the call, the elements in the range [first,last] are left in an unspecified but valid state.
OutputIterator move (InputIterator first, InputIterator last, OutputIterator result); Parameters : first, last Input iterators to the initial and final positions in a sequence to be moved. The range used is [first,last], which contains all the elements between first and last, including the element pointed by first but not the element pointed by last. result Output iterator to the initial position in the destination sequence. This shall not point to any element in the range [first,last]. Return type : An iterator to the end of the destination range where elements have been moved.
Input : vec1 contains : 1 2 3 4 5 vec2 contains : 7 7 7 7 7 Output : arr2 contains : 7 1 2 3 4 /*First 4 elements of vector vec1 moved to vec2 starting second position*/
Vector1 contains : 1 2 3 4 5 Vector2 contains : 7 7 7 7 7 Vector2 contains after std::move function: 7 1 2 3 4
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.
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Find the K closest points to origin using Priority Queue
- Implementation of lower_bound and upper_bound on Set of Pairs in C++
- std::cerr | Error Stream Object in C++ with Examples
- basic_istream::readsome() in C++ with Examples
- std::is_function template in C++ with Examples
- type_traits::is_null_pointer in C++
- std::extent() template in C++ with Examples
- basic_istream::swap() in C++ with Examples
- basic_istream::peek() in C++ with Examples
- basic_istream::unget() in C++ with Examples
- exception::bad_exception in C++ with Examples
- std::bad_array_new_length class in C++ with Examples
- basic_istream::seekg() in C++ with Examples
- functional::bad_function_call in C++ with Examples
- basic_istream::get() in C++ with Examples