STL copy 用法

int main()
{
	int src[] = {1,2,3,4,5,6,7,8,9,10};
	vector<int>srcVect(11);//必须大于等于 10
	std::copy(src, src + 10, srcVect.begin());//数组复制到容器中
	for (auto const & child: srcVect)
	{
		cout<<child<<" ";
	}

	cout<<endl;

	vector<int>srcVect2(11);
	std::copy(srcVect.begin(), srcVect.end(), srcVect2.begin());//容器复制到容器
	for (auto const & child: srcVect2)
	{
		cout<<child<<" ";
	}
}

你可能感兴趣的:(STL copy 用法)