Advertisement Jump to content
Sign in to follow this  
mrmrcoleman

Is this is good idea? STL.

This topic is 4892 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Would this work.. vector<int> Vec1; vector<int> Vec2; Assign various values into Vec1 here.. Vec2 = Vec1. Would this copy all the elements for me, or do I have to loop through and do it manually? Mark

Share this post


Link to post
Share on other sites
Advertisement
How can I copy thee? Let me count the ways:
std::vector< int > vector1;
std::vector< int > vector2;
fill(vector1);

// copy assignment operator
vector2 = vector1;

// assign member function
vector2.assign(vector1.begin(), vector1.end());

// insert member function
vector2.clear();
vector2.insert(vector2.end(), vector1.begin(), vector1.end());

// std::copy
vector2.clear();
std::copy(vector1.begin(), vector1.end(), std::back_inserter(vector2));

Enigma

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!