From 4a3fd9984ddd10557946307c240c8e2fcd66cd21 Mon Sep 17 00:00:00 2001 From: Jeremy Siek Date: Mon, 12 Jan 2004 15:53:04 +0000 Subject: [PATCH] filled out some missing operator--, added a comment about the operations and concepts, and added some text to the indirect iterator example [SVN r21629] --- doc/counting_iterator.html | 51 +++-- doc/counting_iterator.rst | 3 + doc/counting_iterator_ref.rst | 27 ++- doc/facade-and-adaptor.html | 340 ++++++++++++++++++++------------- doc/filter_iterator.html | 22 ++- doc/filter_iterator.rst | 3 + doc/index.html | 6 +- doc/index.rst | 10 +- doc/indirect_iterator.html | 73 ++++++- doc/indirect_iterator.rst | 3 + doc/indirect_iterator_eg.rst | 10 + doc/indirect_iterator_ref.rst | 25 +++ doc/reverse_iterator.html | 33 +++- doc/reverse_iterator.rst | 2 +- doc/reverse_iterator_ref.rst | 13 ++ doc/transform_iterator.html | 42 ++-- doc/transform_iterator.rst | 3 + doc/transform_iterator_ref.rst | 17 +- 18 files changed, 482 insertions(+), 201 deletions(-) diff --git a/doc/counting_iterator.html b/doc/counting_iterator.html index c7debc3..0e9af8f 100644 --- a/doc/counting_iterator.html +++ b/doc/counting_iterator.html @@ -45,12 +45,15 @@ adding an operator* that retur

Table of Contents

+
+

counting_iterator synopsis

 template <
     class Incrementable
@@ -64,8 +67,11 @@ class counting_iterator
     counting_iterator(counting_iterator const& rhs);
     explicit counting_iterator(Incrementable x);
     Incrementable base() const;
+    reference operator*() const;
+    counting_iterator& operator++();
+    counting_iterator& operator--();
  private:
-    Incrementable current; // exposition
+    Incrementable m_inc; // exposition
   };
 
@@ -73,14 +79,15 @@ class counting_iterator
distance_to and a difference_type that avoids overflows in the cases when the Incrementable type is a numeric type.]
+
-

counting_iterator requirements

+

counting_iterator requirements

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

-

counting_iterator models

+

counting_iterator models

counting_iterator models Readable Lvalue Iterator.

Furthermore, if you wish to create a counting iterator that is a Forward Traversal Iterator, then the following expressions must be valid:

@@ -105,7 +112,10 @@ i < j
-

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();

@@ -129,7 +139,7 @@ i < j - @@ -139,7 +149,7 @@ constructed from x. - +
Returns:An instance of counting_iterator with current +
Returns:An instance of counting_iterator with m_inc constructed from x.
Returns:current
Returns:m_inc
@@ -148,7 +158,20 @@ constructed from x. -Effects:++current +Effects:++m_inc + +Returns:*this + + + +

counting_iterator& operator--();

+ +++ + + +
Effects:--m_inc
Returns:*this
@@ -157,7 +180,7 @@ constructed from x. -Returns:current +Returns:m_inc @@ -176,7 +199,7 @@ with current constructed from
-

Example

+

Example

This example fills an array with numbers and a second array with pointers into the first array, using counting_iterator for both tasks. Finally indirect_iterator is used to print out the numbers @@ -211,7 +234,7 @@ indirectly printing out the numbers from 0 to 7

