From d15302e683a9abd1c7c4a3731a02f39962082559 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 27 Jan 2004 04:50:52 +0000 Subject: [PATCH] Bring branch up-to-date with trunk [SVN r21992] --- doc/facade-and-adaptor.html | 1776 ++++++---- doc/facade-and-adaptor.rst | 29 +- doc/filter_iterator.html | 510 +-- doc/filter_iterator.rst | 8 +- doc/filter_iterator_abstract.rst | 19 +- doc/filter_iterator_ref.rst | 156 +- doc/function_output_iterator.html | 319 +- doc/function_output_iterator.rst | 3 +- doc/function_output_iterator_ref.rst | 75 +- doc/generate.py | 4 +- doc/index.html | 288 +- doc/index.rst | 94 +- doc/indirect_iterator.html | 460 ++- doc/indirect_iterator.rst | 9 +- doc/indirect_iterator_abstract.rst | 15 +- doc/indirect_iterator_ref.rst | 168 +- doc/iter-issue-list.rst | 4521 +++++++++++++++++++++----- doc/iterator_adaptor.html | 388 +-- doc/iterator_adaptor.rst | 9 +- doc/iterator_adaptor_ref.rst | 54 +- doc/iterator_facade.html | 1214 ++++--- doc/iterator_facade.rst | 15 +- doc/iterator_facade_body.rst | 26 +- doc/iterator_facade_ref.rst | 349 +- doc/new-iter-concepts.html | 530 ++- doc/new-iter-concepts.rst | 434 +-- doc/permutation_iterator.html | 421 ++- doc/permutation_iterator.rst | 8 +- doc/permutation_iterator_ref.rst | 113 +- doc/reverse_iterator.html | 222 +- doc/reverse_iterator.rst | 8 +- doc/reverse_iterator_abstract.rst | 11 +- doc/reverse_iterator_ref.rst | 130 +- doc/sources.py | 6 +- doc/transform_iterator.html | 262 +- doc/transform_iterator.rst | 7 +- doc/transform_iterator_abstract.rst | 8 +- doc/transform_iterator_ref.rst | 120 +- 38 files changed, 8573 insertions(+), 4216 deletions(-) diff --git a/doc/facade-and-adaptor.html b/doc/facade-and-adaptor.html index 465c920..270976f 100755 --- a/doc/facade-and-adaptor.html +++ b/doc/facade-and-adaptor.html @@ -3,11 +3,11 @@ - + Iterator Facade and Adaptor - - + + @@ -20,13 +20,12 @@ Author: David Abrahams, Jeremy Siek, Thomas Witt Contact: -dave@boost-consulting.com, jsiek@osl.iu.edu, witt@acm.org +dave@boost-consulting.com, jsiek@osl.iu.edu, witt@styleadvisor.com Organization: Boost Consulting, Indiana University Open Systems -Lab, University of Hanover Institute for Transport -Railway Operation and Construction +Lab, Zephyr Associates, Inc. Date: -2003-11-24 +2004-01-21 Number:This is a revised version of N1530=03-0113, which was accepted for Technical Report 1 by the C++ standard committee's library working group. @@ -56,80 +55,84 @@ by adapting other iterators.

Table of Contents

-

Motivation

+

Motivation

Iterators play an important role in modern C++ programming. The iterator is the central abstraction of the algorithms of the Standard Library, allowing algorithms to be re-used in in a wide variety of @@ -222,15 +225,15 @@ applies some user-specified function during the dereference of the iterator.

-

Impact on the Standard

+

Impact on the Standard

This proposal is purely an addition to the C++ standard library. However, note that this proposal relies on the proposal for New Iterator Concepts.

-

Design

+

Design

-

Iterator Concepts

+

Iterator Concepts

This proposal is formulated in terms of the new iterator concepts as proposed in n1550, since user-defined and especially adapted iterators suffer from the well known categorization problems that are @@ -240,7 +243,7 @@ is a direct mapping between new and old categories. This proposal could be reformulated using this mapping if n1550 was not accepted.

-

Interoperability

+

Interoperability

The question of iterator interoperability is poorly addressed in the current standard. There are currently two defect reports that are concerned with interoperability issues.

@@ -260,7 +263,7 @@ fixes the issues raised in 280. It provides the desired interoperability without introducing unwanted overloads.

-

Iterator Facade

+

Iterator Facade

+ +

The enable_if_interoperable template used above is for exposition -purposes. The member operators should be only be in an overload set +purposes. The member operators should only be in an overload set provided the derived types Dr1 and Dr2 are interoperable, meaning that at least one of the types is convertible to the other. The enable_if_interoperable approach uses SFINAE to take the operators @@ -699,25 +759,29 @@ struct enable_if_interoperable > {}; -

+
+

iterator_facade Requirements

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<Derived*>(iterator_facade*) shall be well-formed.

In the table below, F is iterator_facade<X,V,C,R,D>, a is an object of type X, b and c are objects of type const X, n is an object of F::difference_type, y is a constant object of a single pass iterator type interoperable with X, and z is a constant object of a random access traversal iterator type interoperable with X.

- +
+

iterator_facade Core Operations

+
---+++ @@ -734,25 +798,13 @@ Concept(s) - - - - - - + - - - - - @@ -764,80 +816,26 @@ Iterator - - - + + + - +
Expression Readable Iterator, Writable Iterator
c.equal(b)convertible to booltrue iff b and c are -equivalent.Single Pass Iterator
c.equal(y) convertible to booltrue iff c and y refer to the -same position. Implements c == y -and c != y.true iff c and y +refer to the same +position. Single Pass Iterator
a.advance(n)unused Random Access Traversal -Iterator
a.increment() unused   Bidirectional Traversal Iterator
c.distance_to(b)convertible to -F::difference_typeequivalent to distance(c, b)
a.advance(n)unused  Random Access Traversal Iterator
c.distance_to(z) convertible to F::difference_typeequivalent to distance(c, z). -Implements c - z, c < z, c -<= z, c > z, and c >= c.equivalent to +distance(c, X(z)). Random Access Traversal Iterator
-
-
-

iterator_facade iterator category

-

The iterator_category member of iterator_facade<X,V,R,C,D> -is a type which satisfies the following conditions:

-
-
    -
  • if C is convertible to std::input_iterator_tag or -C is convertible to std::output_iterator_tag, -iterator_category is the same as C.

    -
  • -
  • Otherwise, if C is not convertible to -incrementable_traversal_tag, the program is ill-formed

    -
  • -
  • Otherwise:

    -
      -
    • iterator_category is convertible to the iterator -category tag or tags given by the following algorithm, and -not to any more-derived iterator category tag or tags:

      -
      -if (R is a reference type
      -    && C is convertible to forward_traversal_tag)
      -{
      -    if (C is convertible to random_access_traversal_tag)
      -        return random_access_iterator_tag
      -    else if (C is convertible to bidirectional_traversal_tag)
      -        return bidirectional_iterator_tag
      -    else
      -        return forward_traversal_tag
      -}
      -else
      -{
      -    if (C is convertible to single_pass_traversal_tag
      -        && R is convertible to V)
      -    {
      -        if (V is const)
      -            return input_iterator_tag
      -        else
      -            return input_iterator_tag and output_iterator_tag
      -    }
      -    else
      -        return output_iterator_tag
      -}
      -
      -
    • -
    • iterator_traversal<X>::type is convertible to the most -derived traversal tag type to which C is also -convertible, and not to any more-derived traversal tag type.

      -
    • -
    -
  • -
-
+
-

iterator_facade operations

+

iterator_facade operations

The operations in this section are described in terms of operations on the core interface of Derived which may be inaccessible (i.e. private). The implementation should access these operations @@ -873,10 +871,12 @@ of type pointer equal to:

-Returns:an object convertible to reference and holding a copy -p of *static_cast<Derived const*>(this) + n such that, for a constant object v of type -value_type, (*static_cast<Derived const*>(this))[n] = v is equivalent -to p = v. +Returns:an object convertible to value_type. For constant +objects v of type value_type, and n of type +difference_type, (*this)[n] = v is equivalent to +*(*this + n) = v, and static_cast<value_type +const&>((*this)[n]) is equivalent to +static_cast<value_type const&>(*(*this + n)) @@ -914,7 +914,7 @@ return tmp; Effects:
 static_cast<Derived*>(this)->decrement();
-return static_cast<Derived*>(this);
+return *static_cast<Derived*>(this);
 
@@ -941,7 +941,7 @@ return tmp; Effects:
 static_cast<Derived*>(this)->advance(n);
-return static_cast<Derived*>(this);
+return *static_cast<Derived*>(this);
 
@@ -954,7 +954,7 @@ return static_cast<Derived*>(this); Effects:
 static_cast<Derived*>(this)->advance(-n);
-return static_cast<Derived*>(this);
+return *static_cast<Derived*>(this);
 
@@ -973,11 +973,197 @@ return tmp -= n; -
+
+template <class Dr, class V, class TC, class R, class D>
+Derived operator+ (iterator_facade<Dr,V,TC,R,D> const&,
+                   typename Derived::difference_type n);
+
+template <class Dr, class V, class TC, class R, class D>
+Derived operator+ (typename Derived::difference_type n,
+                   iterator_facade<Dr,V,TC,R,D> const&);
+
+ +++ + + + +
Effects:
+Derived tmp(static_cast<Derived const*>(this));
+return tmp += n;
+
+
+
+template <class Dr1, class V1, class TC1, class R1, class D1,
+          class Dr2, class V2, class TC2, class R2, class D2>
+typename enable_if_interoperable<Dr1,Dr2,bool>::type
+operator ==(iterator_facade<Dr1,V1,TC1,R1,D1> const& lhs,
+            iterator_facade<Dr2,V2,TC2,R2,D2> const& rhs);
+
+ +++ + + + +
Returns:

