Return type
Preincrement ++i X&
Postincrement i++ X
Expression semantics

Forward Iterator does not define any new expressions beyond those defined in Input Iterator. However, some of the restrictions described in Input Iterator are relaxed.

Name Expression Precondition Semantics Postcondition
Preincrement ++i i is dereferenceable i points to the next value i is dereferenceable or past-the-end. &i == &++i . If i == j , then ++i == + +j. [1]
Postincrement i++ i is dereferenceable Equivalent to {X tmp = i; ++i; return tmp;} i is dereferenceable or past-the-end. [1]
Complexity guarantees

The complexity of operations on Forward Iterators is guaranteed to be amortized constant time.

Models

• T*

• hash_set<T>::iterator

Notes

[1] The restrictions described in Input Iterator have been removed. Incrementing a forward iterator does not invalidate copies of the old value and it is guaranteed that, if i and j are dereferenceable and i == j, then ++i == + +j. As a consequence of these two facts, it is possible to pass through the same Forward Iterator twice.

See also

Input Iterator, Output Iterator, Bidirectional Iterator, Random Access Iterator, Iterator overview

Bidirectional Iterator

Category: iterators

Component type: concept

Description

A Bidirectional Iterator is an iterator that can be both incremented and decremented. The requirement that a Bidirectional Iterator can be decremented is the only thing that distinguishes Bidirectional Iterators from Forward Iterators.

Refinement of

Forward Iterator

Associated types

The same as for Forward Iterator.

Notation

X A type that is a model of Bidirectional Iterator

T The value type of X

i, j Object of type X

t Object of type T

Valid expressions

In addition to the expressions defined in Forward Iterator, the following expressions must be valid.

Name  Expression Return type
Predecrement --i X&
Postdecrement i-- X
Expression Semantics

Semantics of an expression is defined only where it is not defined in Forward Iterator.

Name Expression
Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

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

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