diff --git a/doc/counting_iterator.rst b/doc/counting_iterator.rst index 52b38da..47db740 100644 --- a/doc/counting_iterator.rst +++ b/doc/counting_iterator.rst @@ -20,6 +20,9 @@ .. contents:: Table of Contents +``counting_iterator`` synopsis +.............................. + .. include:: counting_iterator_ref.rst .. include:: make_counting_iterator.rst diff --git a/doc/counting_iterator_ref.rst b/doc/counting_iterator_ref.rst index 4d5b46d..a5fdc05 100644 --- a/doc/counting_iterator_ref.rst +++ b/doc/counting_iterator_ref.rst @@ -12,8 +12,11 @@ counting_iterator(counting_iterator const& rhs); explicit counting_iterator(Incrementable x); Incrementable base() const; + reference operator*() const; + counting_iterator& operator++(); + counting_iterator& operator--(); private: - Incrementable current; // exposition + Incrementable m_inc; // exposition }; @@ -61,6 +64,11 @@ required:: ``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``. @@ -74,20 +82,27 @@ required:: ``explicit counting_iterator(Incrementable x);`` -:Returns: An instance of ``counting_iterator`` with ``current`` +:Returns: An instance of ``counting_iterator`` with ``m_inc`` constructed from ``x``. ``reference operator*() const;`` -:Returns: ``current`` +:Returns: ``m_inc`` ``counting_iterator& operator++();`` -:Effects: ``++current`` - +:Effects: ``++m_inc`` +:Returns: ``*this`` + + +``counting_iterator& operator--();`` + +:Effects: ``--m_inc`` +:Returns: ``*this`` + ``Incrementable base() const;`` -:Returns: ``current`` \ No newline at end of file +:Returns: ``m_inc`` diff --git a/doc/facade-and-adaptor.html b/doc/facade-and-adaptor.html index 2084dd0..83e07bc 100755 --- a/doc/facade-and-adaptor.html +++ b/doc/facade-and-adaptor.html @@ -56,82 +56,82 @@ 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 @@ -226,15 +226,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 @@ -244,7 +244,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.

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

-

Iterator Facade

+

Iterator Facade

-

Class template indirect_iterator

+

Class template indirect_iterator

 template <
     class Iterator
@@ -1289,6 +1280,9 @@ class indirect_iterator
     );
 
     Iterator base() const;
+    reference operator*() const;
+    indirect_iterator& operator++();
+    indirect_iterator& operator--();
 private:
    Iterator m_iterator; // exposition
 };
@@ -1325,7 +1319,7 @@ satisfies the requirements of the concepts modeled by the indirect
 iterator as specified in the models section.

-

indirect_iterator requirements

+

indirect_iterator requirements

The Iterator argument shall meet the requirements of Readable Iterator. The CategoryOrTraversal argument shall be one of the standard iterator tags or use_default. If CategoryOrTraversal @@ -1341,7 +1335,7 @@ is not use_default, as implied default for the value_type member.

-

indirect_iterator models

+

indirect_iterator models

If CategoryOrTraversal is a standard iterator tag, indirect_iterator is a model of the iterator concept corresponding to the tag, otherwise indirect_iterator satisfies the requirements @@ -1355,7 +1349,10 @@ the Iterator argument.

indirect_iterator models Lvalue Iterator.

-

indirect_iterator operations

+

indirect_iterator operations

+

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

indirect_iterator();

@@ -1410,16 +1407,47 @@ indirect_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

+

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.

-

Class template reverse_iterator

+

Class template reverse_iterator

 template <class Iterator>
 class reverse_iterator
@@ -1436,25 +1464,29 @@ public:
   Iterator base() const;
   reference operator*() const;
   reverse_iterator& operator++();
+  reverse_iterator& operator--();
 private:
   Iterator m_iterator; // exposition
 };
 
-

reverse_iterator requirements

+

reverse_iterator requirements

The base Iterator must be a model of Bidirectional Traversal Iterator and Readable Iterator.

-

reverse_iterator models

+

reverse_iterator models

reverse_iterator models Bidirectional Traversal Iterator and Readable Iterator. In addition, reverse_iterator models the same standard iterator access concepts that the Iterator argument models.

-

reverse_iterator operations

+

reverse_iterator operations

+

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

reverse_iterator();

@@ -1527,17 +1559,28 @@ return *..tmp;
+

reverse_iterator& operator--();

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

Transform iterator

+

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.

-

Class template transform_iterator

+

Class template transform_iterator

 template <class UnaryFunction,
@@ -1556,11 +1599,11 @@ public:
       , typename enable_if_convertible<I2, Iterator>::type* = 0      // exposition
       , typename enable_if_convertible<F2, UnaryFunction>::type* = 0 // exposition
   );
-
-  reference operator*() const;
-  transform_iterator& operator++();
   Iterator base() const;
   UnaryFunction functor() const;
+  reference operator*() const;
+  transform_iterator& operator++();
+  transform_iterator& operator--();
 private:
   Iterator m_iterator; // exposition
   UnaryFunction m_f;   // exposition
@@ -1568,7 +1611,7 @@ private:
 
