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

The MPL Reference Manual: Forward Sequence
Front Page / Sequences / Concepts / Forward Sequence

Forward Sequence

Description

A Forward Sequence is an MPL concept representing a compile-time sequence of elements. Sequence elements are types, and are accessible through Iterators. The begin and end metafunctions provide iterators delimiting the range of the sequence elements. A sequence guarantees that its elements are arranged in a definite, but possibly unspecified, order. Every MPL sequence is a Forward Sequence.

Definitions

  • The size of a sequence is the number of elements it contains. The size is a nonnegative number.
  • A sequence is empty if its size is zero.

Expression requirements

For any Forward Sequence s the following expressions must be valid:

Expression Type Complexity
begin::type Forward Iterator Amortized constant time
end::type Forward Iterator Amortized constant time
size::type Integral Constant Unspecified
empty::type Boolean Integral Constant Constant time
front::type Any type Amortized constant time

Expression semantics

Expression Semantics
begin::type An iterator to the first element of the sequence; see begin.
end::type A past-the-end iterator to the sequence; see end.
size::type The size of the sequence; see size.
empty::type A boolean Integral Constant c such that c::value == true if and only if the sequence is empty; see empty.
front::type The first element in the sequence; see front.

Invariants

For any Forward Sequence s the following invariants always hold:

  • [begin::type, end::type) is always a valid range.
  • An algorithm that iterates through the range [begin::type, end::type) will pass through every element of s exactly once.
  • begin::type is identical to end::type if and only if s is empty.
  • Two different iterations through s will access its elements in the same order.