This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
[insert.iterators.general]
# 24 Iterators library [[iterators]](./#iterators)
## 24.5 Iterator adaptors [[predef.iterators]](predef.iterators#insert.iterators.general)
### 24.5.2 Insert iterators [[insert.iterators]](insert.iterators#general)
#### 24.5.2.1 General [insert.iterators.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L3779)
To make it possible to deal with insertion in the same way as writing into an array, a special kind of iterator
adaptors, called[*insert iterators*](#def:insert_iterators),
are provided in the library[.](#1.sentence-1)
With regular iterator classes,while (first != last) *result++ = *first++; causes a range [first, last)
to be copied into a range starting with result[.](#1.sentence-2)
The same code withresult being an insert iterator will insert corresponding elements into the container[.](#1.sentence-3)
This device allows all of the
copying algorithms in the library to work in the[*insert mode*](#def:insert_mode) instead of the [*regular overwrite*](#def:regular_overwrite) mode[.](#1.sentence-4)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L3798)
An insert iterator is constructed from a container and possibly one of its iterators pointing to where
insertion takes place if it is neither at the beginning nor at the end of the container[.](#2.sentence-1)
Insert iterators meet the requirements of output iterators[.](#2.sentence-2)
operator* returns the insert iterator itself[.](#2.sentence-3)
The assignmentoperator=(const T& x) is defined on insert iterators to allow writing into them, it insertsx right before where the insert iterator is pointing[.](#2.sentence-4)
In other words, an insert iterator is like a cursor pointing into the
container where the insertion takes place[.](#2.sentence-5)
back_insert_iterator inserts elements at the end of a container,front_insert_iterator inserts elements at the beginning of a container, andinsert_iterator inserts elements where the iterator points to in a container[.](#2.sentence-6)
back_inserter,front_inserter,
andinserter are three
functions making the insert iterators out of a container[.](#2.sentence-7)