-

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 @@ -1577,7 +1620,7 @@ where the type of f(*i) must b

The type Iterator must at least model Readable Iterator.

-

transform_iterator models

+

transform_iterator models

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

@@ -1595,7 +1638,10 @@ concept that is modeled by Iterator The value_type is remove_cv<remove_reference<reference> >::type.

-

transform_iterator 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();

@@ -1671,10 +1717,21 @@ transform_iterator(
+

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 @@ -1686,7 +1743,7 @@ 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.

-

Class template filter_iterator

+

Class template filter_iterator

 template <class Predicate, class Iterator>
 class filter_iterator
@@ -1722,7 +1779,7 @@ corresponding to each standard concept modeled by 
 
-

filter_iterator requirements

+

filter_iterator requirements

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 @@ -1733,7 +1790,7 @@ Iterator and Single Pass Iterator or it shall meet the requirements of Input Iterator.

-

filter_iterator models

+

filter_iterator models

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

@@ -1802,7 +1859,7 @@ following tables.

-

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.

@@ -1912,11 +1969,11 @@ or m_pred(*m_iter) -

Counting iterator

+

Counting iterator

counting_iterator adapts an arithmetic type, such as int, by adding an operator* that returns the current value of the object.

-

Class template counting_iterator

+

Class template counting_iterator

 template <
     class Incrementable
@@ -1930,8 +1987,11 @@ class counting_iterator
     counting_iterator(counting_iterator const& rhs);
     explicit counting_iterator(Incrementable x);
     Incrementable base() const;
+    reference operator*() const;
+    counting_iterator& operator++();
+    counting_iterator& operator--();
  private:
-    Incrementable current; // exposition
+    Incrementable m_inc; // exposition
   };
 
@@ -1941,13 +2001,13 @@ the cases when the Incrementable
-

counting_iterator requirements

+

counting_iterator requirements

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

-

counting_iterator models

+

counting_iterator models

counting_iterator models Readable Lvalue Iterator.

Furthermore, if you wish to create a counting iterator that is a Forward Traversal Iterator, then the following expressions must be valid:

@@ -1972,7 +2032,10 @@ i < j
-

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();

@@ -1996,7 +2059,7 @@ i < j - @@ -2006,7 +2069,7 @@ constructed from x. - +
Returns:An instance of counting_iterator with current +
Returns:An instance of counting_iterator with m_inc constructed from x.
Returns:current
Returns:m_inc
@@ -2015,7 +2078,20 @@ constructed from x. -Effects:++current +Effects:++m_inc + +Returns:*this + + + +

counting_iterator& operator--();