if is_convertible<Dr2,Dr1>::value

+
+
then
+
((Dr1 const&)lhs).equal((Dr2 const&)rhs).
+
Otherwise,
+
((Dr2 const&)rhs).equal((Dr1 const&)lhs).
+
+
+
+template <class Dr1, class V1, class TC1, class R1, class D1,
+          class Dr2, class V2, class TC2, class R2, class D2>
+typename enable_if_interoperable<Dr1,Dr2,bool>::type
+operator !=(iterator_facade<Dr1,V1,TC1,R1,D1> const& lhs,
+            iterator_facade<Dr2,V2,TC2,R2,D2> const& rhs);
+
+ +++ + + + +
Returns:

if is_convertible<Dr2,Dr1>::value

+
+
then
+
!((Dr1 const&)lhs).equal((Dr2 const&)rhs).
+
Otherwise,
+
!((Dr2 const&)rhs).equal((Dr1 const&)lhs).
+
+
+
+template <class Dr1, class V1, class TC1, class R1, class D1,
+          class Dr2, class V2, class TC2, class R2, class D2>
+typename enable_if_interoperable<Dr1,Dr2,bool>::type
+operator <(iterator_facade<Dr1,V1,TC1,R1,D1> const& lhs,
+           iterator_facade<Dr2,V2,TC2,R2,D2> const& rhs);
+
+ +++ + + + +
Returns:

if is_convertible<Dr2,Dr1>::value

+
+
then
+
((Dr1 const&)lhs).distance_to((Dr2 const&)rhs) < 0.
+
Otherwise,
+
((Dr2 const&)rhs).distance_to((Dr1 const&)lhs) > 0.
+
+
+
+template <class Dr1, class V1, class TC1, class R1, class D1,
+          class Dr2, class V2, class TC2, class R2, class D2>
+typename enable_if_interoperable<Dr1,Dr2,bool>::type
+operator <=(iterator_facade<Dr1,V1,TC1,R1,D1> const& lhs,
+            iterator_facade<Dr2,V2,TC2,R2,D2> const& rhs);
+
+ +++ + + + +
Returns:

if is_convertible<Dr2,Dr1>::value

+
+
then
+
((Dr1 const&)lhs).distance_to((Dr2 const&)rhs) <= 0.
+
Otherwise,
+
((Dr2 const&)rhs).distance_to((Dr1 const&)lhs) >= 0.
+
+
+
+template <class Dr1, class V1, class TC1, class R1, class D1,
+          class Dr2, class V2, class TC2, class R2, class D2>
+typename enable_if_interoperable<Dr1,Dr2,bool>::type
+operator >(iterator_facade<Dr1,V1,TC1,R1,D1> const& lhs,
+           iterator_facade<Dr2,V2,TC2,R2,D2> const& rhs);
+
+ +++ + + + +
Returns:

if is_convertible<Dr2,Dr1>::value

+
+
then
+
((Dr1 const&)lhs).distance_to((Dr2 const&)rhs) > 0.
+
Otherwise,
+
((Dr2 const&)rhs).distance_to((Dr1 const&)lhs) < 0.
+
+
+
+template <class Dr1, class V1, class TC1, class R1, class D1,
+          class Dr2, class V2, class TC2, class R2, class D2>
+typename enable_if_interoperable<Dr1,Dr2,bool>::type
+operator >=(iterator_facade<Dr1,V1,TC1,R1,D1> const& lhs,
+            iterator_facade<Dr2,V2,TC2,R2,D2> const& rhs);
+
+ +++ + + + +
Returns:

if is_convertible<Dr2,Dr1>::value

+
+
then
+
((Dr1 const&)lhs).distance_to((Dr2 const&)rhs) >= 0.
+
Otherwise,
+
((Dr2 const&)rhs).distance_to((Dr1 const&)lhs) <= 0.
+
+
+
+template <class Dr1, class V1, class TC1, class R1, class D1,
+          class Dr2, class V2, class TC2, class R2, class D2>
+typename enable_if_interoperable<Dr1,Dr2,difference>::type
+operator -(iterator_facade<Dr1,V1,TC1,R1,D1> const& lhs,
+           iterator_facade<Dr2,V2,TC2,R2,D2> const& rhs);
+
+ +++ + + + + + +
Return Type:

if is_convertible<Dr2,Dr1>::value

+
+
+
then
+
difference shall be +iterator_traits<Dr1>::difference_type.
+
Otherwise
+
difference shall be iterator_traits<Dr2>::difference_type
+
+
+
Returns:

if is_convertible<Dr2,Dr1>::value

+
+
then
+
-((Dr1 const&)lhs).distance_to((Dr2 const&)rhs).
+
Otherwise,
+
((Dr2 const&)rhs).distance_to((Dr1 const&)lhs).
+
+
-

Iterator adaptor [lib.iterator.adaptor]

+

Iterator adaptor [lib.iterator.adaptor]

template < class Derived , class Base - , class Value = use_default - , class CategoryOrTraversal = use_default - , class Reference = use_default + , class Value = use_default + , class CategoryOrTraversal = use_default + , class Reference = use_default , class Difference = use_default > class iterator_adaptor - : public iterator_facade<Derived, V, C, R, D> // see details + : public iterator_facade<Derived, V', C', R', D'> // see details { friend class iterator_core_access; public: iterator_adaptor(); explicit iterator_adaptor(Base iter); - Base base() const; + Base const& base() const; protected: Base const& base_reference() const; Base& base_reference(); @@ -1040,24 +1226,29 @@ class iterator_adaptor Base m_iterator; // exposition only }; +
+
+

iterator_adaptor requirements

+

static_cast<Derived*>(iterator_adaptor*) shall be well-formed. +The Base argument shall be Assignable and Copy Constructible.

-

iterator_adaptor base class parameters

-

The V, C, R, and D parameters of the iterator_facade +

iterator_adaptor base class parameters

+

The V', C', R', and D' parameters of the iterator_facade used as a base class in the summary of iterator_adaptor above are defined as follows:

-V = if (Value is use_default)
+V' = if (Value is use_default)
           return iterator_traits<Base>::value_type
       else
           return Value
 
-C = if (CategoryOrTraversal is use_default)
+C' = if (CategoryOrTraversal is use_default)
           return iterator_traversal<Base>::type
       else
           return CategoryOrTraversal
 
-R = if (Reference is use_default)
+R' = if (Reference is use_default)
           if (Value is use_default)
               return iterator_traits<Base>::reference
           else
@@ -1065,26 +1256,25 @@ above are defined as follows:

else return Reference -D = if (Difference is use_default) +D' = if (Difference is use_default) return iterator_traits<Base>::difference_type else return Difference
-
-
-

iterator_adaptor usage

-

The Derived template parameter must be a publicly derived from -iterator_adaptor. In order for Derived to model the -iterator concepts corresponding to -iterator_traits<Derived>::iterator_category, the expressions -involving m_iterator in the specifications of those private -member functions of iterator_adaptor that may be called by -iterator_facade<Derived, ``\ *V*\, \ *C*\, \ *R*\, \ -*D*\>`` in evaluating any valid expression involving Derived -in those concepts' requirements.

+ + +
-

iterator_adaptor public operations

+

iterator_adaptor public operations

iterator_adaptor();

@@ -1107,7 +1297,7 @@ in those concepts' requirements.

-

Base base() const;

+

Base const& base() const;

@@ -1118,7 +1308,7 @@ in those concepts' requirements.

-

iterator_adaptor protected member functions

+

iterator_adaptor protected member functions

Base const& base_reference() const;

@@ -1139,7 +1329,7 @@ in those concepts' requirements.

-

iterator_adaptor private member functions

+

iterator_adaptor private member functions

typename iterator_adaptor::reference dereference() const;

@@ -1208,7 +1398,7 @@ typename iterator_adaptor::difference_type distance_to(
-

Specialized adaptors [lib.iterator.special.adaptors]

+

Specialized adaptors [lib.iterator.special.adaptors]

The enable_if_convertible<X,Y>::type expression used in this section is for exposition purposes. The converting constructors for specialized adaptors should be only be in an overload set provided @@ -1237,16 +1427,96 @@ take the constructor out of the overload set when the types are not implicitly convertible. ]

-

Indirect iterator

-

The indirect iterator adapts an iterator by applying an extra -dereference inside of operator*(). For example, this iterator -adaptor makes it possible to view a container of pointers +

Indirect iterator

+

indirect_iterator adapts an iterator by applying an +extra dereference inside of operator*(). For example, this +iterator adaptor makes it possible to view a container of pointers (e.g. list<foo*>) as if it were a container of the pointed-to type -(e.g. list<foo>) .

- +(e.g. list<foo>). indirect_iterator depends on two +auxiliary traits, pointee and indirect_reference, to +provide support for underlying iterators whose value_type is +not an iterator.

+
+

Class template pointee

+ + + +
+template <class Dereferenceable>
+struct pointee
+{
+    typedef /* see below */ type;
+};
+
+
+++ + + + +
Requires:For an object x of type Dereferenceable, *x +is well-formed. If ++x is ill-formed it shall neither be +ambiguous nor shall it violate access control, and +Dereferenceable::element_type shall be an accessible type. +Otherwise iterator_traits<Dereferenceable>::value_type shall +be well formed. [Note: These requirements need not apply to +explicit or partial specializations of pointee]
+

type is determined according to the following algorithm, where +x is an object of type Dereferenceable:

