resolved some issues with counting_iterator

[SVN r21639]
This commit is contained in:
Jeremy Siek
2004-01-12 19:01:57 +00:00
parent b2407b0191
commit 6085e03da0
6 changed files with 88 additions and 39 deletions

View File

@ -8,6 +8,12 @@
class counting_iterator
{
public:
typedef Incrementable value_type;
typedef const Incrementable& reference;
typedef const Incrementable* pointer;
typedef /* see below */ difference_type;
typedef /* see below */ iterator_category;
counting_iterator();
counting_iterator(counting_iterator const& rhs);
explicit counting_iterator(Incrementable x);
@ -20,6 +26,15 @@
};
If the ``Diference`` argument is ``use_default`` then the
``difference_type`` member is an implementation defined signed
integral type.
The member ``iterator_category`` is a type that satisfies the
requirements of the concepts modeled by the ``counting_iterator`` as
specified in the models section.
[*Note:* implementers are encouraged to provide an implementation of
``distance_to`` and a ``difference_type`` that avoids overflows in
the cases when the ``Incrementable`` type is a numeric type.]
@ -28,8 +43,7 @@
..................................
The ``Incrementable`` type must be Default Constructible, Copy
Constructible, and Assignable. The default distance is
an implementation defined signed integral type.
Constructible, and Assignable.
``counting_iterator`` models
@ -37,21 +51,23 @@ an implementation defined signed integral type.
``counting_iterator`` models Readable Lvalue Iterator.
Furthermore, if you wish to create a counting iterator that is a Forward
Traversal Iterator, then the following expressions must be valid::
Furthermore, if you wish to create a counting iterator that is a
Forward Traversal Iterator and also Forward Iterator, then the
following expressions must be valid::
Incrementable i, j;
++i // pre-increment
i == j // operator equal
If you wish to create a counting iterator that is a
Bidirectional Traversal Iterator, then pre-decrement is also required::
If you wish to create a counting iterator that is a Bidirectional
Traversal Iterator and also Bidirectional Iterator, then pre-decrement
is also required::
--i
If you wish to create a counting iterator that is a Random Access
Traversal Iterator, then these additional expressions are also
required::
Traversal Iterator and also Random Access Iterator, then these
additional expressions are also required::
counting_iterator::difference_type n;
i += n