+ +++ + + +
Effects:--m_inc
Returns:*this
@@ -2024,14 +2100,14 @@ constructed from x. -Returns:current +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 @@ -2040,7 +2116,7 @@ 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 {
@@ -2067,7 +2143,7 @@ public:
 
-

function_output_iterator requirements

+

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. @@ -2075,7 +2151,7 @@ The resulting function_output_iterator

-

function_output_iterator operations

+

function_output_iterator operations

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

@@ -2116,7 +2192,7 @@ a copy of the unary function f
-

function_output_iterator::output_proxy operations

+

function_output_iterator::output_proxy operations

output_proxy(UnaryFunction& f);

@@ -2154,7 +2230,7 @@ LocalWords: OtherIncrementable Coplien --> diff --git a/doc/filter_iterator.html b/doc/filter_iterator.html index 4a8139e..bd57fd4 100644 --- a/doc/filter_iterator.html +++ b/doc/filter_iterator.html @@ -53,12 +53,15 @@ iterator and the end of the range.

+
+

filter_iterator synopsis

 template <class Predicate, class Iterator>
 class filter_iterator
@@ -92,8 +95,9 @@ private:
 

The iterator_category member is a type convertible to the tags corresponding to each standard concept modeled by filter_iterator, as described in the models section.

+
-

filter_iterator requirements

+

filter_iterator requirements

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 @@ -104,7 +108,7 @@ Iterator and Single Pass Iterator or it shall meet the requirements of Input Iterator.

-

filter_iterator models

+

filter_iterator models

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

@@ -173,7 +177,7 @@ following tables.

-

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.

@@ -313,7 +317,7 @@ constructed Predicate, or else
-

Example

+

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 @@ -377,7 +381,7 @@ int main()

diff --git a/doc/filter_iterator.rst b/doc/filter_iterator.rst index d460b5c..b4e3286 100644 --- a/doc/filter_iterator.rst +++ b/doc/filter_iterator.rst @@ -20,6 +20,9 @@ .. contents:: Table of Contents +``filter_iterator`` synopsis +............................ + .. include:: filter_iterator_ref.rst .. include:: make_filter_iterator.rst diff --git a/doc/index.html b/doc/index.html index 05a0952..0934cfc 100755 --- a/doc/index.html +++ b/doc/index.html @@ -150,8 +150,8 @@ testing iterator interoperability

Testing and Concept Checking

@@ -226,7 +226,7 @@ LocalWords: TraversalTag typename lvalues DWA Hmm JGS --> diff --git a/doc/index.rst b/doc/index.rst index 462686a..9b965c0 100755 --- a/doc/index.rst +++ b/doc/index.rst @@ -187,16 +187,16 @@ Traits Testing and Concept Checking ---------------------------- -* |iterator_archetypes|_: Add summary here +* |iterator_concepts|_: Concept checking classes for the new iterator concepts. -* |iterator_concepts|_: Add summary - -.. |iterator_archetypes| replace:: ``iterator_archetypes.hpp`` -.. _iterator_archetypes: iterator_archetypes.html +* |iterator_archetypes|_: Concept archetype classes for the new iterators concepts. .. |iterator_concepts| replace:: ``iterator_concepts.hpp`` .. _iterator_concepts: iterator_concepts.html +.. |iterator_archetypes| replace:: ``iterator_archetypes.hpp`` +.. _iterator_archetypes: iterator_archetypes.html + ======================================================= Upgrading from the old Boost Iterator Adaptor Library diff --git a/doc/indirect_iterator.html b/doc/indirect_iterator.html index cd2362c..84a4d50 100644 --- a/doc/indirect_iterator.html +++ b/doc/indirect_iterator.html @@ -3,7 +3,7 @@ - + Indirect Iterator @@ -50,12 +50,15 @@ iterators over smart pointers, which the impl handles. -JGS --> +
+

indirect_iterator synopsis

 template <
     class Iterator
@@ -88,6 +91,9 @@ class indirect_iterator
     );
 
     Iterator base() const;
+    reference operator*() const;
+    indirect_iterator& operator++();
+    indirect_iterator& operator--();
 private:
    Iterator m_iterator; // exposition
 };
@@ -122,8 +128,9 @@ else
 

The member indirect_iterator::iterator_category is a type that satisfies the requirements of the concepts modeled by the indirect iterator as specified in the models section.

+
-

indirect_iterator requirements

+

indirect_iterator requirements

The Iterator argument shall meet the requirements of Readable Iterator. The CategoryOrTraversal argument shall be one of the standard iterator tags or use_default. If CategoryOrTraversal @@ -139,7 +146,7 @@ is not use_default, as implied default for the value_type member.

-

indirect_iterator models

+

indirect_iterator models

If CategoryOrTraversal is a standard iterator tag, indirect_iterator is a model of the iterator concept corresponding to the tag, otherwise indirect_iterator satisfies the requirements @@ -153,7 +160,10 @@ the Iterator argument.

indirect_iterator models Lvalue Iterator.

-

indirect_iterator operations

+

indirect_iterator operations

+

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

indirect_iterator();

