Advertisement Jump to content
Sign in to follow this  
dotproduct

Appending a vector to another vector

This topic is 4984 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

If I have two std::vector<int>, a and b, is there a good way to copy the elements of b into a, so that a would contain elements of a + elements of b? Another way than just looping through b, and push_back elements to a?

Share this post


Link to post
Share on other sites
Advertisement
There's also insert, although I suppose that's a little less general than jdhardy's approach.

vector<int> a;
vector<int> b;
a.insert(a.end(), b.begin(), b.end());

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!