Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

std::copy

// suppose you want to copy list to a vector 
// instead of using a for loop, You can use to the std:: algorithm
// to keep the code cleaner
std::list <int> list;
std::vector <int> vector;

/// WARNING --- 
/// YOU MUST ALLOCATE ENOUGH SPACE IN THE CONTAINER BEFORE COPY
vector.resize (list.size());
std::copy (list.begin(), list.end(), vector.begin());
Source by www.cplusplus.com #
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
7+6 =