@@ -208,9 +218,48 @@ indirect_iterator(
+

reference operator*() const;

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

indirect_iterator& operator++();

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

indirect_iterator& operator--();

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

Example

+

Example

+

This example prints an array of characters, using +indirect_iterator to access the array of characters through an +array of pointers. Next indirect_iterator is used with the +transform algorithm to copy the characters (incremented by one) to +another array. A constant indirect iterator is used for the source and +a mutable indirect iterator is used for the destination. The last part +of the example prints the original array of characters, but this time +using the make_indirect_iterator helper function.

 char characters[] = "abcdefg";
 const int N = sizeof(characters)/sizeof(char) - 1; // -1 since characters has a null char
@@ -262,5 +311,11 @@ a,b,c,d,e,f,g,
 
+ + diff --git a/doc/indirect_iterator.rst b/doc/indirect_iterator.rst index 4e12086..3624834 100644 --- a/doc/indirect_iterator.rst +++ b/doc/indirect_iterator.rst @@ -20,5 +20,8 @@ .. contents:: Table of Contents +``indirect_iterator`` synopsis +.............................. + .. include:: indirect_iterator_ref.rst .. include:: indirect_iterator_eg.rst diff --git a/doc/indirect_iterator_eg.rst b/doc/indirect_iterator_eg.rst index 347aa95..9e92cc3 100644 --- a/doc/indirect_iterator_eg.rst +++ b/doc/indirect_iterator_eg.rst @@ -1,6 +1,15 @@ Example ....... +This example prints an array of characters, using +``indirect_iterator`` to access the array of characters through an +array of pointers. Next ``indirect_iterator`` is used with the +``transform`` algorithm to copy the characters (incremented by one) to +another array. A constant indirect iterator is used for the source and +a mutable indirect iterator is used for the destination. The last part +of the example prints the original array of characters, but this time +using the ``make_indirect_iterator`` helper function. + :: @@ -52,3 +61,4 @@ The output is:: a,b,c,d,e,f,g, b,c,d,e,f,g,h, a,b,c,d,e,f,g, + diff --git a/doc/indirect_iterator_ref.rst b/doc/indirect_iterator_ref.rst index 48072c8..e385364 100644 --- a/doc/indirect_iterator_ref.rst +++ b/doc/indirect_iterator_ref.rst @@ -31,6 +31,9 @@ ); Iterator base() const; + reference operator*() const; + indirect_iterator& operator++(); + indirect_iterator& operator--(); private: Iterator m_iterator; // exposition }; @@ -108,6 +111,11 @@ the ``Iterator`` argument. ``indirect_iterator`` operations ................................ +In addition to the operations required by the concepts modeled by +``indirect_iterator``, ``indirect_iterator`` provides the following +operations. + + ``indirect_iterator();`` :Requires: ``Iterator`` must be Default Constructible. @@ -141,3 +149,20 @@ the ``Iterator`` argument. ``Iterator 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`` diff --git a/doc/reverse_iterator.html b/doc/reverse_iterator.html index 12d5b05..19fc39a 100644 --- a/doc/reverse_iterator.html +++ b/doc/reverse_iterator.html @@ -47,14 +47,12 @@ invoking operator--() moves th

reverse_iterator synopsis

@@ -74,24 +72,29 @@ public: Iterator base() const; reference operator*() const; reverse_iterator& operator++(); + reverse_iterator& operator--(); private: Iterator m_iterator; // exposition }; +
-

reverse_iterator requirements

+

reverse_iterator requirements

The base Iterator must be a model of Bidirectional Traversal Iterator and Readable Iterator.

-

reverse_iterator models

+

reverse_iterator models

reverse_iterator models Bidirectional Traversal Iterator and Readable Iterator. In addition, reverse_iterator models the same standard iterator access concepts that the Iterator argument models.

-

reverse_iterator operations

+

reverse_iterator operations

+

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

reverse_iterator();

@@ -164,6 +167,17 @@ return *..tmp;
+

reverse_iterator& operator--();

+ +++ + + + + + +
Effects:++m_iterator
Returns:*this
 template <class BidirectionalIterator>
 reverse_iterator<BidirectionalIterator>n
@@ -180,7 +194,7 @@ with a current constructed fro
 
 
-

Example

+

Example

The following example prints an array of characters in reverse order using reverse_iterator.

@@ -213,6 +227,11 @@ sequence in double-reversed (normal) order:     hello world!
 
