May 2017
Intermediate to advanced
590 pages
17h 18m
English
Use the following iterator adapters to insert new elements in a container:
std::vector<int> v{ 1,2,3,4,5 }; std::fill_n(std::back_inserter(v), 3, 0); // v={1,2,3,4,5,0,0,0}
std::list<int> l{ 1,2,3,4,5 }; std::fill_n(std::front_inserter(l), 3, 0); // l={0,0,0,1,2,3,4,5}
std::vector<int> v{ 1,2,3,4,5 }; std::fill_n(std::inserter(v, v.begin()), 3, 0); // v={0,0,0,1,2,3,4,5} std::list<int> l{ 1,2,3,4,5 }; auto it = l.begin(); ...Read now
Unlock full access