• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. Copyright David Abrahams 2006. Distributed under the Boost
2.. Software License, Version 1.0. (See accompanying
3.. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4
5Bidirectional Traversal Concept
6...............................
7
8A class or built-in type ``X`` models the *Bidirectional Traversal*
9concept if, in addition to ``X`` meeting the requirements of Forward
10Traversal Iterator, the following expressions are valid and respect
11the stated semantics.
12
13+--------------------------------------------------------------------------------------+
14|Bidirectional Traversal Iterator Requirements (in addition to Forward Traversal       |
15|Iterator)                                                                             |
16+--------------------------------+-------------------------------+---------------------+
17|Expression                      |Return Type                    |Assertion/Semantics /|
18|                                |                               |Pre-/Post-condition  |
19+================================+===============================+=====================+
20|``--r``                         |``X&``                         |pre: there exists    |
21|                                |                               |``s`` such that ``r  |
22|                                |                               |== ++s``.  post:     |
23|                                |                               |``s`` is             |
24|                                |                               |dereferenceable.     |
25|                                |                               |``--(++r) == r``.    |
26|                                |                               |``--r == --s``       |
27|                                |                               |implies ``r ==       |
28|                                |                               |s``. ``&r == &--r``. |
29+--------------------------------+-------------------------------+---------------------+
30|``r--``                         |convertible to ``const X&``    |::                   |
31|                                |                               |                     |
32|                                |                               | {                   |
33|                                |                               |   X tmp = r;        |
34|                                |                               |   --r;              |
35|                                |                               |   return tmp;       |
36|                                |                               | }                   |
37+--------------------------------+-------------------------------+---------------------+
38|``iterator_traversal<X>::type`` |Convertible to                 |                     |
39|                                |``bidirectional_traversal_tag``|                     |
40|                                |                               |                     |
41+--------------------------------+-------------------------------+---------------------+
42