+
+if ( ++x is ill-formed )
+{
+    return ``Dereferenceable::element_type``
+}
+else if (``*x`` is a mutable reference to
+         std::iterator_traits<Dereferenceable>::value_type)
+{
+    return iterator_traits<Dereferenceable>::value_type
+}
+else
+{
+    return iterator_traits<Dereferenceable>::value_type const
+}
+
+
+
+

Class template indirect_reference

+ + + +
+template <class Dereferenceable>
+struct indirect_reference
+{
+    typedef /* see below */ type;
+};
+
+ +++ + + + +
Requires:For an object x of type Dereferenceable, *x +is well-formed. If ++x is ill-formed it shall neither be +ambiguous nor shall it violate access control, and +pointee<Dereferenceable>::type& shall be well-formed. +Otherwise iterator_traits<Dereferenceable>::reference shall +be well formed. [Note: These requirements need not apply to +explicit or partial specializations of indirect_reference]
+

type is determined according to the following algorithm, where +x is an object of type Dereferenceable:

+
+if ( ++x is ill-formed )
+    return ``pointee<Dereferenceable>::type&``
+else
+    std::iterator_traits<Dereferenceable>::reference
+
+
-

Class template indirect_iterator

+

Class template indirect_iterator

 template <
     class Iterator
@@ -1256,17 +1526,14 @@ template <
   , class Difference = use_default
 >
 class indirect_iterator
-  : public iterator_adaptor<
-               indirect_iterator<Iterator, Value, Access, Traversal, 
-                                 Reference, Difference>,
-               Iterator,
-               /* Value = see below */,
-               CategoryOrTraversal,
-               Reference,
-               Difference>
 {
-    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);
 
@@ -1280,54 +1547,92 @@ class indirect_iterator
         > const& y
       , typename enable_if_convertible<Iterator2, Iterator>::type* = 0 // exposition
     );
-private: // as-if specification
-    typename indirect_iterator::reference dereference() const
-    {
-        return **this->base();
-    }
-};
 
-template <class Dereferenceable>
-struct referent {
-  typedef /* see below */ type;
+    Iterator const& base() const;
+    reference operator*() const;
+    indirect_iterator& operator++();
+    indirect_iterator& operator--();
+private:
+   Iterator m_iterator; // exposition
 };
 
-

If Value is not use_default then the the argument for the -iterator_adaptor base class' Value parameter is Value with -cv-qualifiers removed. If Value is use_default, then the -argument for the iterator_adaptor base class' Value parameter -is computed as follows. We use the abbreviation -V=iterator_traits<Iterator>::value_type and v is an object of -type V.:

+

The member types of indirect_iterator are defined according to +the following pseudo-code, where V is +iterator_traits<Iterator>::value_type

-if (*v returns a constant lvalue or an rvalue) then
-    referent<V>::type
+if (Value is use_default) then
+    typedef remove_const<pointee<V>::type>::type value_type;
 else
-    add_const<referent<V>::type>::type
-
-

The algorithm for the type member of referent traits class is -as follows:

-
-if (Dereferenceable is a class and has member element_type)
-    Dereferenceable::element_type
+    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
-    iterator_traits<Dereferenceable>::value_type
+    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

-

The Iterator type must meet the requirements of Readable -Iterator. Also, the following requirements are placed on -iterator_traits<Iterator>::value_type. Let i be an object of -type iterator_traits<Iterator>::value_type. Then *i must be a -valid expression, and the type of *i must be the same as the -iterator_adaptor::reference. Also, 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.

+

indirect_iterator requirements

+

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.]

+
+
+

indirect_iterator models

+

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:

+
+
    +
  • Readable Iterator if reference(*v) is convertible to +value_type.
  • +
  • Writable Iterator if reference(*v) = t is a valid +expression (where t is an object of type +indirect_iterator::value_type)
  • +
  • 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

+

indirect_iterator operations

+

In addition to the operations required by the concepts described +above, specializations of indirect_iterator provide the +following operations.

indirect_iterator();

@@ -1335,8 +1640,8 @@ the default.

- +
Requires:Iterator must be Default Constructible.
Returns:An instance of indirect_iterator with -a default-constructed iterator_adaptor subobject.
Effects:Constructs an instance of indirect_iterator with +a default-constructed m_iterator.
@@ -1345,8 +1650,8 @@ a default-constructed iterator_adaptor -Returns:An instance of indirect_iterator with -the iterator_adaptor subobject copy constructed from x. +Effects:Constructs an instance of indirect_iterator with +m_iterator copy constructed from x. @@ -1368,28 +1673,70 @@ indirect_iterator( Requires:Iterator2 is implicitly convertible to Iterator. -Returns:An instance of indirect_iterator whose -iterator_adaptor subobject is constructed from y.base(). +Effects:Constructs an instance of indirect_iterator whose +m_iterator subobject is constructed from y.base(). + + + +

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
-

Reverse iterator

- -

The reverse iterator adaptor flips the direction of a base iterator's -motion. Invoking operator++() moves the base iterator backward and -invoking operator--() moves the base iterator forward.

+

Reverse iterator

+

The reverse iterator adaptor iterates through the adapted iterator +range in the opposite direction.

-

Class template reverse_iterator

+

Class template reverse_iterator

 template <class Iterator>
-class reverse_iterator :
-  public iterator_adaptor< reverse_iterator<Iterator>, Iterator >
+class reverse_iterator
 {
-  friend class iterator_core_access;
 public:
+  typedef iterator_traits<Iterator>::value_type value_type;
+  typedef iterator_traits<Iterator>::reference reference;
+  typedef iterator_traits<Iterator>::pointer pointer;
+  typedef iterator_traits<Iterator>::difference_type difference_type;
+  typedef /* see below */ iterator_category;
+
   reverse_iterator() {}
   explicit reverse_iterator(Iterator x) ;
 
@@ -1398,34 +1745,72 @@ public:
       reverse_iterator<OtherIterator> const& r
     , typename enable_if_convertible<OtherIterator, Iterator>::type* = 0 // exposition
   );
-
-private: // as-if specification
-  typename reverse_iterator::reference dereference() const { return *prior(this->base()); }
-
-  void increment() { --this->base_reference(); }
-  void decrement() { ++this->base_reference(); }
-
-  void advance(typename reverse_iterator::difference_type n)
-  {
-      this->base_reference() += -n;
-  }
-
-  template <class OtherIterator>
-  typename reverse_iterator::difference_type
-  distance_to(reverse_iterator<OtherIterator> const& y) const
-  {
-      return this->base_reference() - y.base();
-  }
-
+  Iterator const& base() const;
+  reference operator*() const;
+  reverse_iterator& operator++();
+  reverse_iterator& operator--();
+private:
+  Iterator m_iterator; // exposition
 };
 
+

If Iterator models Random Access Traversal Iterator and Readable +Lvalue Iterator, then iterator_category is convertible to +random_access_iterator_tag. Otherwise, if +Iterator models Bidirectional Traversal Iterator and Readable +Lvalue Iterator, then iterator_category is convertible to +bidirectional_iterator_tag. Otherwise, iterator_category is +convertible to input_iterator_tag.

-

reverse_iterator requirements

-

The base Iterator must be a model of Bidirectional Traversal -Iterator. The resulting reverse_iterator will be a model of the -most refined standard traversal and access concepts that are modeled -by Iterator.

+

reverse_iterator requirements

+

Iterator must be a model of Bidirectional Traversal Iterator. The +type iterator_traits<Iterator>::reference must be the type of +*i, where i is an object of type Iterator.

+
+
+

reverse_iterator models

+

A specialization of reverse_iterator models the same iterator +traversal and iterator access concepts modeled by its Iterator +argument. In addition, it may model old iterator concepts +specified in the following table:

+ ++++ + + + + + + + + + + + + + + + + + + + +
If I modelsthen reverse_iterator<I> models
Readable Lvalue Iterator, +Bidirectional Traversal IteratorBidirectional Iterator
Writable Lvalue Iterator, +Bidirectional Traversal IteratorMutable Bidirectional Iterator
Readable Lvalue Iterator, +Random Access Traversal IteratorRandom Access Iterator
Writable Lvalue Iterator, +Random Access Traversal IteratorMutable Random Access Iterator
+

reverse_iterator<X> is interoperable with +reverse_iterator<Y> if and only if X is interoperable with +Y.

+
+
+

reverse_iterator operations

+

In addition to the operations required by the concepts modeled by +reverse_iterator, reverse_iterator provides the following +operations.

reverse_iterator();

@@ -1433,8 +1818,8 @@ by Iterator.