+ + diff --git a/doc/reverse_iterator.rst b/doc/reverse_iterator.rst index 9bfa857..000a770 100644 --- a/doc/reverse_iterator.rst +++ b/doc/reverse_iterator.rst @@ -21,7 +21,7 @@ .. contents:: Table of Contents ``reverse_iterator`` synopsis ------------------------------ +............................. .. include:: reverse_iterator_ref.rst .. include:: make_reverse_iterator.rst diff --git a/doc/reverse_iterator_ref.rst b/doc/reverse_iterator_ref.rst index 0e9b35b..ea6e54d 100644 --- a/doc/reverse_iterator_ref.rst +++ b/doc/reverse_iterator_ref.rst @@ -15,6 +15,7 @@ Iterator base() const; reference operator*() const; reverse_iterator& operator++(); + reverse_iterator& operator--(); private: Iterator m_iterator; // exposition }; @@ -40,6 +41,12 @@ argument models. ``reverse_iterator`` operations ............................... +In addition to the operations required by the concepts modeled by +``reverse_iterator``, ``reverse_iterator`` provides the following +operations. + + + ``reverse_iterator();`` :Requires: ``Iterator`` must be Default Constructible. @@ -85,3 +92,9 @@ argument models. :Effects: ``--m_iterator`` :Returns: ``*this`` + + +``reverse_iterator& operator--();`` + +:Effects: ``++m_iterator`` +:Returns: ``*this`` diff --git a/doc/transform_iterator.html b/doc/transform_iterator.html index 9d16f44..0cd3f24 100644 --- a/doc/transform_iterator.html +++ b/doc/transform_iterator.html @@ -48,12 +48,15 @@ then returns the result.

+
+

transform_iterator synopsis

 template <class UnaryFunction,
@@ -72,18 +75,19 @@ public:
       , typename enable_if_convertible<I2, Iterator>::type* = 0      // exposition
       , typename enable_if_convertible<F2, UnaryFunction>::type* = 0 // exposition
   );
-
-  reference operator*() const;
-  transform_iterator& operator++();
   Iterator base() const;
   UnaryFunction functor() const;
+  reference operator*() const;
+  transform_iterator& operator++();
+  transform_iterator& operator--();
 private:
   Iterator m_iterator; // exposition
   UnaryFunction m_f;   // exposition
 };
 
+
-

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 @@ -92,7 +96,7 @@ where the type of f(*i) must b

The type Iterator must at least model Readable Iterator.

-

transform_iterator models

+

transform_iterator models

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

@@ -110,7 +114,10 @@ concept that is modeled by Iterator The value_type is remove_cv<remove_reference<reference> >::type.

-

transform_iterator 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();

@@ -186,6 +193,17 @@ transform_iterator(
+

transform_iterator& operator--();

+ +++ + + + + + +
Effects:--m_iterator
Returns:*this
 template <class UnaryFunction, class Iterator>
 transform_iterator<UnaryFunction, Iterator>
@@ -216,7 +234,7 @@ default constructed and m_iterator<
 
 
-

Example

+

Example

This is a simple example of using the transform_iterators class to generate iterators that multiply (or add to) the value returned by dereferencing the iterator. It would be cooler to use lambda library @@ -254,7 +272,7 @@ adding 4 to each element in the array:

diff --git a/doc/transform_iterator.rst b/doc/transform_iterator.rst index 8e39d07..d49e35c 100644 --- a/doc/transform_iterator.rst +++ b/doc/transform_iterator.rst @@ -20,6 +20,9 @@ .. contents:: Table of Contents +``transform_iterator`` synopsis +............................... + .. include:: transform_iterator_ref.rst .. include:: make_transform_iterator.rst .. include:: transform_iterator_eg.rst diff --git a/doc/transform_iterator_ref.rst b/doc/transform_iterator_ref.rst index 247378a..f4528e3 100644 --- a/doc/transform_iterator_ref.rst +++ b/doc/transform_iterator_ref.rst @@ -18,11 +18,11 @@ , typename enable_if_convertible::type* = 0 // exposition , typename enable_if_convertible::type* = 0 // exposition ); - - reference operator*() const; - transform_iterator& operator++(); Iterator base() const; UnaryFunction functor() const; + reference operator*() const; + transform_iterator& operator++(); + transform_iterator& operator--(); private: Iterator m_iterator; // exposition UnaryFunction m_f; // exposition @@ -66,6 +66,11 @@ The ``value_type`` is ``remove_cv >::type``. ``transform_iterator`` operations ................................. +In addition to the operations required by the concepts modeled by +``transform_iterator``, ``transform_iterator`` provides the following +operations. + + ``transform_iterator();`` :Returns: An instance of ``transform_iterator`` with ``m_f`` @@ -110,3 +115,9 @@ The ``value_type`` is ``remove_cv >::type``. :Effects: ``++m_iterator`` :Returns: ``*this`` + +``transform_iterator& operator--();`` + +:Effects: ``--m_iterator`` +:Returns: ``*this`` +