Fixup some tables. Restore the equivalence between readable

single-pass iterator and input iterator by restricting the allowed
return type of r++.


[SVN r19091]
This commit is contained in:
Dave Abrahams
2003-07-12 20:16:49 +00:00
parent dfc43d81cf
commit b0aef5a66d

View File

@ -42,17 +42,18 @@ requirements that address value access sneak in at various places. The
following table gives a summary of the current value access following table gives a summary of the current value access
requirements in the iterator categories. requirements in the iterator categories.
+------------------------+-------------------------------------------------------------------------+ +------------------------+-----------------------------------------------------+
| Output Iterator | ``*i = a`` | |Output Iterator |``*i = a`` |
+------------------------+-------------------------------------------------------------------------+ +------------------------+-----------------------------------------------------+
| Input Iterator | ``*i`` is convertible to ``T`` | |Input Iterator |``*i`` is convertible to ``T`` |
+------------------------+-------------------------------------------------------------------------+ +------------------------+-----------------------------------------------------+
| Forward Iterator | ``*i`` is ``T&`` (or ``const T&`` once | |Forward Iterator |``*i`` is ``T&`` (or ``const T&`` once `issue 200`_ |
| | `issue 200`_ is resolved) | | |is resolved) |
+------------------------+-------------------------------------------------------------------------+ +------------------------+-----------------------------------------------------+
| Random Access Iterator | ``i[n]`` is convertible to ``T`` (also ``i[n] = t`` is required for | |Random Access Iterator |``i[n]`` is convertible to ``T`` (also ``i[n] = t`` |
| | mutable iterators once `issue 299`_ is resolved) | | |is required for mutable iterators once `issue 299`_ |
+------------------------+-------------------------------------------------------------------------+ | |is resolved) |
+------------------------+-----------------------------------------------------+
.. _issue 200: http://anubis.dkuug.dk/JTC1/SC22/WG21/docs/lwg-active.html#200 .. _issue 200: http://anubis.dkuug.dk/JTC1/SC22/WG21/docs/lwg-active.html#200
.. _issue 299: http://anubis.dkuug.dk/JTC1/SC22/WG21/docs/lwg-active.html#299 .. _issue 299: http://anubis.dkuug.dk/JTC1/SC22/WG21/docs/lwg-active.html#299
@ -135,29 +136,36 @@ following lists the proposed changes to the type requirements of
algorithms. algorithms.
Forward Iterator -> Forward Traversal Iterator and Readable Iterator Forward Iterator -> Forward Traversal Iterator and Readable Iterator
``find_end, adjacent_find, search, search_n, rotate_copy, lower_bound, upper_bound, equal_range, binary_search, min_element, max_element`` ``find_end, adjacent_find, search, search_n, rotate_copy, lower_bound, upper_bound, equal_range, binary_search, min_element, max_element``
Forward Iterator (1) -> Single Pass Iterator and Readable Iterator Forward Iterator (1) -> Single Pass Iterator and Readable Iterator
Forward Iterator (2) -> Forward Traversal Iterator and Readable Iterator Forward Iterator (2) -> Forward Traversal Iterator and Readable Iterator
``find_first_of`` ``find_first_of``
Forward Iterator -> Readable Iterator and Writable Iterator Forward Iterator -> Readable Iterator and Writable Iterator
``iter_swap`` ``iter_swap``
Forward Iterator -> Single Pass Iterator and Writable Iterator Forward Iterator -> Single Pass Iterator and Writable Iterator
``fill, generate`` ``fill, generate``
Forward Iterator -> Forward Traversal Iterator and Swappable Iterator Forward Iterator -> Forward Traversal Iterator and Swappable Iterator
``rotate`` ``rotate``
Forward Iterator (1) -> Swappable Iterator and Single Pass Iterator Forward Iterator (1) -> Swappable Iterator and Single Pass Iterator
Forward Iterator (2) -> Swappable Iterator and Incrementable Iterator Forward Iterator (2) -> Swappable Iterator and Incrementable Iterator
``swap_ranges`` ``swap_ranges``
Forward Iterator -> Forward Traversal Iterator and Readable Iterator and Writable Iterator Forward Iterator -> Forward Traversal Iterator and Readable Iterator and Writable Iterator
``remove, remove_if, unique`` ``remove, remove_if, unique``
Forward Iterator -> Single Pass Iterator and Readable Iterator and Writable Iterator Forward Iterator -> Single Pass Iterator and Readable Iterator and Writable Iterator
``replace, replace_if`` ``replace, replace_if``
Bidirectional Iterator -> Bidirectional Traversal Iterator and Swappable Iterator Bidirectional Iterator -> Bidirectional Traversal Iterator and Swappable Iterator
@ -168,6 +176,7 @@ Bidirectional Iterator -> Bidirectional Traversal Iterator and Readable and Swap
Bidirectional Iterator (1) -> Bidirectional Traversal Iterator and Readable Iterator, Bidirectional Iterator (1) -> Bidirectional Traversal Iterator and Readable Iterator,
Bidirectional Iterator (2) -> Bidirectional Traversal Iterator and Writable Iterator Bidirectional Iterator (2) -> Bidirectional Traversal Iterator and Writable Iterator
``copy_backwards`` ``copy_backwards``
Bidirectional Iterator -> Bidirectional Traversal Iterator and Swappable Iterator and Readable Iterator Bidirectional Iterator -> Bidirectional Traversal Iterator and Swappable Iterator and Readable Iterator
@ -313,22 +322,25 @@ for the value type ``T`` if the following expressions are valid and
respect the stated semantics. ``U`` is the type of any specified respect the stated semantics. ``U`` is the type of any specified
member of type ``T``. member of type ``T``.
+------------------------------------------------------------------------------------------------------------------------------------------------------------+ +-------------------------------------------------------------------------------------------------------------------+
| Readable Iterator Requirements (in addition to CopyConstructible) | |Readable Iterator Requirements (in addition to CopyConstructible) |
+--------------------------------------+---------------------------------------------------+-----------------------------------------------------------------+ +--------------------------------------+----------------------------------+-----------------------------------------+
| Expression | Return Type | Assertion/Note/Precondition/Postcondition | |Expression |Return Type |Assertion/Note/Precondition/Postcondition|
+======================================+===================================================+=================================================================+ +======================================+==================================+=========================================+
| ``iterator_traits<X>::value_type`` | ``T`` | Any non-reference, non-cv-qualified type | |``iterator_traits<X>::value_type`` |``T`` |Any non-reference, non-cv-qualified type |
+--------------------------------------+---------------------------------------------------+-----------------------------------------------------------------+ +--------------------------------------+----------------------------------+-----------------------------------------+
| ``iterator_traits<X>::reference`` | Convertible to ``iterator_traits<X>::value_type`` | | |``iterator_traits<X>::reference`` |Convertible to | |
+--------------------------------------+---------------------------------------------------+-----------------------------------------------------------------+ | |``iterator_traits<X>::value_type``| |
| ``access_category<X>::type`` | Convertible to ``readable_iterator_tag`` | | +--------------------------------------+----------------------------------+-----------------------------------------+
+--------------------------------------+---------------------------------------------------+-----------------------------------------------------------------+ |``access_category<X>::type`` |Convertible to | |
| ``*a`` | ``iterator_traits<X>::reference`` | pre: ``a`` is dereferenceable. If ``a == b`` then | | |``readable_iterator_tag`` | |
| | | ``*a`` is equivalent to ``*b`` | +--------------------------------------+----------------------------------+-----------------------------------------+
+--------------------------------------+---------------------------------------------------+-----------------------------------------------------------------+ |``*a`` |``iterator_traits<X>::reference`` |pre: ``a`` is dereferenceable. If ``a == |
| ``a->m`` | ``U&`` | pre: ``(*a).m`` is well-defined. Equivalent to ``(*a).m`` | | | |b`` then ``*a`` is equivalent to ``*b`` |
+--------------------------------------+---------------------------------------------------+-----------------------------------------------------------------+ +--------------------------------------+----------------------------------+-----------------------------------------+
|``a->m`` |``U&`` |pre: ``(*a).m`` is well-defined. |
| | |Equivalent to ``(*a).m`` |
+--------------------------------------+----------------------------------+-----------------------------------------+
.. _Writable Iterator: .. _Writable Iterator:
@ -350,16 +362,18 @@ semantics.
to have a meaningful value_type? If not, we need to use a to have a meaningful value_type? If not, we need to use a
different name from ``v`` in this table -DWA different name from ``v`` in this table -DWA
+------------------------------------------------------------------------------------------------------------------------------+ +---------------------------------------------------------------------------------------------+
| Writable Iterator Requirements (in addition to CopyConstructible) | |Writable Iterator Requirements (in addition to CopyConstructible) |
+--------------------------------------+------------------------------------------+--------------------------------------------+ +--------------------------------------+-------------------------+----------------------------+
| Expression | Return Type | Assertion/Note/Precondition/Postcondition | |Expression |Return Type |Precondition |
+======================================+==========================================+============================================+ +======================================+=========================+============================+
| ``access_category<X>::type`` | Convertible to ``writable_iterator_tag`` | | |``access_category<X>::type`` |Convertible to | |
+--------------------------------------+------------------------------------------+--------------------------------------------+ | |``writable_iterator_tag``| |
| ``*a = v`` | | .. ** pre: The type of ``v`` is in the set | +--------------------------------------+-------------------------+----------------------------+
| | | of value types of ``X`` | |``*a = v`` | |.. ** pre: The type of ``v``|
+--------------------------------------+------------------------------------------+--------------------------------------------+ | | | is in the set |
| | | of value types of ``X`` |
+--------------------------------------+-------------------------+----------------------------+
Swappable Iterators [lib.swappable.iterators] Swappable Iterators [lib.swappable.iterators]
@ -370,11 +384,11 @@ if the following expressions are valid and respect the stated
semantics. semantics.
+------------------------------------------------------------------------------------------------+ +------------------------------------------------------------------------------------------------+
| Swappable Iterator Requirements (in addition to CopyConstructible) | |Swappable Iterator Requirements (in addition to CopyConstructible) |
+------------------------------------+-------------+---------------------------------------------+ +------------------------------------+-------------+---------------------------------------------+
| Expression | Return Type | Assertion/Note/Precondition/Postcondition | |Expression |Return Type |Postcondition |
+====================================+=============+=============================================+ +====================================+=============+=============================================+
| ``iter_swap(a, b)`` | ``void`` | post: the pointed to values are exchanged | |``iter_swap(a, b)`` |``void`` |post: the pointed to values are exchanged |
+------------------------------------+-------------+---------------------------------------------+ +------------------------------------+-------------+---------------------------------------------+
[*Note:* An iterator that is a model of the *Readable* and *Writable Iterator* concepts [*Note:* An iterator that is a model of the *Readable* and *Writable Iterator* concepts
@ -387,16 +401,19 @@ Readable Lvalue Iterators [lib.readable.lvalue.iterators]
The *Readable Lvalue Iterator* concept adds the requirement that the The *Readable Lvalue Iterator* concept adds the requirement that the
``reference`` type be a reference to the value type of the iterator. ``reference`` type be a reference to the value type of the iterator.
+--------------------------------------------------------------------------------------------------------------------------------------------------+ +----------------------------------------------------------------------------------------------------------+
| Readable Lvalue Iterator Requirements (in addition to Readable Iterator) | |Readable Lvalue Iterator Requirements (in addition to Readable Iterator) |
+------------------------------------+-------------------------------------------------+-----------------------------------------------------------+ +------------------------------------+---------------------------------+-----------------------------------+
| Expression | Return Type | Assertion/Note/Precondition/Postcondition | |Expression |Return Type |Assertion |
+====================================+=================================================+===========================================================+ +====================================+=================================+===================================+
| ``iterator_traits<X>::reference`` | ``T&`` | ``T`` is *cv* ``iterator_traits<X>::value_type`` where | |``iterator_traits<X>::reference`` |``T&`` |``T`` is *cv* |
| | | *cv* is an optional cv-qualification | | | |``iterator_traits<X>::value_type`` |
+------------------------------------+-------------------------------------------------+-----------------------------------------------------------+ | | |where *cv* is an optional |
| ``access_category<X>::type`` | Convertible to ``readable_lvalue_iterator_tag`` | | | | |cv-qualification |
+------------------------------------+-------------------------------------------------+-----------------------------------------------------------+ +------------------------------------+---------------------------------+-----------------------------------+
|``access_category<X>::type`` |Convertible to | |
| |``readable_lvalue_iterator_tag`` | |
+------------------------------------+---------------------------------+-----------------------------------+
Writable Lvalue Iterators [lib.writable.lvalue.iterators] Writable Lvalue Iterators [lib.writable.lvalue.iterators]
@ -406,15 +423,17 @@ The *Writable Lvalue Iterator* concept adds the requirement that the
``reference`` type be a non-const reference to the value type of the ``reference`` type be a non-const reference to the value type of the
iterator. iterator.
+------------------------------------------------------------------------------------------------------------------------------------------------------+
| Writable Lvalue Iterator Requirements (in addition to Readable Lvalue Iterator) | +--------------------------------------------------------------------------------------+
+--------------------------------------+--------------------------------------------------+------------------------------------------------------------+ | Writable Lvalue Iterator Requirements (in addition to Readable Lvalue Iterator) |
| Expression | Return Type | Assertion/Note/Precondition/Postcondition | +--------------------------------------+-----------------------------------------------+
+======================================+==================================================+============================================================+ | Expression | Return Type |
| ``iterator_traits<X>::reference`` | ``iterator_traits<X>::value_type&`` | | +======================================+===============================================+
+--------------------------------------+--------------------------------------------------+------------------------------------------------------------+ |``iterator_traits<X>::reference`` |``iterator_traits<X>::value_type&`` |
| ``access_category<X>::type`` | Convertible to ``writable_lvalue_iterator_tag`` | | +--------------------------------------+-----------------------------------------------+
+--------------------------------------+--------------------------------------------------+------------------------------------------------------------+ |``access_category<X>::type`` |Convertible to ``writable_lvalue_iterator_tag``|
| | |
+--------------------------------------+-----------------------------------------------+
Iterator Traversal Concepts [lib.iterator.traversal] Iterator Traversal Concepts [lib.iterator.traversal]
@ -434,17 +453,17 @@ concept if the following expressions are valid and respect the stated
semantics. semantics.
+------------------------------------------------------------------------------------------------------------------------------------------------------+ +-------------------------------------------------------------------------------------------------------------------------+
| Incrementable Iterator Requirements (in addition to Assignable, Copy Constructible) | |Incrementable Iterator Requirements (in addition to Assignable, Copy Constructible) |
+--------------------------------------+--------------------------------------------------+------------------------------------------------------------+ +--------------------------------+---------------------------------------------+------------------------------------------+
| Expression | Return Type | Assertion/Note/Precondition/Postcondition | |Expression |Return Type |Assertion/Semantics |
+======================================+==================================================+============================================================+ +================================+=============================================+==========================================+
| ``++r`` | ``X&`` | ``&r == &++r`` | |``++r`` |``X&`` |``&r == &++r`` |
+--------------------------------------+--------------------------------------------------+------------------------------------------------------------+ +--------------------------------+---------------------------------------------+------------------------------------------+
| ``r++`` | convertible to ``const X&`` | ``{ X tmp = r; ++r; return tmp; }`` | |``r++`` |``X`` |``{ X tmp = r; ++r; return tmp; }`` |
+--------------------------------------+--------------------------------------------------+------------------------------------------------------------+ +--------------------------------+---------------------------------------------+------------------------------------------+
| ``traversal_category<X>::type`` | | Convertible to ``incrementable_iterator_tag`` | |``traversal_category<X>::type`` |Convertible to ``incrementable_iterator_tag``| |
+--------------------------------------+--------------------------------------------------+------------------------------------------------------------+ +--------------------------------+---------------------------------------------+------------------------------------------+
Single Pass Iterators [lib.single.pass.iterators] Single Pass Iterators [lib.single.pass.iterators]
@ -454,19 +473,24 @@ A class or built-in type ``X`` models the *Single Pass Iterator*
concept if the following expressions are valid and respect the stated concept if the following expressions are valid and respect the stated
semantics. semantics.
+------------------------------------------------------------------------------------------------------------------------------------------------------+
| Single Pass Iterator Requirements (in addition to Incrementable Iterator and Equality Comparable) | +--------------------------------------------------------------------------------------------------------+
+----------------------------------+-------------------------+-----------------------------------------------------------------------------------------+ |Single Pass Iterator Requirements (in addition to Incrementable Iterator and Equality Comparable) |
| Expression | Return Type | Assertion/Note/Precondition/Postcondition/Semantics | +----------------------------------+----------------------------+----------------------------------------+
+==================================+=========================+=========================================================================================+ |Expression |Return Type |Assertion/Semantics/Pre-/Post-condition |
| ``++r`` | ``X&`` | pre: ``r`` is dereferenceable; post: ``r`` is dereferenceable or ``r`` is past-the-end | +==================================+============================+========================================+
+----------------------------------+-------------------------+-----------------------------------------------------------------------------------------+ |``++r`` |``X&`` |pre: ``r`` is dereferenceable; post: |
| ``a == b`` | convertible to ``bool`` | ``==`` is an equivalence relation over its domain | | | |``r`` is dereferenceable or ``r`` is |
+----------------------------------+-------------------------+-----------------------------------------------------------------------------------------+ | | |past-the-end |
| ``a != b`` | convertible to ``bool`` | ``!(a == b)`` | +----------------------------------+----------------------------+----------------------------------------+
+----------------------------------+-------------------------+-----------------------------------------------------------------------------------------+ |``a == b`` |convertible to ``bool`` |``==`` is an equivalence relation over |
| ``traversal_category<X>::type`` | | Convertible to ``single_pass_iterator_tag`` | | | |its domain |
+----------------------------------+-------------------------+-----------------------------------------------------------------------------------------+ +----------------------------------+----------------------------+----------------------------------------+
|``a != b`` |convertible to ``bool`` |``!(a == b)`` |
+----------------------------------+----------------------------+----------------------------------------+
|``traversal_category<X>::type`` |Convertible to | |
| |``single_pass_iterator_tag``| |
+----------------------------------+----------------------------+----------------------------------------+
Forward Traversal Iterators [lib.forward.traversal.iterators] Forward Traversal Iterators [lib.forward.traversal.iterators]
@ -476,19 +500,24 @@ A class or built-in type ``X`` models the *Forward Traversal Iterator*
concept if the following expressions are valid and respect the stated concept if the following expressions are valid and respect the stated
semantics. semantics.
+----------------------------------------------------------------------------------------------------------------------------------+ +------------------------------------------------------------------------------------------------------+
| Forward Traversal Iterator Requirements (in addition to Single Pass Iterator) | |Forward Traversal Iterator Requirements (in addition to Single Pass Iterator) |
+------------------------------------------+--------------+------------------------------------------------------------------------+ +---------------------------------------+-------------------------------------+------------------------+
| Expression | Return Type | Assertion/Note/Precondition/Postcondition/Semantics | |Expression |Return Type |Assertion/Note |
+==========================================+==============+========================================================================+ +=======================================+=====================================+========================+
| ``X u;`` | ``X&`` | ``note: u may have a singular value.`` | |``X u;`` |``X&`` |``note: u may have a |
+------------------------------------------+--------------+------------------------------------------------------------------------+ | | |singular value.`` |
| ``++r`` | ``X&`` | ``r == s`` and ``r`` is dereferenceable implies ``++r == ++s.`` | +---------------------------------------+-------------------------------------+------------------------+
+------------------------------------------+--------------+------------------------------------------------------------------------+ |``++r`` |``X&`` |``r == s`` and ``r`` is |
| ``iterator_traits<X>::difference_type`` | | A signed integral type representing the distance between iterators | | | |dereferenceable implies |
+------------------------------------------+--------------+------------------------------------------------------------------------+ | | |``++r == ++s.`` |
| ``traversal_category<X>::type`` | | Convertible to ``forward_traversal_iterator_tag`` | +---------------------------------------+-------------------------------------+------------------------+
+------------------------------------------+--------------+------------------------------------------------------------------------+ |``iterator_traits<X>::difference_type``|A signed integral type representing | |
| |the distance between iterators | |
+---------------------------------------+-------------------------------------+------------------------+
|``traversal_category<X>::type`` |Convertible to | |
| |``forward_traversal_iterator_tag`` | |
+---------------------------------------+-------------------------------------+------------------------+
Bidirectional Traversal Iterators [lib.bidirectional.traversal.iterators] Bidirectional Traversal Iterators [lib.bidirectional.traversal.iterators]
@ -498,23 +527,25 @@ A class or built-in type ``X`` models the *Bidirectional Traversal
Iterator* concept if the following expressions are valid and respect Iterator* concept if the following expressions are valid and respect
the stated semantics. the stated semantics.
+-------------------------------------------------------------------------------------------------------------+ +----------------------------------------------------------------------------------------------------------------+
|Bidirectional Traversal Iterator Requirements (in addition to Forward Traversal Iterator) | |Bidirectional Traversal Iterator Requirements (in addition to Forward Traversal Iterator) |
+-----------------------------------------+-------------+-----------------------------------------------------+ +-------------------------------+----------------------------------------+---------------------------------------+
| Expression | Return Type | Assertion/Note/Precondition/Postcondition/Semantics | |Expression |Return Type |Assertion/Semantics/Pre-/Post-condition|
+=========================================+=============+=====================================================+ +===============================+========================================+=======================================+
| ``--r`` | ``X&`` |pre: there exists ``s`` such that ``r == ++s``. | |``--r`` |``X&`` |pre: there exists ``s`` such that ``r |
| | |post: ``s`` is dereferenceable. ``--(++r) == r``. | | | |== ++s``. post: ``s`` is |
| | |``--r == --s`` implies ``r == s``. ``&r == &--r``. | | | |dereferenceable. ``--(++r) == r``. |
+-----------------------------------------+-------------+-----------------------------------------------------+ | | |``--r == --s`` implies ``r == s``. ``&r|
|``r--`` |convertible |``{ X tmp = r; --r; return tmp; }`` | | | |== &--r``. |
| |to ``const | | +-------------------------------+----------------------------------------+---------------------------------------+
| |X&`` | | |``r--`` |convertible to ``const X&`` |``{ X tmp = r; --r; return tmp; }`` |
+-----------------------------------------+-------------+-----------------------------------------------------+ | | | |
| ``traversal_category<X>::type`` | | Convertible to | | | | |
| | | ``bidirectional_traversal_iterator_tag`` | +-------------------------------+----------------------------------------+---------------------------------------+
| | | | |``traversal_category<X>::type``|Convertible to | |
+-----------------------------------------+-------------+-----------------------------------------------------+ | |``bidirectional_traversal_iterator_tag``| |
| | | |
+-------------------------------+----------------------------------------+---------------------------------------+
Random Access Traversal Iterators [lib.random.access.traversal.iterators] Random Access Traversal Iterators [lib.random.access.traversal.iterators]
@ -526,51 +557,56 @@ the stated semantics. In the table below, ``Distance`` is
``iterator_traits<X>::difference_type`` and ``n`` represents a ``iterator_traits<X>::difference_type`` and ``n`` represents a
constant object of type ``Distance``. constant object of type ``Distance``.
+--------------------------------------------------------------------------------------------------------------------------------------------+ +------------------------------------------------------------------------------------------------------------------------------+
| Random Access Traversal Iterator Requirements (in addition to Bidirectional Traversal Iterator) | |Random Access Traversal Iterator Requirements (in addition to Bidirectional Traversal Iterator) |
+--------------------------------+---------------------------------------+--------------------------+----------------------------------------+ +--------------------------------+----------------------------------------+----------------------+-----------------------------+
| Expression | Return Type | Operational Semantics | Assertion/Note/Pre/Post-condition | | Expression |Return Type | Operational Semantics| Assertion/Precondition |
+================================+=======================================+==========================+========================================+ +================================+========================================+======================+=============================+
|``r += n`` | ``X&`` |:: | | |``r += n`` |``X&`` |:: | |
| | | | | | | | | |
| | | { | | | | | { | |
| | | Distance m = n; | | | | | Distance m = n; | |
| | | if (m >= 0) | | | | | if (m >= 0) | |
| | | while (m--) | | | | | while (m--) | |
| | | ++r; | | | | | ++r; | |
| | | else | | | | | else | |
| | | while (m++) | | | | | while (m++) | |
| | | --r; | | | | | --r; | |
| | | return r; | | | | | return r; | |
| | | } | | | | | } | |
+--------------------------------+---------------------------------------+--------------------------+----------------------------------------+ +--------------------------------+----------------------------------------+----------------------+-----------------------------+
| ``a + n``, ``n + a`` | ``X`` |``{ X tmp = a; return tmp | | | ``a + n``, ``n + a`` |``X`` |``{ X tmp = a; return | |
| | |+= n; }`` | | | | |tmp += n; }`` | |
+--------------------------------+---------------------------------------+--------------------------+----------------------------------------+ +--------------------------------+----------------------------------------+----------------------+-----------------------------+
|``r -= n`` | ``X&`` |``return r += -n`` | | |``r -= n`` |``X&`` |``return r += -n`` | |
+--------------------------------+---------------------------------------+--------------------------+----------------------------------------+ +--------------------------------+----------------------------------------+----------------------+-----------------------------+
|``a - n`` | ``X`` |``{ X tmp = a; return tmp | | |``a - n`` |``X`` |``{ X tmp = a; return | |
| | |-= n; }`` | | | | |tmp -= n; }`` | |
+--------------------------------+---------------------------------------+--------------------------+----------------------------------------+ +--------------------------------+----------------------------------------+----------------------+-----------------------------+
|``b - a`` |``Distance`` |``a < b ? distance(a,b) : |pre: there exists a value ``n`` of | |``b - a`` |``Distance`` |``a < b ? |pre: there exists a value |
| | |-distance(b,a)`` |``Distance`` such that ``a + n == b``. | | | |distance(a,b) : |``n`` of ``Distance`` such |
| | | |``b == a + (b - a)``. | | | |-distance(b,a)`` |that ``a + n == b``. ``b == |
+--------------------------------+---------------------------------------+--------------------------+----------------------------------------+ | | | |a + (b - a)``. |
|``a[n]`` |convertible to T |``*(a + n)`` |pre: a is a `readable iterator`_ | +--------------------------------+----------------------------------------+----------------------+-----------------------------+
+--------------------------------+---------------------------------------+--------------------------+----------------------------------------+ |``a[n]`` |convertible to T |``*(a + n)`` |pre: a is a `readable |
|``a[n] = v`` |convertible to T |``*(a + n) = v`` |pre: a is a `writable iterator`_ | | | | |iterator`_ |
+--------------------------------+---------------------------------------+--------------------------+----------------------------------------+ +--------------------------------+----------------------------------------+----------------------+-----------------------------+
|``a < b`` |convertible to ``bool`` |``b - a > 0`` |``<`` is a total ordering relation | |``a[n] = v`` |convertible to T |``*(a + n) = v`` |pre: a is a `writable |
+--------------------------------+---------------------------------------+--------------------------+----------------------------------------+ | | | |iterator`_ |
|``a > b`` |convertible to ``bool`` |``b < a`` |``>`` is a total ordering relation | +--------------------------------+----------------------------------------+----------------------+-----------------------------+
+--------------------------------+---------------------------------------+--------------------------+----------------------------------------+ |``a < b`` |convertible to ``bool`` |``b - a > 0`` |``<`` is a total ordering |
|``a >= b`` |convertible to ``bool`` |``!(a < b)`` | | | | | |relation |
+--------------------------------+---------------------------------------+--------------------------+----------------------------------------+ +--------------------------------+----------------------------------------+----------------------+-----------------------------+
|``a <= b`` |convertible to ``bool`` |``!(a > b)`` | | |``a > b`` |convertible to ``bool`` |``b < a`` |``>`` is a total ordering |
+--------------------------------+---------------------------------------+--------------------------+----------------------------------------+ | | | |relation |
|``traversal_category<X>::type`` | | |Convertible to | +--------------------------------+----------------------------------------+----------------------+-----------------------------+
| | | |``random_access_traversal_iterator_tag``| |``a >= b`` |convertible to ``bool`` |``!(a < b)`` | |
+--------------------------------+---------------------------------------+--------------------------+----------------------------------------+ +--------------------------------+----------------------------------------+----------------------+-----------------------------+
|``a <= b`` |convertible to ``bool`` |``!(a > b)`` | |
+--------------------------------+----------------------------------------+----------------------+-----------------------------+
|``traversal_category<X>::type`` |Convertible to | | |
| |``random_access_traversal_iterator_tag``| | |
+--------------------------------+----------------------------------------+----------------------+-----------------------------+