- +
Requires:Iterator must be Default Constructible.
Returns:An instance of reverse_iterator with a -default constructed base object.
Effects:Constructs an instance of reverse_iterator with m_iterator +default constructed.
@@ -1443,8 +1828,8 @@ default constructed base object. -Returns:An instance of reverse_iterator with a -base object copy constructed from x. +Effects:Constructs an instance of reverse_iterator with +m_iterator copy constructed from x. @@ -1461,21 +1846,64 @@ reverse_iterator( Requires:OtherIterator is implicitly convertible to Iterator. -Returns:An instance of reverse_iterator that is a copy of r. +Effects:Constructs instance of reverse_iterator whose +m_iterator subobject is constructed from y.base(). + + + +

Iterator const& base() const;

+ +++ + + + +
Returns:m_iterator
+

reference operator*() const;

+ +++ + + + +
Effects:
+
+Iterator tmp = m_iterator;
+return *--tmp;
+
+

reverse_iterator& operator++();

+ +++ + + + + + +
Effects:--m_iterator
Returns:*this
+

reverse_iterator& operator--();

+ +++ + + +
Effects:++m_iterator
Returns:*this
-

Transform iterator

-

The transform iterator adapts an iterator by applying some function -object to the result of dereferencing the iterator. In other words, -the operator* of the transform iterator first dereferences the -base iterator, passes the result of this to the function object, and -then returns the result.

+

Transform iterator

+

The transform iterator adapts an iterator by modifying the +operator* to apply a function object to the result of +dereferencing the iterator and returning the result.

-

Class template transform_iterator

+

Class template transform_iterator

 template <class UnaryFunction,
@@ -1483,53 +1911,111 @@ template <class UnaryFunction,
           class Reference = use_default, 
           class Value = use_default>
 class transform_iterator
-  : 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 iterator_traits<Iterator>::difference_type difference_type;
+  typedef /* see below */ iterator_category;
+
   transform_iterator();
   transform_iterator(Iterator const& x, UnaryFunction f);
 
   template<class F2, class I2, class R2, class V2>
   transform_iterator(
         transform_iterator<F2, I2, R2, V2> const& t
-      , typename enable_if_convertible<I2, Iterator>::type* = 0      // exposition
-      , typename enable_if_convertible<F2, UnaryFunction>::type* = 0 // exposition
+      , typename enable_if_convertible<I2, Iterator>::type* = 0      // exposition only
+      , typename enable_if_convertible<F2, UnaryFunction>::type* = 0 // exposition only
   );
-
   UnaryFunction functor() const;
+  Iterator const& base() const;
+  reference operator*() const;
+  transform_iterator& operator++();
+  transform_iterator& operator--();
 private:
-  typename transform_iterator::value_type dereference() const;
-  UnaryFunction m_f;
+  Iterator m_iterator; // exposition only
+  UnaryFunction m_f;   // exposition only
 };
 
+

If Reference is use_default then the reference member of +transform_iterator is +result_of<UnaryFunction(iterator_traits<Iterator>::reference)>::type. +Otherwise, reference is Reference.

+

If Value is use_default then the value_type member is +remove_cv<remove_reference<reference> >::type. Otherwise, +value_type is Value.

+

If Iterator models Readable Lvalue Iterator and if Iterator +models Random Access Traversal Iterator, then iterator_category is +convertible to random_access_iterator_tag. Otherwise, if +Iterator models Bidirectional Traversal Iterator, then +iterator_category is convertible to +bidirectional_iterator_tag. Otherwise iterator_category is +convertible to forward_iterator_tag. If Iterator does not +model Readable Lvalue Iterator then iterator_category is +convertible to input_iterator_tag.

-

transform_iterator requirements

+

transform_iterator requirements

The type UnaryFunction must be Assignable, Copy Constructible, and the expression f(*i) must be valid where f is an object of type UnaryFunction, i is an object of type Iterator, and where the type of f(*i) must be result_of<UnaryFunction(iterator_traits<Iterator>::reference)>::type.

-

The type Iterator must at least model Readable Iterator. The -resulting transform_iterator models the most refined of the -following options that is also modeled by Iterator.

+

The argument Iterator shall model Readable Iterator.

+
+
+

transform_iterator models

+

The resulting transform_iterator models the most refined of the +following that is also modeled by Iterator.

    -
  • Writable Lvalue Iterator if result_of<UnaryFunction(iterator_traits<Iterator>::reference)>::type is a non-const reference.
  • -
  • Readable Lvalue Iterator if result_of<UnaryFunction(iterator_traits<Iterator>::reference)>::type is a const -reference.
  • +
  • Writable Lvalue Iterator if transform_iterator::reference is a non-const reference.
  • +
  • Readable Lvalue Iterator if transform_iterator::reference is a const reference.
  • Readable Iterator otherwise.

The transform_iterator models the most refined standard traversal -concept that is modeled by Iterator.

-

The reference type of transform_iterator is -result_of<UnaryFunction(iterator_traits<Iterator>::reference)>::type. -The value_type is remove_cv<remove_reference<reference> >::type.

+concept that is modeled by the Iterator argument.

+

If transform_iterator is a model of Readable Lvalue Iterator then +it models the following original iterator concepts depending on what +the Iterator argument models.

+ ++++ + + + + + + + + + + + + + + + + + + + +
If Iterator modelsthen transform_iterator models
Single Pass IteratorInput Iterator
Forward Traversal IteratorForward Iterator
Bidirectional Traversal IteratorBidirectional Iterator
Random Access Traversal IteratorRandom Access Iterator
+

If transform_iterator models Writable Lvalue Iterator then it is a +mutable iterator (as defined in the old iterator requirements).

+

transform_iterator<F1, X, R1, V1> is interoperable with +transform_iterator<F2, Y, R2, V2> if and only if X is +interoperable with Y.

-
-

transform_iterator public operations

+
+

transform_iterator operations

+

In addition to the operations required by the concepts modeled by +transform_iterator, transform_iterator provides the following +operations.

transform_iterator();

@@ -1576,44 +2062,77 @@ transform_iterator(
-
-
-

transform_iterator private operations

-

typename transform_iterator::value_type dereference() const;

+

Iterator const& base() const;

- + + + +
Returns:m_f(transform_iterator::dereference());
Returns:m_iterator
+

reference operator*() const;

+ +++ + + + +
Returns:m_f(*m_iterator)
+

transform_iterator& operator++();

+ +++ + + + + + +
Effects:++m_iterator
Returns:*this
+

transform_iterator& operator--();

+ +++ + + +
Effects:--m_iterator
Returns:*this
-

Filter iterator

+

Filter iterator

The filter iterator adaptor creates a view of an iterator range in -which some elements of the range are skipped over. A predicate -function object controls which elements are skipped. When the -predicate is applied to an element, if it returns true then the -element is retained and if it returns false then the element is -skipped over. When skipping over elements, it is necessary for the -filter adaptor to know when to stop so as to avoid going past the end -of the underlying range. Therefore the constructor of the filter -iterator takes two iterator parameters: the position for the filtered -iterator and the end of the range.

+which some elements of the range are skipped. A predicate function +object controls which elements are skipped. When the predicate is +applied to an element, if it returns true then the element is +retained and if it returns false then the element is skipped +over. When skipping over elements, it is necessary for the filter +adaptor to know when to stop so as to avoid going past the end of the +underlying range. A filter iterator is therefore constructed with pair +of iterators indicating the range of elements in the unfiltered +sequence to be traversed.

-

Class template filter_iterator

+

Class template filter_iterator

+ + + +
 template <class Predicate, class Iterator>
 class filter_iterator
-    : public iterator_adaptor<
-          filter_iterator<Predicate, Iterator>, Iterator
-        , use_default
-        , /* see details */
-      >
 {
  public:
+    typedef iterator_traits<Iterator>::value_type value_type;
+    typedef iterator_traits<Iterator>::reference reference;
+    typedef iterator_traits<Iterator>::pointer pointer;
+    typedef iterator_traits<Iterator>::difference_type difference_type;
+    typedef /* see below */ iterator_category;
+
     filter_iterator();
     filter_iterator(Predicate f, Iterator x, Iterator end = Iterator());
     filter_iterator(Iterator x, Iterator end = Iterator());
@@ -1624,45 +2143,107 @@ class filter_iterator
         );
     Predicate predicate() const;
     Iterator end() const;
-
- private: // as-if specification
-    void increment()
-    {
-        ++(this->base_reference());
-        satisfy_predicate();
-    }
-
-    void satisfy_predicate()
-    {
-        while (this->base() != this->m_end && !this->m_predicate(*this->base()))
-            ++(this->base_reference());
-    }
-
-    Predicate m_predicate;
-    Iterator m_end;
+    Iterator const& base() const;
+    reference operator*() const;
+    filter_iterator& operator++();
+private:
+    Predicate m_pred; // exposition only
+    Iterator m_iter;  // exposition only
+    Iterator m_end;   // exposition only
 };
 
-
+

If Iterator models Readable Lvalue Iterator and Forward Traversal +Iterator then iterator_category is convertible to +std::forward_iterator_tag. Otherwise iterator_category is +convertible to std::input_iterator_tag.

-

filter_iterator requirements

-

The base Iterator parameter must be a model of Readable -Iterator and Single Pass Iterator. The resulting -filter_iterator will be a model of Forward Traversal Iterator -if Iterator is, otherwise the filter_iterator will be a -model of Single Pass Iterator. The access category of the -filter_iterator will be the same as the access category of -Iterator.

- -

The Predicate must be Assignable, Copy Constructible, and the -expression p(x) must be valid where p is an object of type +

filter_iterator requirements

+

The Iterator argument shall meet the requirements of Readable +Iterator and Single Pass Iterator or it shall meet the requirements of +Input Iterator.

+

The Predicate argument must be Assignable, Copy Constructible, and +the expression p(x) must be valid where p is an object of type Predicate, x is an object of type iterator_traits<Iterator>::value_type, and where the type of p(x) must be convertible to bool.

+
+

filter_iterator models

+

The concepts that filter_iterator models are dependent on which +concepts the Iterator argument models, as specified in the +following tables.

+ ++++ + + + + + + + + + + + + + +
If Iterator modelsthen filter_iterator models
Single Pass IteratorSingle Pass Iterator
Forward Traversal IteratorForward Traversal Iterator
+ ++++ + + + + + + + + + + + + + + + + +
If Iterator modelsthen filter_iterator models
Readable IteratorReadable Iterator
Writable IteratorWritable Iterator
Lvalue IteratorLvalue Iterator
+ ++++ + + + + + + + + + + + + + + + + +
If Iterator modelsthen filter_iterator models
Readable Iterator, Single Pass IteratorInput Iterator
Readable Lvalue Iterator, Forward Traversal IteratorForward Iterator
Writable Lvalue Iterator, Forward Traversal IteratorMutable Forward Iterator
+

