Created
March 31, 2016 17:21
-
-
Save steveobbayi/2742e6ff8401512f38dcabe255935f11 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vector<int> v1 = {3,4}; | |
vector<int> v2 = {1,2,5,6}; | |
// Get the position of "5" in the vector and store it in i | |
vector<int>::iterator i = find(v2.begin(), v2.end(), 5); | |
//Now we use the insert iterator to add all elements in | |
//v1 to v2 at the position of i | |
insert_iterator<vector<int>> ins_i(v2, i); | |
copy(v1.begin(), v1.end(), ins_i); | |
// v2 is now {1,2,3,4,5,6} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment