1 .. Iterators/Concepts//Forward Iterator |10
9 A |Forward Iterator| ``i`` is a type that represents a positional reference
10 to an element of a |Forward Sequence|. It allows to access the element through
11 a dereference operation, and provides a way to obtain an iterator to
12 the next element in a sequence.
14 .. A [Forward Iterator] guarantees a linear traversal over
21 * An iterator can be `dereferenceable`, meaning that ``deref<i>::type``
22 is a well-defined expression.
24 * An iterator is `past-the-end` if it points beyond the last element of a
25 sequence; past-the-end iterators are non-dereferenceable.
27 * An iterator ``i`` is `incrementable` if there is a "next" iterator, that
28 is, if ``next<i>::type`` expression is well-defined; past-the-end iterators are
31 * Two iterators into the same sequence are `equivalent` if they have the same
34 * An iterator ``j`` is `reachable` from an iterator ``i`` if , after recursive
35 application of ``next`` metafunction to ``i`` a finite number of times, ``i``
36 is equivalent to ``j``.
38 * The notation [``i``,\ ``j``) refers to a `range` of iterators beginning with
39 ``i`` and up to but not including ``j``.
41 * The range [``i``,\ ``j``) is a `valid range` if ``j`` is reachable from ``i``.
44 Expression requirements
45 -----------------------
47 +-----------------------+-------------------------------------------+---------------------------+
48 | Expression | Type | Complexity |
49 +=======================+===========================================+===========================+
50 | ``deref<i>::type`` | Any type | Amortized constant time |
51 +-----------------------+-------------------------------------------+---------------------------+
52 | ``next<i>::type`` | |Forward Iterator| | Amortized constant time |
53 +-----------------------+-------------------------------------------+---------------------------+
54 | ``i::category`` | |Integral Constant|, convertible | Constant time |
55 | | to ``forward_iterator_tag`` | |
56 +-----------------------+-------------------------------------------+---------------------------+
65 typedef deref<i>::type j;
68 ``i`` is dereferenceable
71 ``j`` is identical to the type of the pointed element
74 .. ..........................................................................
78 typedef next<i>::type j;
81 ``i`` is incrementable
84 ``j`` is the next iterator in a sequence
87 ``j`` is dereferenceable or past-the-end
90 .. ..........................................................................
94 typedef i::category c;
97 ``c`` is identical to the iterator's category tag
103 For any forward iterators ``i`` and ``j`` the following invariants always hold:
105 * ``i`` and ``j`` are equivalent if and only if they are pointing to the same
108 * If ``i`` is dereferenceable, and ``j`` is equivalent to ``i``, then ``j`` is
109 dereferenceable as well.
111 * If ``i`` and ``j`` are equivalent and dereferenceable, then ``deref<i>::type``
112 and ``deref<j>::type`` are identical.
114 * If ``i`` is incrementable, and ``j`` is equivalent to ``i``, then ``j`` is
115 incrementable as well.
117 * If ``i`` and ``j`` are equivalent and incrementable, then ``next<i>::type``
118 and ``next<j>::type`` are equivalent.
124 |Iterators|, |Bidirectional Iterator|, |Forward Sequence|, |deref|, |next|
127 .. copyright:: Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams
128 Distributed under the Boost Software License, Version 1.0. (See accompanying
129 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)