August 2012
Intermediate to advanced
976 pages
30h 17m
English
The insert members (Table 11.4 (overleaf)) add one element or a range of elements. Because map and set (and the corresponding unordered types) contain unique keys, inserting an element that is already present has no effect:
vector<int> ivec = {2,4,6,8,2,4,6,8}; // ivec has eight elementsset<int> set2; // empty setset2.insert(ivec.cbegin(), ivec.cend()); // set2 has four elementsset2.insert({1,3,5,7,1,3,5,7}); // set2 now has eight elements
Table 11.4. Associative Container insert Operations
The versions of insert that take a pair of iterators or an initializer list work similarly to the ...