Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: C++
Expertise: Intermediate
Jan 13, 1999



Application Security Testing: An Integral Part of DevOps

The Copy Algorithm

The Standard Library provides a generic copy function, which can be used to copy a sequence of objects to a specified target. The first and the second arguments of copy() are const iterators that mark the sequence's beginning and its end, respectively. The third argument points to a container into which the sequence is copied. The following example demonstrates how to copy the elements of a list into a vector:
#include <algorithm>
using namespace std;

void main() 
  list<int> li; vector <int> vi;
  li.push_back(1);   // fill the list with elements
  vi.reserve( li.size() );  // a vector must make room for copied elements in advance 
  copy (li.begin(), li.end(), vi.begin() );  //copy list elements into vector, starting at vector's beginning
Danny Kalev
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date