[c++][stl] std::vector Copy 방법

// copy() 를 이용한 복사

 

destVector.resize((int)(sourceVector.size()));

std::copy( sourceVector.begin(), sourceVector.end(), destVector.begin() );

std::copy( sourceVector.begin() + 2, sourceVector.begin() + 5, destVector.begin() );
// assign() 을 이용한 복사 

 

destVector.clear();

destVector.assign( sourceVector.begin(), sourceVector.end() ); // 전체 복사

destVector.assign( sourceVector.begin() + 1, sourceVector.begin() + 4 );