mirror of
https://github.com/boostorg/iterator.git
synced 2025-07-24 09:57:17 +02:00
some progress
[SVN r21610]
This commit is contained in:
@ -2,31 +2,18 @@
|
||||
|
||||
template <
|
||||
class Incrementable
|
||||
, unsigned Access = use_default_access
|
||||
, class Traversal = use_default
|
||||
, class CategoryOrTraversal = use_default
|
||||
, class Difference = use_default
|
||||
>
|
||||
class counting_iterator
|
||||
: public iterator_adaptor<
|
||||
counting_iterator<Incrementable, Access, Traversal, Difference>
|
||||
, Incrementable
|
||||
, Incrementable
|
||||
, Access
|
||||
, /* see details for traversal category */
|
||||
, Incrementable const&
|
||||
, Incrementable const*
|
||||
, /* distance = Difference or a signed integral type */>
|
||||
{
|
||||
friend class iterator_core_access;
|
||||
public:
|
||||
counting_iterator();
|
||||
counting_iterator(counting_iterator const& rhs);
|
||||
counting_iterator(Incrementable x);
|
||||
explicit counting_iterator(Incrementable x);
|
||||
Incrementable base() const;
|
||||
private:
|
||||
typename counting_iterator::reference dereference() const
|
||||
{
|
||||
return this->base_reference();
|
||||
}
|
||||
Incrementable current; // exposition
|
||||
};
|
||||
|
||||
|
||||
@ -39,28 +26,29 @@
|
||||
|
||||
The ``Incrementable`` type must be Default Constructible, Copy
|
||||
Constructible, and Assignable. The default distance is
|
||||
an implementation defined signed integegral type.
|
||||
an implementation defined signed integral type.
|
||||
|
||||
The resulting ``counting_iterator`` models Readable Lvalue Iterator.
|
||||
|
||||
``counting_iterator`` models
|
||||
----------------------------
|
||||
|
||||
``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:
|
||||
::
|
||||
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
|
||||
Bidirectional Traversal Iterator, then pre-decrement is also required:
|
||||
::
|
||||
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
|
||||
required:
|
||||
::
|
||||
required::
|
||||
|
||||
counting_iterator::difference_type n;
|
||||
i += n
|
||||
@ -84,8 +72,22 @@ required:
|
||||
|
||||
|
||||
|
||||
``counting_iterator(Incrementable x);``
|
||||
``explicit counting_iterator(Incrementable x);``
|
||||
|
||||
:Returns: An instance of ``counting_iterator`` with its base
|
||||
object copy constructed from ``x``.
|
||||
:Returns: An instance of ``counting_iterator`` with ``current``
|
||||
constructed from ``x``.
|
||||
|
||||
|
||||
``reference operator*() const;``
|
||||
|
||||
:Returns: ``current``
|
||||
|
||||
|
||||
``counting_iterator& operator++();``
|
||||
|
||||
:Effects: ``++current``
|
||||
|
||||
|
||||
``Incrementable base() const;``
|
||||
|
||||
:Returns: ``current``
|
Reference in New Issue
Block a user