C++ 算法 move()function 用于移动元素。它接受三个参数,然后将属于范围 [first,last) 的元素移动到以 'result' 开头的范围中。
用法
template<class InputIterator, class OutputIterator> OutputIterator move(InputIterator first, InputIterator last, OutputIterator result);
参数
first:它是范围的第一个元素的输入迭代器,其中元素本身包含在范围内。
last: 它是范围最后一个元素的输入迭代器,其中元素本身不包含在范围内。
result:它是移动元素初始位置的输出迭代器。
返回值
该函数将第一个元素的迭代器返回到移动的元素序列。
例子1
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
int main ()
{
std::vector<std::string> a = {"suraj","aman","vanshika","chhavi"};
std::vector<std::string> b (4);
std::cout << "Move function.\n";
std::move ( a.begin(), a.begin()+4, b.begin() );
st