These members are not defined in the Output Iterator requirements, but are specific to ostream_iterator.

Function Description
ostream_iterator(ostream& s) Creates an ostream_iterator such that assignment of t through it is equivalent to s << t.
ostream_iterator(ostream& s, const char* delim) Creates an ostream_iterator such that assignment of t through it is equivalent to s << t << delim.
Notes

[1] Note how assignment through an ostream_iterator is implemented. In general, unary operator* must be defined so that it returns a proxy object, where the proxy object defines operator= to perform the output operation. In this case, for the sake of simplicity, the proxy object is the ostream_iterator itself. That is, *i simply returns i , and *i = t is equivalent to i = t. You should not, however, rely on this behavior. It is an implementation detail, and it is not guaranteed to remain the same in future versions.

See also

istream_iterator, Output Iterator, Input Iterator.

front_insert_iterator<FrontInsertionSequence>

Categories: iterators, adaptors

Component type: type

Description

Front_insert_iterator is an iterator adaptor that functions as an Output Iterator: assignment through a front_insert_iterator inserts an object before the first element of a Front Insertion Sequence. [1] [2]

Example

list<int> L;

L.push_front(3);

front_insert_iterator<list<int> > ii(L);

*ii++ = 0;

*ii++ = 1;

*ii++ = 2;

copy(L.begin(), L.end(), ostream_iterator<int>(cout, ' '));

// The values that are printed are 2 1 0 3

Definition

Defined in the standard header iterator, and in the nonstandard backward-compatibility header iterator.h.

Template parameters
Parameter Description
FrontInsertionSequence The type of Front Insertion Sequence into which values will be inserted.
Model of

Output Iterator. A front insert iterator's set of value types (as defined in the Output Iterator requirements) consists of a single type: FrontInsertionSequence::value_type.

Type requirements

The template parameter FrontInsertionSequence must be a Front Insertion Sequence.

Public base classes

None.

Members
Member Where defined Description
front_insert_iterator(FrontInsertionSequence&) front_insert_iterator See below.
front_insert_iterator(const front_insert_iterator&) Trivial Iterator The copy constructor
front_insert_iterator& operator=(const front_insert_iterator&) Trivial Iterator The assignment operator
front_insert_iterator& operator*() Output Iterator Used to implement the output iterator expression *i = x. [3]
Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату