24.5 Inserters
- Algorithms like fill, copy, or generate
are normally used to overwrite contents
- inserter is an adapter, wraps iterator
- Inserts values into new locations
- back_inserter calls push_back when a value is assigned
- Create an empty list b, then copy a into it:
list<int> b;
copy(a.begin(), a.end(), back_inserter(b));
- copy inserts values, not overwrites
prev
|top
|next