filter_iterator<P1, X> is interoperable with filter_iterator<P2, Y> +if and only if X is interoperable with Y.

+
-

filter_iterator operations

+

filter_iterator operations

+

In addition to those operations required by the concepts that +filter_iterator models, filter_iterator provides the following +operations.

filter_iterator();

@@ -1670,9 +2251,8 @@ expression p(x) must be valid - +
Requires:Predicate and Iterator must be Default Constructible.
Returns:a filter_iterator whose -predicate is a default constructed Predicate and -whose end is a default constructed Iterator.
Effects:Constructs a filter_iterator whose``m_pred``, m_iter, and m_end +members are a default constructed.
@@ -1681,8 +2261,10 @@ whose end is a default constru -Returns:A filter_iterator at position x that filters according -to predicate f and that will not increment past end. +Effects:Constructs a filter_iterator where m_iter is either +the first position in the range [x,end) such that f(*m_iter) == true +or else``m_iter == end``. The member m_pred is constructed from +f and m_end from end. @@ -1691,11 +2273,12 @@ to predicate f and that will n -Requires:Predicate must be Default Constructible. +Requires:Predicate must be Default Constructible and +Predicate is a class type (not a function pointer). -Returns:A filter_iterator at position x that filters -according to a default constructed Predicate -and that will not increment past end. +Effects:Constructs a filter_iterator where m_iter is either +the first position in the range [x,end) such that m_pred(*m_iter) == true +or else``m_iter == end``. The member m_pred is default constructed. @@ -1712,7 +2295,7 @@ filter_iterator( Requires:OtherIterator is implicitly convertible to Iterator. -Returns:A copy of iterator t. +Effects:Constructs a filter iterator whose members are copied from t. @@ -1721,7 +2304,7 @@ filter_iterator( -Returns:A copy of the predicate object used to construct *this. +Returns:m_pred @@ -1730,92 +2313,154 @@ filter_iterator( -Returns:The object end used to construct *this. +Returns:m_end + + + +

Iterator const& base() const;

+ +++ + + + +
Returns:m_iterator
+

reference operator*() const;

+ +++ + + + +
Returns:*m_iter
+

filter_iterator& operator++();

+ +++ + + +
Effects:Increments m_iter and then continues to +increment m_iter until either m_iter == m_end +or m_pred(*m_iter) == true.
Returns:*this
+
-

Counting iterator

-

The counting iterator adaptor implements dereference by returning a -reference to the base object. The other operations are implemented by -the base m_iterator, as per the inheritance from -iterator_adaptor.

+

Counting iterator

+

counting_iterator adapts an object by adding an operator* that +returns the current value of the object. All other iterator operations +are forwarded to the adapted object.

-

Class template counting_iterator

+

Class template counting_iterator

 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:
+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);
-    counting_iterator(Incrementable x);
- private:
-    typename counting_iterator::reference dereference() const
-    {
-        return this->base_reference();
-    }
-  };
+    explicit counting_iterator(Incrementable x);
+    Incrementable const& base() const;
+    reference operator*() const;
+    counting_iterator& operator++();
+    counting_iterator& operator--();
+private:
+    Incrementable m_inc; // exposition
+};
+
+

If the Difference argument is use_default then +difference_type is an unspecified signed integral +type. Otherwise difference_type is Difference.

+

iterator_category is determined according to the following +algorithm:

+
+if (CategoryOrTraversal is not use_default)
+    return CategoryOrTraversal
+else if (numeric_limits<Incrementable>::is_specialized)
+    return iterator-category(
+        random_access_traversal_tag, Incrementable, const Incrementable&)
+else
+    return iterator-category(
+         iterator_traversal<Incrementable>::type, 
+         Incrementable, const Incrementable&)
 
[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.]
+
operator- and a difference_type that avoids overflows in +the cases where std::numeric_limits<Incrementable>::is_specialized +is true.]
-
-

counting_iterator requirements

-

The Incrementable type must be Default Constructible, Copy -Constructible, and Assignable. The default distance is -an implementation defined signed integegral type.

-

The resulting 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:

+

counting_iterator requirements

+

The Incrementable argument shall be Copy Constructible and Assignable.

+

If iterator_category is convertible to forward_iterator_tag +or forward_traversal_tag, the following must be well-formed:

 Incrementable i, j;
-++i         // pre-increment
-i == j      // operator equal
+++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 iterator_category is convertible to +bidirectional_iterator_tag or bidirectional_traversal_tag, +the following expression must also be well-formed:

 --i
 
-

If you wish to create a counting iterator that is a Random Access -Traversal Iterator, then these additional expressions are also -required:

+

If iterator_category is convertible to +random_access_iterator_tag or random_access_traversal_tag, +the following must must also be valid:

 counting_iterator::difference_type n;
-i += n
-n = i - j
-i < j
+i += n;
+n = i - j;
+i < j;
 
+
+

counting_iterator models

+

Specializations of counting_iterator model Readable Lvalue +Iterator. In addition, they model the concepts corresponding to the +iterator tags to which their iterator_category is convertible. +Also, if CategoryOrTraversal is not use_default then +counting_iterator models the concept corresponding to the iterator +tag CategoryOrTraversal. Otherwise, if +numeric_limits<Incrementable>::is_specialized, then +counting_iterator models Random Access Traversal Iterator. +Otherwise, counting_iterator models the same iterator traversal +concepts modeled by Incrementable.

+

counting_iterator<X,C1,D1> is interoperable with +counting_iterator<Y,C2,D2> if and only if X is +interoperable with Y.

+
-

counting_iterator operations

+

counting_iterator operations

+

In addition to the operations required by the concepts modeled by +counting_iterator, counting_iterator provides the following +operations.

counting_iterator();

- + + +
Returns:A default constructed instance of counting_iterator.
Requires:Incrementable is Default Constructible.
Effects:Default construct the member m_inc.
@@ -1824,23 +2469,63 @@ i < j -Returns:An instance of counting_iterator that is a copy of rhs. +Effects:Construct member m_inc from rhs.m_inc. -

counting_iterator(Incrementable x);

+

explicit counting_iterator(Incrementable x);

- + + + +
Returns:An instance of counting_iterator with its base -object copy constructed from x.
Effects:Construct member m_inc from x.
+

reference operator*() const;

+ +++ + + + +
Returns:m_inc
+

counting_iterator& operator++();

+ +++ + + + + + +
Effects:++m_inc
Returns:*this
+

counting_iterator& operator--();

+ +++ + + + + + +
Effects:--m_inc
Returns:*this
+

Incrementable const& base() const;

+ +++ +
Returns:m_inc
+
-

Function output iterator

+

Function output iterator

The function output iterator adaptor makes it easier to create custom output iterators. The adaptor takes a unary function and creates a model of Output Iterator. Each item assigned to the output iterator is @@ -1849,60 +2534,57 @@ iterator is that creating a conforming output iterator is non-trivial, particularly because the proper implementation usually requires a proxy object.

-

Class template function_output_iterator

+

Class template function_output_iterator

 template <class UnaryFunction>
 class function_output_iterator {
 public:
-  typedef iterator_tag<
-        writable_iterator
-      , incrementable_traversal_tag
-  > iterator_category;
-  typedef void                value_type;
-  typedef void                difference_type;
-  typedef void                pointer;
-  typedef void                reference;
+  typedef std::output_iterator_tag iterator_category;
+  typedef void                     value_type;
+  typedef void                     difference_type;
+  typedef void                     pointer;
+  typedef void                     reference;
 
-  explicit function_output_iterator(const UnaryFunction& f = UnaryFunction());
+  explicit function_output_iterator();
 
-  struct output_proxy {
-    output_proxy(UnaryFunction& f);
-    template <class T> output_proxy& operator=(const T& value);
-  };
-  output_proxy operator*();
+  explicit function_output_iterator(const UnaryFunction& f);
+
+  /* see below */ operator*();
   function_output_iterator& operator++();
   function_output_iterator& operator++(int);
+private:
+  UnaryFunction m_f;     // exposition only
 };
 
-
-

function_output_iterator requirements

-

The UnaryFunction must be Assignable, Copy Constructible, and the -expression f(x) must be valid, where f is an object of type -UnaryFunction and x is an object of a type accepted by f. -The resulting function_output_iterator is a model of the Writable -and Incrementable Iterator concepts.

+

function_output_iterator requirements

+

UnaryFunction must be Assignable and Copy Constructible.

+
+
+

function_output_iterator models

+

function_output_iterator is a model of the Writable and +Incrementable Iterator concepts.

-

function_output_iterator operations

+

function_output_iterator operations

explicit function_output_iterator(const UnaryFunction& f = UnaryFunction());

- +
Returns:An instance of function_output_iterator with -f stored as a data member.
Effects:Constructs an instance of function_output_iterator +with m_f constructed from f.
-

output_proxy operator*();

+

operator*();

- +
Returns:An instance of output_proxy constructed with -a copy of the unary function f.
Returns:An object r of unspecified type such that r = t +is equivalent to m_f(t) for all t.
@@ -1924,32 +2606,6 @@ a copy of the unary function f -
-
-

function_output_iterator::output_proxy operations

-

output_proxy(UnaryFunction& f);

- --- - - - -
Returns:An instance of output_proxy with f stored as -a data member.
-

template <class T> output_proxy& operator=(const T& value);

