-
+
This concludes our iterator_facade tutorial, but before you
stop reading we urge you to take a look at iterator_adaptor.
There's another way to approach writing these iterators which might
diff --git a/doc/iterator_facade_ref.rst b/doc/iterator_facade_ref.rst
index 51ff2ac..47fe684 100644
--- a/doc/iterator_facade_ref.rst
+++ b/doc/iterator_facade_ref.rst
@@ -18,7 +18,7 @@
public:
typedef remove_const::type value_type;
typedef Reference reference;
- typedef Value* pointer;
+ typedef Value\* pointer;
typedef Difference difference_type;
typedef /* see below__ \*/ iterator_category;
@@ -37,57 +37,55 @@
// Comparison operators
template
- typename enable_if_interoperable::type // exposition
- operator ==(iterator_facade const& lhs,
- iterator_facade const& rhs);
+ typename enable_if_interoperable::type // exposition
+ operator ==(iterator_facade const& lhs,
+ iterator_facade const& rhs);
template
- typename enable_if_interoperable::type
- operator !=(iterator_facade const& lhs,
- iterator_facade const& rhs);
+ typename enable_if_interoperable::type
+ operator !=(iterator_facade const& lhs,
+ iterator_facade const& rhs);
template
- typename enable_if_interoperable::type
- operator <(iterator_facade const& lhs,
- iterator_facade const& rhs);
+ typename enable_if_interoperable::type
+ operator <(iterator_facade const& lhs,
+ iterator_facade const& rhs);
template
- typename enable_if_interoperable::type
- operator <=(iterator_facade const& lhs,
- iterator_facade const& rhs);
+ typename enable_if_interoperable::type
+ operator <=(iterator_facade const& lhs,
+ iterator_facade const& rhs);
template
- typename enable_if_interoperable::type
- operator >(iterator_facade const& lhs,
- iterator_facade const& rhs);
+ typename enable_if_interoperable::type
+ operator >(iterator_facade const& lhs,
+ iterator_facade const& rhs);
template
- typename enable_if_interoperable::type
- operator >=(iterator_facade const& lhs,
- iterator_facade const& rhs);
-
- template
- typename enable_if_interoperable::type
- operator >=(iterator_facade const& lhs,
- iterator_facade const& rhs);
+ typename enable_if_interoperable::type
+ operator >=(iterator_facade const& lhs,
+ iterator_facade const& rhs);
// Iterator difference
template
- typename enable_if_interoperable::type
- operator -(iterator_facade const& lhs,
- iterator_facade const& rhs);
+ /* see below__ \*/
+ operator-(iterator_facade const& lhs,
+ iterator_facade const& rhs);
// Iterator addition
- template
- Derived operator+ (iterator_facade const&,
- typename Derived::difference_type n)
+ template
+ Derived operator+ (iterator_facade const&,
+ typename Derived::difference_type n);
+
+ template
+ Derived operator+ (typename Derived::difference_type n,
+ iterator_facade const&);
__ `iterator category`_
@@ -95,6 +93,8 @@ __ `operator arrow`_
__ brackets_
+__ minus_
+
.. _`iterator category`:
The ``iterator_category`` member of ``iterator_facade`` is
@@ -138,7 +138,8 @@ The following table describes the typical valid expressions on
``iterator_facade``\ 's ``Derived`` parameter, depending on the
iterator concept(s) it will model. The operations in the first
column must be made accessible to member functions of class
-``iterator_core_access``.
+``iterator_core_access``. In addition,
+``static_cast(iterator_facade*)`` shall be well-formed.
In the table below, ``F`` is ``iterator_facade``, ``a`` is an
object of type ``X``, ``b`` and ``c`` are objects of type ``const X``,
@@ -151,27 +152,28 @@ interoperable with ``X``.
.. topic:: ``iterator_facade`` Core Operations
- +--------------------+----------------------+-------------------------------------+---------------------------+
- |Expression |Return Type |Assertion/Note |Used to implement Iterator |
- | | | |Concept(s) |
- +====================+======================+=====================================+===========================+
- |``c.dereference()`` |``F::reference`` | |Readable Iterator, Writable|
- | | | |Iterator |
- +--------------------+----------------------+-------------------------------------+---------------------------+
- |``c.equal(y)`` |convertible to bool |true iff ``c`` and ``y`` refer to the|Single Pass Iterator |
- | | |same position. | |
- +--------------------+----------------------+-------------------------------------+---------------------------+
- |``a.increment()`` |unused | |Incrementable Iterator |
- +--------------------+----------------------+-------------------------------------+---------------------------+
- |``a.decrement()`` |unused | |Bidirectional Traversal |
- | | | |Iterator |
- +--------------------+----------------------+-------------------------------------+---------------------------+
- |``a.advance(n)`` |unused | |Random Access Traversal |
- | | | |Iterator |
- +--------------------+----------------------+-------------------------------------+---------------------------+
- |``c.distance_to(z)``|convertible to |equivalent to ``distance(c, X(z))``. |Random Access Traversal |
- | |``F::difference_type``| |Iterator |
- +--------------------+----------------------+-------------------------------------+---------------------------+
+ +--------------------+----------------------+-------------------------+---------------------------+
+ |Expression |Return Type |Assertion/Note |Used to implement Iterator |
+ | | | |Concept(s) |
+ +====================+======================+=========================+===========================+
+ |``c.dereference()`` |``F::reference`` | |Readable Iterator, Writable|
+ | | | |Iterator |
+ +--------------------+----------------------+-------------------------+---------------------------+
+ |``c.equal(y)`` |convertible to bool |true iff ``c`` and ``y`` |Single Pass Iterator |
+ | | |refer to the same | |
+ | | |position. | |
+ +--------------------+----------------------+-------------------------+---------------------------+
+ |``a.increment()`` |unused | |Incrementable Iterator |
+ +--------------------+----------------------+-------------------------+---------------------------+
+ |``a.decrement()`` |unused | |Bidirectional Traversal |
+ | | | |Iterator |
+ +--------------------+----------------------+-------------------------+---------------------------+
+ |``a.advance(n)`` |unused | |Random Access Traversal |
+ | | | |Iterator |
+ +--------------------+----------------------+-------------------------+---------------------------+
+ |``c.distance_to(z)``|convertible to |equivalent to |Random Access Traversal |
+ | |``F::difference_type``|``distance(c, X(z))``. |Iterator |
+ +--------------------+----------------------+-------------------------+---------------------------+
@@ -280,8 +282,115 @@ __ `operator arrow`_
::
- Derived tmp(static_cast(this));
- return tmp -= n;
+ Derived tmp(static_cast(this));
+ return tmp -= n;
+
+::
+
+ template
+ Derived operator+ (iterator_facade const&,
+ typename Derived::difference_type n);
+
+ template
+ Derived operator+ (typename Derived::difference_type n,
+ iterator_facade const&);
+
+:Effects:
+
+ ::
+
+ Derived tmp(static_cast(this));
+ return tmp += n;
+
+``iterator_facade`` interoperability
+------------------------------------
+
+::
+
+ template
+ typename enable_if_interoperable::type
+ operator ==(iterator_facade const& lhs,
+ iterator_facade const& rhs);
+
+:Returns: if ``is_convertible::value``, then
+ ``lhs.equal(rhs)``. Otherwise, ``rhs.equal(lhs)``.
+
+::
+
+ template
+ typename enable_if_interoperable::type
+ operator !=(iterator_facade const& lhs,
+ iterator_facade const& rhs);
+
+:Returns: if ``is_convertible::value``, then
+ ``!lhs.equal(rhs)``. Otherwise, ``!rhs.equal(lhs)``.
+
+::
+
+ template
+ typename enable_if_interoperable::type
+ operator <(iterator_facade const& lhs,
+ iterator_facade const& rhs);
+
+:Returns: if ``is_convertible::value``, then
+ ``lhs.distance_to(rhs) < 0``. Otherwise, ``rhs.distance_to(lhs) >
+ 0``.
+
+::
+
+ template
+ typename enable_if_interoperable::type
+ operator <=(iterator_facade const& lhs,
+ iterator_facade const& rhs);
+
+:Returns: if ``is_convertible::value``, then
+ ``lhs.distance_to(rhs) <= 0``. Otherwise, ``rhs.distance_to(lhs)
+ >= 0``.
+
+::
+
+ template
+ typename enable_if_interoperable::type
+ operator >(iterator_facade const& lhs,
+ iterator_facade const& rhs);
+
+:Returns: if ``is_convertible::value``, then
+ ``lhs.distance_to(rhs) > 0``. Otherwise,
+ ``rhs.distance_to(lhs) < 0``.
+::
+ template
+ typename enable_if_interoperable::type
+ operator >=(iterator_facade const& lhs,
+ iterator_facade const& rhs);
+
+:Returns: if ``is_convertible::value``, then
+ ``lhs.distance_to(rhs) >= 0``. Otherwise,
+ ``rhs.distance_to(lhs) <= 0``.
+
+.. _minus:
+
+::
+
+ template
+ typename enable_if_interoperable::type
+ operator -(iterator_facade const& lhs,
+ iterator_facade const& rhs);
+
+:Return Type: if ``is_convertible::value``, then ``difference_type`` shall be
+ ``iterator_traits::difference_type``. Otherwise,
+ ``difference_type`` shall be
+ ``iterator_traits::difference_type``.
+
+:Returns: if ``is_convertible::value``, then
+ ``-lhs.distance_to(rhs)``. Otherwise,
+ ``-rhs.distance_to(lhs)``.