Книга: Standard Template Library Programmer
fill
Разделы на этой странице:
fill
Category: algorithms
Component type: function
Prototype
template <class ForwardIterator, class T>
void fill(ForwardIterator first, ForwardIterator last, const T& value);
Description
Fill assigns the value value to every element in the range [first, last). That is, for every iterator i in [first, last), it performs the assignment *i = value.
Definition
Defined in the standard header algorithm, and in the nonstandard backward-compatibility header algo.h.
Requirements on types
• ForwardIterator is a model of Forward Iterator . [1]
• ForwardIterator is mutable.
• T is a model of Assignable.
• T is convertible to Forward Iterator's value type.
Preconditions
• [first, last) is a valid range.
Complexity
Linear. Fill performs exactly last – first assignments.
Example
vector <double> V(4);
fill(V.begin(), V.end(), 137);
assert(V[0] == 137 && V[1] == 137 && V[2] == 137 && V[3] == 137);
Notes
[1] The reason that fill requires its argument to be a mutable forward iterator, rather than merely an output iterator, is that it uses a range [first, last) of iterators. There is no sensible way to describe a range of output iterators, because it is impossible to compare two output iterators for equality. The fill_n algorithm does have an interface that permits use of an output iterator.
See also
copy, fill_n, generate, generate_n, iota
- 7.2.5 Using Fill Prefixes
- Создание собственных методов DrawPie и FillPie
- fill_n
- uninitialized_fill
- uninitialized_fill_n
- 1.7.2 Letting Emacs Fill in the Blanks
- 2.7.3 Turning On Text Mode and Auto-Fill Mode Automatically
- 7.2.3 Filling Indented Paragraphs
- Table E-4. Text filling and reformatting commands
- Команда Fill (Заливка)
- 11.4. Fill Layer (Слой заливки) и Adjustment Layer (Слой настройки)
- Информация страниц данных