BidirectionalTraversal.rst 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. Bidirectional Traversal Concept
  5. ...............................
  6. A class or built-in type ``X`` models the *Bidirectional Traversal*
  7. concept if, in addition to ``X`` meeting the requirements of Forward
  8. Traversal Iterator, the following expressions are valid and respect
  9. the stated semantics.
  10. +--------------------------------------------------------------------------------------+
  11. |Bidirectional Traversal Iterator Requirements (in addition to Forward Traversal |
  12. |Iterator) |
  13. +--------------------------------+-------------------------------+---------------------+
  14. |Expression |Return Type |Assertion/Semantics /|
  15. | | |Pre-/Post-condition |
  16. +================================+===============================+=====================+
  17. |``--r`` |``X&`` |pre: there exists |
  18. | | |``s`` such that ``r |
  19. | | |== ++s``. post: |
  20. | | |``s`` is |
  21. | | |dereferenceable. |
  22. | | |``--(++r) == r``. |
  23. | | |``--r == --s`` |
  24. | | |implies ``r == |
  25. | | |s``. ``&r == &--r``. |
  26. +--------------------------------+-------------------------------+---------------------+
  27. |``r--`` |convertible to ``const X&`` |:: |
  28. | | | |
  29. | | | { |
  30. | | | X tmp = r; |
  31. | | | --r; |
  32. | | | return tmp; |
  33. | | | } |
  34. +--------------------------------+-------------------------------+---------------------+
  35. |``iterator_traversal<X>::type`` |Convertible to | |
  36. | |``bidirectional_traversal_tag``| |
  37. | | | |
  38. +--------------------------------+-------------------------------+---------------------+