Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

PrevUpHomeNext

Random Access Sequence

Description

A Random Access Sequence is a Bidirectional Sequence whose iterators model Random Access Iterator. It guarantees constant time access to arbitrary sequence elements.

Refinement of

Bidirectional Sequence

Notation

s

A Random Access Sequence

S

A Random Access Sequence type

M

An MPL integral constant

N

An integral constant

o

An arbitrary object

e

A Sequence element

Valid Expressions

In addition to the requirements defined in Bidirectional Sequence, for any Random Access Sequence the following must be met:

Expression

Return type

Type Requirements

Runtime Complexity

begin(s)

Random Access Iterator

Constant

end(s)

Random Access Iterator

Constant

at_c<N>(s)

Any type

Constant

at_c<N>(s) = o

Any type

s is mutable and e = o, where e is the N-th element from the beginning of the sequence, is a valid expression.

Constant

at<M>(s)

Any type

Constant

at<M>(s) = o

Any type

s is mutable and e = o, where e is the M-th element from the beginning of the sequence, is a valid expression.

Constant

Result Type Expressions

Expression

Compile Time Complexity

result_of::begin<S>::type

Amortized constant time

result_of::end<S>::type

Amortized constant time

result_of::at<S, M>::type

Amortized constant time

result_of::at_c<S, N>::type

Amortized constant time

result_of::value_at<S, M>::type

Amortized constant time

result_of::value_at_c<S, N>::type

Amortized constant time

[Note] Note

result_of::at<S, M> returns the actual type returned by at<M>(s). In most cases, this is a reference. Hence, there is no way to know the exact element type using result_of::at<S, M>.The element at M may actually be a reference to begin with. For this purpose, you can use result_of::value_at<S, M> (Note that, result_of::value_at_c<S, N> is a counterpart of result_of::at_c<S, N> as well).

Expression Semantics

The semantics of an expression are defined only where they differ from, or are not defined in Bidirectional Sequence.

Expression

Semantics

at<M>(s)

The Mth element from the beginning of the sequence; see at.

at_c<N>(s)

The Nth element from the beginning of the sequence; see at_c.

Models

PrevUpHomeNext