- --- - - - -
Effects:
-m_f(value); 
-return *this; 
-
-
+ + + diff --git a/doc/facade-and-adaptor.rst b/doc/facade-and-adaptor.rst index 17174a9..754e08e 100644 --- a/doc/facade-and-adaptor.rst +++ b/doc/facade-and-adaptor.rst @@ -3,10 +3,9 @@ +++++++++++++++++++++++++++++ :Author: David Abrahams, Jeremy Siek, Thomas Witt -:Contact: dave@boost-consulting.com, jsiek@osl.iu.edu, witt@acm.org +:Contact: dave@boost-consulting.com, jsiek@osl.iu.edu, witt@styleadvisor.com :organization: `Boost Consulting`_, Indiana University `Open Systems - Lab`_, University of Hanover `Institute for Transport - Railway Operation and Construction`_ + Lab`_, `Zephyr Associates, Inc.`_ :date: $Date$ :Number: This is a revised version of N1530_\ =03-0113, which was @@ -22,7 +21,7 @@ .. _`Boost Consulting`: http://www.boost-consulting.com .. _`Open Systems Lab`: http://www.osl.iu.edu -.. _`Institute for Transport Railway Operation and Construction`: http://www.ive.uni-hannover.de +.. _`Zephyr Associates, Inc.`: http://www.styleadvisor.com :abstract: We propose a set of class templates that help programmers build standard-conforming iterators, both from scratch and @@ -197,10 +196,6 @@ which were easily implemented using ``iterator_adaptor``: * ``transform_iterator``, which applies a user-defined function object to the underlying values when dereferenced. -* ``projection_iterator``, which is similar to ``transform_iterator`` - except that when dereferenced it returns a reference instead of - a value. - * ``filter_iterator``, which provides a view of an iterator range in which some elements of the underlying range are skipped. @@ -266,6 +261,12 @@ Header ```` synopsis [lib.iterator.helper.synopsis] > class indirect_iterator; + template + struct pointee; + + template + struct indirect_reference; + template class reverse_iterator; @@ -285,7 +286,7 @@ Header ```` synopsis [lib.iterator.helper.synopsis] , class CategoryOrTraversal = use_default , class Difference = use_default > - class counting_iterator + class counting_iterator; template class function_output_iterator; @@ -352,6 +353,16 @@ Indirect iterator .. include:: indirect_iterator_abstract.rst +Class template ``pointee`` +.................................... + +.. include:: pointee_ref.rst + +Class template ``indirect_reference`` +..................................... + +.. include:: indirect_reference_ref.rst + Class template ``indirect_iterator`` .................................... diff --git a/doc/filter_iterator.html b/doc/filter_iterator.html index 2c3180f..d1d90a7 100644 --- a/doc/filter_iterator.html +++ b/doc/filter_iterator.html @@ -7,200 +7,9 @@ Filter Iterator - + - +
@@ -218,7 +27,7 @@ ul.auto-toc { Lab, University of Hanover Institute for Transport Railway Operation and Construction Date: -2003-09-14 +2004-01-13 Copyright: Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved @@ -227,37 +36,46 @@ Railway Operation and Construction -abstract: +abstract:The filter iterator adaptor creates a view of an iterator range in +which some elements of the range are skipped. A predicate function +object controls which elements are skipped. When the predicate is +applied to an element, if it returns true then the element is +retained and if it returns false then the element is skipped +over. When skipping over elements, it is necessary for the filter +adaptor to know when to stop so as to avoid going past the end of the +underlying range. A filter iterator is therefore constructed with pair +of iterators indicating the range of elements in the unfiltered +sequence to be traversed. -

The filter iterator adaptor creates a view of an iterator range in -which some elements of the range are skipped over. A predicate -function object controls which elements are skipped. When the -predicate is applied to an element, if it returns true then the -element is retained and if it returns false then the element is -skipped over. When skipping over elements, it is necessary for the -filter adaptor to know when to stop so as to avoid going past the end -of the underlying range. Therefore the constructor of the filter -iterator takes two iterator parameters: the position for the filtered -iterator and the end of the range.

+
+

filter_iterator synopsis

+ + + +
 template <class Predicate, class Iterator>
 class filter_iterator
-    : public iterator_adaptor<
-          filter_iterator<Predicate, Iterator>, Iterator
-        , use_default
-        , /* see details */
-      >
 {
  public:
+    typedef iterator_traits<Iterator>::value_type value_type;
+    typedef iterator_traits<Iterator>::reference reference;
+    typedef iterator_traits<Iterator>::pointer pointer;
+    typedef iterator_traits<Iterator>::difference_type difference_type;
+    typedef /* see below */ iterator_category;
+
     filter_iterator();
     filter_iterator(Predicate f, Iterator x, Iterator end = Iterator());
     filter_iterator(Iterator x, Iterator end = Iterator());
@@ -268,43 +86,107 @@ class filter_iterator
         );
     Predicate predicate() const;
     Iterator end() const;
-
- private: // as-if specification
-    void increment()
-    {
-        ++(this->base_reference());
-        satisfy_predicate();
-    }
-
-    void satisfy_predicate()
-    {
-        while (this->base() != this->m_end && !this->m_predicate(*this->base()))
-            ++(this->base_reference());
-    }
-
-    Predicate m_predicate;
-    Iterator m_end;
+    Iterator const& base() const;
+    reference operator*() const;
+    filter_iterator& operator++();
+private:
+    Predicate m_pred; // exposition only
+    Iterator m_iter;  // exposition only
+    Iterator m_end;   // exposition only
 };
 
+

If Iterator models Readable Lvalue Iterator and Forward Traversal +Iterator then iterator_category is convertible to +std::forward_iterator_tag. Otherwise iterator_category is +convertible to std::input_iterator_tag.

+
-

filter_iterator requirements

-

The base Iterator parameter must be a model of Readable -Iterator and Single Pass Iterator. The resulting -filter_iterator will be a model of Forward Traversal Iterator -if Iterator is, otherwise the filter_iterator will be a -model of Single Pass Iterator. The access category of the -filter_iterator will be the same as the access category of -Iterator.

- -

The Predicate must be Assignable, Copy Constructible, and the -expression p(x) must be valid where p is an object of type +

filter_iterator requirements

+

The Iterator argument shall meet the requirements of Readable +Iterator and Single Pass Iterator or it shall meet the requirements of +Input Iterator.

+

The Predicate argument must be Assignable, Copy Constructible, and +the expression p(x) must be valid where p is an object of type Predicate, x is an object of type iterator_traits<Iterator>::value_type, and where the type of p(x) must be convertible to bool.

+
+

filter_iterator models

+

The concepts that filter_iterator models are dependent on which +concepts the Iterator argument models, as specified in the +following tables.

+ ++++ + + + + + + + + + + + + + +
If Iterator modelsthen filter_iterator models
Single Pass IteratorSingle Pass Iterator
Forward Traversal IteratorForward Traversal Iterator
+ ++++ + + + + + + + + + + + + + + + + +
If Iterator modelsthen filter_iterator models
Readable IteratorReadable Iterator
Writable IteratorWritable Iterator
Lvalue IteratorLvalue Iterator
+ ++++ + + + + + + + + + + + + + + + + +
If Iterator modelsthen filter_iterator models
Readable Iterator, Single Pass IteratorInput Iterator
Readable Lvalue Iterator, Forward Traversal IteratorForward Iterator
Writable Lvalue Iterator, Forward Traversal IteratorMutable Forward Iterator
+

filter_iterator<P1, X> is interoperable with filter_iterator<P2, Y> +if and only if X is interoperable with Y.

+
-

filter_iterator operations

+

filter_iterator operations

+

In addition to those operations required by the concepts that +filter_iterator models, filter_iterator provides the following +operations.

filter_iterator();

@@ -312,9 +194,8 @@ expression p(x) must be valid - +
Requires:Predicate and Iterator must be Default Constructible.
Returns:a filter_iterator whose -predicate is a default constructed Predicate and -whose end is a default constructed Iterator.
Effects:Constructs a filter_iterator whose``m_pred``, m_iter, and m_end +members are a default constructed.
@@ -323,8 +204,10 @@ whose end is a default constru -Returns:A filter_iterator at position x that filters according -to predicate f and that will not increment past end. +Effects:Constructs a filter_iterator where m_iter is either +the first position in the range [x,end) such that f(*m_iter) == true +or else``m_iter == end``. The member m_pred is constructed from +f and m_end from end. @@ -333,11 +216,12 @@ to predicate f and that will n -Requires:Predicate must be Default Constructible. +Requires:Predicate must be Default Constructible and +Predicate is a class type (not a function pointer). -Returns:A filter_iterator at position x that filters -according to a default constructed Predicate -and that will not increment past end. +Effects:Constructs a filter_iterator where m_iter is either +the first position in the range [x,end) such that m_pred(*m_iter) == true +or else``m_iter == end``. The member m_pred is default constructed. @@ -354,7 +238,7 @@ filter_iterator( Requires:OtherIterator is implicitly convertible to Iterator. -Returns:A copy of iterator t. +Effects:Constructs a filter iterator whose members are copied from t. @@ -363,7 +247,7 @@ filter_iterator( -Returns:A copy of the predicate object used to construct *this. +Returns:m_pred @@ -372,16 +256,134 @@ filter_iterator( -Returns:The object end used to construct *this. +Returns:m_end +

Iterator const& base() const;

+ +++ + + + +
Returns:m_iterator
+

reference operator*() const;

+ +++ + + + +
Returns:*m_iter
+

filter_iterator& operator++();

+ +++ + + + + + +
Effects:Increments m_iter and then continues to +increment m_iter until either m_iter == m_end +or m_pred(*m_iter) == true.
Returns:*this
+
+template <class Predicate, class Iterator>
+filter_iterator<Predicate,Iterator>
+make_filter_iterator(Predicate f, Iterator x, Iterator end = Iterator());
+
+ +++ + + + +
Returns:filter_iterator<Predicate,Iterator>(f, x, end)
+
+template <class Predicate, class Iterator>
+filter_iterator<Predicate,Iterator>
+make_filter_iterator(Iterator x, Iterator end = Iterator());
+
+ +++ + + + +
Returns:filter_iterator<Predicate,Iterator>(x, end)
+
+
+

Example

+

This example uses filter_iterator and then +make_filter_iterator to output only the positive integers from an +array of integers. Then make_filter_iterator is is used to output +the integers greater than -2.

+
+struct is_positive_number {
+  bool operator()(int x) { return 0 < x; }
+};
+
+int main()
+{
+  int numbers_[] = { 0, -1, 4, -3, 5, 8, -2 };
+  const int N = sizeof(numbers_)/sizeof(int);
+
+  typedef int* base_iterator;
+  base_iterator numbers(numbers_);
+
+  // Example using filter_iterator
+  typedef boost::filter_iterator<is_positive_number, base_iterator>
+    FilterIter;
+
+  is_positive_number predicate;
+  FilterIter filter_iter_first(predicate, numbers, numbers + N);
+  FilterIter filter_iter_last(predicate, numbers + N, numbers + N);
+
+  std::copy(filter_iter_first, filter_iter_last, std::ostream_iterator<int>(std::cout, " "));
+  std::cout << std::endl;
+
+  // Example using make_filter_iterator()
+  std::copy(boost::make_filter_iterator<is_positive_number>(numbers, numbers + N),
+            boost::make_filter_iterator<is_positive_number>(numbers + N, numbers + N),
+            std::ostream_iterator<int>(std::cout, " "));
+  std::cout << std::endl;
+
+  // Another example using make_filter_iterator()
+  std::copy(
+      boost::make_filter_iterator(
+          std::bind2nd(std::greater<int>(), -2)
+        , numbers, numbers + N)
+
+    , boost::make_filter_iterator(
+          std::bind2nd(std::greater<int>(), -2)
+        , numbers + N, numbers + N)
+
+    , std::ostream_iterator<int>(std::cout, " ")
+  );
+
+  std::cout << std::endl;
+
+  return boost::exit_success;
+}
+
+

The output is:

+
+4 5 8 
+4 5 8 
+0 -1 4 5 8 
+
+

The source code for this example can be found here.

diff --git a/doc/filter_iterator.rst b/doc/filter_iterator.rst index acd770e..ceb7adc 100644 --- a/doc/filter_iterator.rst +++ b/doc/filter_iterator.rst @@ -16,8 +16,14 @@ :abstract: -.. include:: filter_iterator_abstract.rst + .. include:: filter_iterator_abstract.rst .. contents:: Table of Contents +``filter_iterator`` synopsis +............................ + .. include:: filter_iterator_ref.rst +.. include:: make_filter_iterator.rst + +.. include:: filter_iterator_eg.rst diff --git a/doc/filter_iterator_abstract.rst b/doc/filter_iterator_abstract.rst index 9517b23..4695478 100644 --- a/doc/filter_iterator_abstract.rst +++ b/doc/filter_iterator_abstract.rst @@ -1,10 +1,11 @@ The filter iterator adaptor creates a view of an iterator range in -which some elements of the range are skipped over. A predicate -function object controls which elements are skipped. When the -predicate is applied to an element, if it returns ``true`` then the -element is retained and if it returns ``false`` then the element is -skipped over. When skipping over elements, it is necessary for the -filter adaptor to know when to stop so as to avoid going past the end -of the underlying range. Therefore the constructor of the filter -iterator takes two iterator parameters: the position for the filtered -iterator and the end of the range. +which some elements of the range are skipped. A predicate function +object controls which elements are skipped. When the predicate is +applied to an element, if it returns ``true`` then the element is +retained and if it returns ``false`` then the element is skipped +over. When skipping over elements, it is necessary for the filter +adaptor to know when to stop so as to avoid going past the end of the +underlying range. A filter iterator is therefore constructed with pair +of iterators indicating the range of elements in the unfiltered +sequence to be traversed. + diff --git a/doc/filter_iterator_ref.rst b/doc/filter_iterator_ref.rst index 239d2f8..80c6182 100644 --- a/doc/filter_iterator_ref.rst +++ b/doc/filter_iterator_ref.rst @@ -1,14 +1,20 @@ +.. Copyright David Abrahams, Jeremy Siek, and Thomas Witt +.. 2004. Use, modification and distribution is subject to the Boost +.. Software License, Version 1.0. (See accompanying file +.. LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + :: template class filter_iterator - : public iterator_adaptor< - filter_iterator, Iterator - , use_default - , /* see details */ - > { public: + typedef iterator_traits::value_type value_type; + typedef iterator_traits::reference reference; + typedef iterator_traits::pointer pointer; + typedef iterator_traits::difference_type difference_type; + typedef /* see below */ iterator_category; + filter_iterator(); filter_iterator(Predicate f, Iterator x, Iterator end = Iterator()); filter_iterator(Iterator x, Iterator end = Iterator()); @@ -19,71 +25,107 @@ ); Predicate predicate() const; Iterator end() const; - - private: // as-if specification - void increment() - { - ++(this->base_reference()); - satisfy_predicate(); - } - - void satisfy_predicate() - { - while (this->base() != this->m_end && !this->m_predicate(*this->base())) - ++(this->base_reference()); - } - - Predicate m_predicate; - Iterator m_end; + Iterator const& base() const; + reference operator*() const; + filter_iterator& operator++(); + private: + Predicate m_pred; // exposition only + Iterator m_iter; // exposition only + Iterator m_end; // exposition only }; +If ``Iterator`` models Readable Lvalue Iterator and Forward Traversal +Iterator then ``iterator_category`` is convertible to +``std::forward_iterator_tag``. Otherwise ``iterator_category`` is +convertible to ``std::input_iterator_tag``. + + ``filter_iterator`` requirements --------------------------------- +................................ -The base ``Iterator`` parameter must be a model of Readable -Iterator and Single Pass Iterator. The resulting -``filter_iterator`` will be a model of Forward Traversal Iterator -if ``Iterator`` is, otherwise the ``filter_iterator`` will be a -model of Single Pass Iterator. The access category of the -``filter_iterator`` will be the same as the access category of -``Iterator``. +The ``Iterator`` argument shall meet the requirements of Readable +Iterator and Single Pass Iterator or it shall meet the requirements of +Input Iterator. -.. Thomas is going to try implementing filter_iterator so that - it will be bidirectional if the underlying iterator is. -JGS - - -The ``Predicate`` must be Assignable, Copy Constructible, and the -expression ``p(x)`` must be valid where ``p`` is an object of type +The ``Predicate`` argument must be Assignable, Copy Constructible, and +the expression ``p(x)`` must be valid where ``p`` is an object of type ``Predicate``, ``x`` is an object of type ``iterator_traits::value_type``, and where the type of ``p(x)`` must be convertible to ``bool``. +``filter_iterator`` models +.......................... + +The concepts that ``filter_iterator`` models are dependent on which +concepts the ``Iterator`` argument models, as specified in the +following tables. + ++-----------------------------+----------------------------------------------------------+ +| If ``Iterator`` models | then ``filter_iterator`` models | ++=============================+==========================================================+ +| Single Pass Iterator | Single Pass Iterator | ++-----------------------------+----------------------------------------------------------+ +| Forward Traversal Iterator | Forward Traversal Iterator | ++-----------------------------+----------------------------------------------------------+ + ++--------------------------------+----------------------------------------------+ +| If ``Iterator`` models | then ``filter_iterator`` models | ++================================+==============================================+ +| Readable Iterator | Readable Iterator | ++--------------------------------+----------------------------------------------+ +| Writable Iterator | Writable Iterator | ++--------------------------------+----------------------------------------------+ +| Lvalue Iterator | Lvalue Iterator | ++--------------------------------+----------------------------------------------+ + ++-------------------------------------------------------+---------------------------------+ +| If ``Iterator`` models | then ``filter_iterator`` models | ++=======================================================+=================================+ +| Readable Iterator, Single Pass Iterator | Input Iterator | ++-------------------------------------------------------+---------------------------------+ +| Readable Lvalue Iterator, Forward Traversal Iterator | Forward Iterator | ++-------------------------------------------------------+---------------------------------+ +| Writable Lvalue Iterator, Forward Traversal Iterator | Mutable Forward Iterator | ++-------------------------------------------------------+---------------------------------+ + + +``filter_iterator`` is interoperable with ``filter_iterator`` +if and only if ``X`` is interoperable with ``Y``. + ``filter_iterator`` operations ------------------------------- +.............................. + +In addition to those operations required by the concepts that +``filter_iterator`` models, ``filter_iterator`` provides the following +operations. + ``filter_iterator();`` :Requires: ``Predicate`` and ``Iterator`` must be Default Constructible. -:Returns: a ``filter_iterator`` whose - predicate is a default constructed ``Predicate`` and - whose ``end`` is a default constructed ``Iterator``. +:Effects: Constructs a ``filter_iterator`` whose``m_pred``, ``m_iter``, and ``m_end`` + members are a default constructed. ``filter_iterator(Predicate f, Iterator x, Iterator end = Iterator());`` -:Returns: A ``filter_iterator`` at position ``x`` that filters according - to predicate ``f`` and that will not increment past ``end``. +:Effects: Constructs a ``filter_iterator`` where ``m_iter`` is either + the first position in the range ``[x,end)`` such that ``f(*m_iter) == true`` + or else``m_iter == end``. The member ``m_pred`` is constructed from + ``f`` and ``m_end`` from ``end``. + ``filter_iterator(Iterator x, Iterator end = Iterator());`` -:Requires: ``Predicate`` must be Default Constructible. -:Returns: A ``filter_iterator`` at position ``x`` that filters - according to a default constructed ``Predicate`` - and that will not increment past ``end``. +:Requires: ``Predicate`` must be Default Constructible and + ``Predicate`` is a class type (not a function pointer). +:Effects: Constructs a ``filter_iterator`` where ``m_iter`` is either + the first position in the range ``[x,end)`` such that ``m_pred(*m_iter) == true`` + or else``m_iter == end``. The member ``m_pred`` is default constructed. :: @@ -95,15 +137,33 @@ expression ``p(x)`` must be valid where ``p`` is an object of type );`` :Requires: ``OtherIterator`` is implicitly convertible to ``Iterator``. -:Returns: A copy of iterator ``t``. +:Effects: Constructs a filter iterator whose members are copied from ``t``. ``Predicate predicate() const;`` -:Returns: A copy of the predicate object used to construct ``*this``. +:Returns: ``m_pred`` ``Iterator end() const;`` -:Returns: The object ``end`` used to construct ``*this``. +:Returns: ``m_end`` + +``Iterator const& base() const;`` + +:Returns: ``m_iterator`` + + + +``reference operator*() const;`` + +:Returns: ``*m_iter`` + + +``filter_iterator& operator++();`` + +:Effects: Increments ``m_iter`` and then continues to + increment ``m_iter`` until either ``m_iter == m_end`` + or ``m_pred(*m_iter) == true``. +:Returns: ``*this`` diff --git a/doc/function_output_iterator.html b/doc/function_output_iterator.html index 8af8f32..e3ea4e8 100644 --- a/doc/function_output_iterator.html +++ b/doc/function_output_iterator.html @@ -7,200 +7,9 @@ Function Output Iterator - + - +
@@ -218,7 +27,7 @@ ul.auto-toc { Lab, University of Hanover Institute for Transport Railway Operation and Construction Date: -2003-09-14 +2004-01-13 Copyright: Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved @@ -227,76 +36,74 @@ Railway Operation and Construction -abstract: - - - -

The function output iterator adaptor makes it easier to create custom +abstract:The function output iterator adaptor makes it easier to create custom output iterators. The adaptor takes a unary function and creates a model of Output Iterator. Each item assigned to the output iterator is passed as an argument to the unary function. The motivation for this iterator is that creating a conforming output iterator is non-trivial, particularly because the proper implementation usually requires a -proxy object.

+proxy object. + + +
 template <class UnaryFunction>
 class function_output_iterator {
 public:
-  typedef iterator_tag<
-        writable_iterator
-      , incrementable_traversal_tag
-  > iterator_category;
-  typedef void                value_type;
-  typedef void                difference_type;
-  typedef void                pointer;
-  typedef void                reference;
+  typedef std::output_iterator_tag iterator_category;
+  typedef void                     value_type;
+  typedef void                     difference_type;
+  typedef void                     pointer;
+  typedef void                     reference;
 
-  explicit function_output_iterator(const UnaryFunction& f = UnaryFunction());
+  explicit function_output_iterator();
 
-  struct output_proxy {
-    output_proxy(UnaryFunction& f);
-    template <class T> output_proxy& operator=(const T& value);
-  };
-  output_proxy operator*();
+  explicit function_output_iterator(const UnaryFunction& f);
+
+  /* see below */ operator*();
   function_output_iterator& operator++();
   function_output_iterator& operator++(int);
+private:
+  UnaryFunction m_f;     // exposition only
 };
 

function_output_iterator requirements

-

The UnaryFunction must be Assignable, Copy Constructible, and the -expression f(x) must be valid, where f is an object of type -UnaryFunction and x is an object of a type accepted by f. -The resulting function_output_iterator is a model of the Writable -and Incrementable Iterator concepts.

+

UnaryFunction must be Assignable and Copy Constructible.

+
+
+

function_output_iterator models

+

function_output_iterator is a model of the Writable and +Incrementable Iterator concepts.

-

function_output_iterator operations

+

function_output_iterator operations

explicit function_output_iterator(const UnaryFunction& f = UnaryFunction());

- +
Returns:An instance of function_output_iterator with -f stored as a data member.
Effects:Constructs an instance of function_output_iterator +with m_f constructed from f.
-

output_proxy operator*();

+

operator*();

- +
Returns:An instance of output_proxy constructed with -a copy of the unary function f.
Returns:An object r of unspecified type such that r = t +is equivalent to m_f(t) for all t.
@@ -319,37 +126,45 @@ a copy of the unary function f
-
-

function_output_iterator::output_proxy operations

-

output_proxy(UnaryFunction& f);

- --- - - - -
Returns:An instance of output_proxy with f stored as -a data member.
-

template <class T> output_proxy& operator=(const T& value);

- --- - - - -
Effects:
-m_f(value); 
-return *this; 
+
+

Example

+
+struct string_appender
+{
+    string_appender(std::string& s)
+        : m_str(&s)
+    {}
+
+    void operator()(const std::string& x) const
+    {
+        *m_str += x;
+    }
+
+    std::string* m_str;
+};
+
+int main(int, char*[])
+{
+  std::vector<std::string> x;
+  x.push_back("hello");
+  x.push_back(" ");
+  x.push_back("world");
+  x.push_back("!");
+
+  std::string s = "";
+  std::copy(x.begin(), x.end(), 
+            boost::make_function_output_iterator(string_appender(s)));
+
+  std::cout << s << std::endl;
+
+  return 0;
+}
 
-
diff --git a/doc/function_output_iterator.rst b/doc/function_output_iterator.rst index d1740fb..01ac022 100644 --- a/doc/function_output_iterator.rst +++ b/doc/function_output_iterator.rst @@ -16,8 +16,9 @@ :abstract: -.. include:: function_output_iterator_abstract.rst + .. include:: function_output_iterator_abstract.rst .. contents:: Table of Contents .. include:: function_output_iterator_ref.rst +.. include:: function_output_iterator_eg.rst \ No newline at end of file diff --git a/doc/function_output_iterator_ref.rst b/doc/function_output_iterator_ref.rst index bee8a60..f46a91c 100644 --- a/doc/function_output_iterator_ref.rst +++ b/doc/function_output_iterator_ref.rst @@ -3,50 +3,53 @@ template class function_output_iterator { public: - typedef iterator_tag< - writable_iterator - , incrementable_traversal_tag - > iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; + typedef std::output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; - explicit function_output_iterator(const UnaryFunction& f = UnaryFunction()); + explicit function_output_iterator(); - struct output_proxy { - output_proxy(UnaryFunction& f); - template output_proxy& operator=(const T& value); - }; - output_proxy operator*(); + explicit function_output_iterator(const UnaryFunction& f); + + /* see below */ operator*(); function_output_iterator& operator++(); function_output_iterator& operator++(int); + private: + UnaryFunction m_f; // exposition only }; -``function_output_iterator`` requirements ------------------------------------------ -The ``UnaryFunction`` must be Assignable, Copy Constructible, and the -expression ``f(x)`` must be valid, where ``f`` is an object of type -``UnaryFunction`` and ``x`` is an object of a type accepted by ``f``. -The resulting ``function_output_iterator`` is a model of the Writable -and Incrementable Iterator concepts. +``function_output_iterator`` requirements +......................................... + +``UnaryFunction`` must be Assignable and Copy Constructible. + + + +``function_output_iterator`` models +................................... + +``function_output_iterator`` is a model of the Writable and +Incrementable Iterator concepts. + ``function_output_iterator`` operations ---------------------------------------- +....................................... ``explicit function_output_iterator(const UnaryFunction& f = UnaryFunction());`` -:Returns: An instance of ``function_output_iterator`` with - ``f`` stored as a data member. +:Effects: Constructs an instance of ``function_output_iterator`` + with ``m_f`` constructed from ``f``. -``output_proxy operator*();`` +``operator*();`` -:Returns: An instance of ``output_proxy`` constructed with - a copy of the unary function ``f``. +:Returns: An object ``r`` of unspecified type such that ``r = t`` + is equivalent to ``m_f(t)`` for all ``t``. ``function_output_iterator& operator++();`` @@ -57,21 +60,3 @@ and Incrementable Iterator concepts. ``function_output_iterator& operator++(int);`` :Returns: ``*this`` - - -``function_output_iterator::output_proxy`` operations ------------------------------------------------------ - -``output_proxy(UnaryFunction& f);`` - -:Returns: An instance of ``output_proxy`` with ``f`` stored as - a data member. - - -``template output_proxy& operator=(const T& value);`` - -:Effects: - :: - - m_f(value); - return *this; diff --git a/doc/generate.py b/doc/generate.py index 86572ba..a6d3f31 100644 --- a/doc/generate.py +++ b/doc/generate.py @@ -23,7 +23,7 @@ else: for s in sources ] - print 'make %s' % ' '.join(all) - syscmd('make %s' % ' '.join(all)) + print 'make -k %s' % ' '.join(all) + syscmd('make -k %s' % ' '.join(all)) diff --git a/doc/index.html b/doc/index.html index b3a3a14..4afe734 100755 --- a/doc/index.html +++ b/doc/index.html @@ -5,198 +5,7 @@ The Boost.Iterator Library Boost - +