Files
boost_iterator/doc/counting_iterator_ref.rst

93 lines
2.1 KiB
ReStructuredText
Raw Normal View History

::
template <
class Incrementable
2004-01-12 00:48:21 +00:00
, class CategoryOrTraversal = use_default
, class Difference = use_default
>
class counting_iterator
{
public:
counting_iterator();
counting_iterator(counting_iterator const& rhs);
2004-01-12 00:48:21 +00:00
explicit counting_iterator(Incrementable x);
Incrementable base() const;
private:
2004-01-12 00:48:21 +00:00
Incrementable current; // exposition
};
[*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.]
``counting_iterator`` requirements
..................................
The ``Incrementable`` type must be Default Constructible, Copy
Constructible, and Assignable. The default distance is
2004-01-12 00:48:21 +00:00
an implementation defined signed integral type.
2004-01-12 00:48:21 +00:00
``counting_iterator`` models
............................
2004-01-12 00:48:21 +00:00
``counting_iterator`` models Readable Lvalue Iterator.
Furthermore, if you wish to create a counting iterator that is a Forward
2004-01-12 00:48:21 +00:00
Traversal 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
2004-01-12 00:48:21 +00:00
Bidirectional Traversal 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
2004-01-12 00:48:21 +00:00
required::
counting_iterator::difference_type n;
i += n
n = i - j
i < j
``counting_iterator`` operations
................................
``counting_iterator();``
:Returns: A default constructed instance of ``counting_iterator``.
``counting_iterator(counting_iterator const& rhs);``
:Returns: An instance of ``counting_iterator`` that is a copy of ``rhs``.
2004-01-12 00:48:21 +00:00
``explicit counting_iterator(Incrementable x);``
:Returns: An instance of ``counting_iterator`` with ``current``
constructed from ``x``.
``reference operator*() const;``
:Returns: ``current``
``counting_iterator& operator++();``
:Effects: ``++current``
2004-01-12 00:48:21 +00:00
``Incrementable base() const;``
2004-01-12 00:48:21 +00:00
:Returns: ``current``