iterator/doc/indirect_iterator_ref.diff
Dave Abrahams b6068667c9 Fixed base() to always return const&. Cleaned up iterator_adaptor
specification of inheritance and base class parameters.


[SVN r21821]
2004-01-18 20:54:59 +00:00

246 lines
7.3 KiB
Diff

Index: indirect_iterator_ref.rst
===================================================================
RCS file: /cvsroot/boost/boost/libs/iterator/doc/indirect_iterator_ref.rst,v
retrieving revision 1.2
retrieving revision 1.21
diff -w -d -u -b -r1.2 -r1.21
--- indirect_iterator_ref.rst 22 Sep 2003 19:55:00 -0000 1.2
+++ indirect_iterator_ref.rst 15 Jan 2004 00:01:33 -0000 1.21
@@ -3,82 +3,139 @@
template <
class Iterator
, class Value = use_default
Issue 9.15
- , unsigned Access = use_default_access
- , class Traversal = use_default
+ , class CategoryOrTraversal = use_default
, class Reference = use_default
, class Difference = use_default
>
class indirect_iterator
Issue 9.37x
- : public iterator_adaptor</* see discussion */>
{
- friend class iterator_core_access;
public:
+ typedef /* see below */ value_type;
+ typedef /* see below */ reference;
+ typedef /* see below */ pointer;
+ typedef /* see below */ difference_type;
+ typedef /* see below */ iterator_category;
+
indirect_iterator();
indirect_iterator(Iterator x);
+
Issue 9.15
template <
- class Iterator2, class Value2, unsigned Access2, class Traversal2
+ class Iterator2, class Value2, class Category2
, class Reference2, class Difference2
>
indirect_iterator(
indirect_iterator<
- Iterator2, Value2, Access2, Traversal2, Reference2, Difference2
+ Iterator2, Value2, Category2, Reference2, Difference2
> const& y
, typename enable_if_convertible<Iterator2, Iterator>::type* = 0 // exposition
);
Issue 9.37x
- private: // as-if specification
- typename indirect_iterator::reference dereference() const
- {
- return **this->base();
- }
+
+ Iterator const& base() const;
+ reference operator*() const;
+ indirect_iterator& operator++();
+ indirect_iterator& operator--();
+ private:
+ Iterator m_iterator; // exposition
};
+
+The member types of ``indirect_iterator`` are defined according to
+the following pseudo-code, where ``V`` is
+``iterator_traits<Iterator>::value_type``
+
+.. parsed-literal::
+
+ if (Value is use_default) then
+ typedef remove_const<pointee<V>::type>::type value_type;
+ else
+ typedef remove_const<Value>::type value_type;
+
+ if (Reference is use_default) then
+ if (Value is use_default) then
+ typedef indirect_reference<V>::type reference;
+ else
+ typedef Value& reference;
+ else
+ typedef Reference reference;
+
+ if (Value is use_default) then
+ typedef pointee<V>::type\* pointer;
+ else
+ typedef Value\* pointer;
+
+ if (Difference is use_default)
+ typedef iterator_traits<Iterator>::difference_type difference_type;
+ else
+ typedef Difference difference_type;
+
+ if (CategoryOrTraversal is use_default)
+ typedef |iterator-category|_\ (
+ iterator_traversal<Iterator>::type,``reference``,``value_type``
+ ) iterator_category;
+ else
+ typedef |iterator-category|_\ (
+ CategoryOrTraversal,``reference``,``value_type``
+ ) iterator_category;
+
+
``indirect_iterator`` requirements
..................................
Issue 9.40x
-The ``value_type`` of the ``Iterator`` template parameter should
-itself be dereferenceable. The return type of the ``operator*`` for
-the ``value_type`` must be the same type as the ``Reference`` template
-parameter. The ``Value`` template parameter will be the ``value_type``
-for the ``indirect_iterator``, unless ``Value`` is const. If ``Value``
-is ``const X``, then ``value_type`` will be *non-* ``const X``. The
-default for ``Value`` is
+The expression ``*v``, where ``v`` is an object of
+``iterator_traits<Iterator>::value_type``, shall be valid
+expression and convertible to ``reference``. ``Iterator`` shall
+model the traversal concept indicated by ``iterator_category``.
+``Value``, ``Reference``, and ``Difference`` shall be chosen so
+that ``value_type``, ``reference``, and ``difference_type`` meet
+the requirements indicated by ``iterator_category``.
-::
+[Note: there are further requirements on the
+``iterator_traits<Iterator>::value_type`` if the ``Value``
+parameter is not ``use_default``, as implied by the algorithm for
+deducing the default for the ``value_type`` member.]
- iterator_traits< iterator_traits<Iterator>::value_type >::value_type
Issue 9.37x
+``indirect_iterator`` models
+............................
-If the default is used for ``Value``, then there must be a valid
-specialization of ``iterator_traits`` for the value type of the base
-iterator.
+In addition to the concepts indicated by ``iterator_category``
+and by ``iterator_traversal<indirect_iterator>::type``, a
+specialization of ``indirect_iterator`` models the following
+concepts, Where ``v`` is an object of
+``iterator_traits<Iterator>::value_type``:
-The ``Reference`` parameter will be the ``reference`` type of the
-``indirect_iterator``. The default is ``Value&``.
+ * Readable Iterator if ``reference(*v)`` is convertible to
+ ``value_type``.
-The ``Access`` and ``Traversal`` parameters are passed unchanged to
-the corresponding parameters of the ``iterator_adaptor`` base
-class, and the ``Iterator`` parameter is passed unchanged as the
-``Base`` parameter to the ``iterator_adaptor`` base class.
+ * Writable Iterator if ``reference(*v) = t`` is a valid
+ expression (where ``t`` is an object of type
+ ``indirect_iterator::value_type``)
-The indirect iterator will model the most refined standard traversal
-concept that is modeled by the ``Iterator`` type. The indirect
-iterator will model the most refined standard access concept that is
-modeled by the value type of ``Iterator``.
+ * Lvalue Iterator if ``reference`` is a reference type.
+
+``indirect_iterator<X,V1,C1,R1,D1>`` is interoperable with
+``indirect_iterator<Y,V2,C2,R2,D2>`` if and only if ``X`` is
+interoperable with ``Y``.
``indirect_iterator`` operations
................................
Issue 9.37x
+In addition to the operations required by the concepts described
+above, specializations of ``indirect_iterator`` provide the
+following operations.
+
+
Issue 9.28 and 9.37x
``indirect_iterator();``
:Requires: ``Iterator`` must be Default Constructible.
:Returns: An instance of ``indirect_iterator`` with
- a default constructed base object.
+ a default-constructed ``m_iterator``.
Issue 9.37x
``indirect_iterator(Iterator x);``
:Returns: An instance of ``indirect_iterator`` with
- the ``iterator_adaptor`` subobject copy constructed from ``x``.
+ ``m_iterator`` copy constructed from ``x``.
::
Issue 9.29
@@ -94,5 +151,27 @@
);
:Requires: ``Iterator2`` is implicitly convertible to ``Iterator``.
-:Returns: An instance of ``indirect_iterator`` that is a copy of ``y``.
+:Returns: An instance of ``indirect_iterator`` whose
+ ``m_iterator`` subobject is constructed from ``y.base()``.
+
Issue 9.37x
+``Iterator const& base() const;``
+:Returns: ``m_iterator``
+
+
+``reference operator*() const;``
+
+:Returns: ``**m_iterator``
+
+
+``indirect_iterator& operator++();``
+
+:Effects: ``++m_iterator``
+:Returns: ``*this``
+
+
+``indirect_iterator& operator--();``
+
+:Effects: ``--m_iterator``
+:Returns: ``*this``