@@ -435,11 +208,5 @@ indirectly printing out the numbers from 0 to 7
-
-
diff --git a/doc/counting_iterator_eg.rst b/doc/counting_iterator_eg.rst
index 98d27ec..a5e6baa 100644
--- a/doc/counting_iterator_eg.rst
+++ b/doc/counting_iterator_eg.rst
@@ -1,6 +1,6 @@
Example
--------
+.......
This example fills an array with numbers and a second array with
pointers into the first array, using ``counting_iterator`` for both
diff --git a/doc/counting_iterator_ref.rst b/doc/counting_iterator_ref.rst
index 42d283a..4d5b46d 100644
--- a/doc/counting_iterator_ref.rst
+++ b/doc/counting_iterator_ref.rst
@@ -22,7 +22,7 @@
the cases when the ``Incrementable`` type is a numeric type.]
``counting_iterator`` requirements
-----------------------------------
+..................................
The ``Incrementable`` type must be Default Constructible, Copy
Constructible, and Assignable. The default distance is
@@ -30,7 +30,7 @@ an implementation defined signed integral type.
``counting_iterator`` models
-----------------------------
+............................
``counting_iterator`` models Readable Lvalue Iterator.
@@ -59,7 +59,7 @@ required::
``counting_iterator`` operations
---------------------------------
+................................
``counting_iterator();``
diff --git a/doc/facade-and-adaptor.html b/doc/facade-and-adaptor.html
index 7db6b6b..c724be1 100755
--- a/doc/facade-and-adaptor.html
+++ b/doc/facade-and-adaptor.html
@@ -3,239 +3,12 @@
-
+
Iterator Facade and Adaptor
-
+
@@ -332,36 +105,34 @@ by adapting other iterators.
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.
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
@@ -1783,7 +1555,7 @@ where the type of f(*i) must b
The type Iterator must at least model Readable Iterator.
The filter iterator adaptor creates a view of an iterator range in
@@ -1921,9 +1694,8 @@ class filter_iterator
corresponding to each standard concept modeled by filter_iterator,
as described in the models section.
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
@@ -1934,7 +1706,7 @@ Iterator and Single Pass Iterator or it shall meet the requirements of
Input Iterator.
counting_iterator adapts an arithmetic type, such as int, by
@@ -2135,15 +1908,14 @@ class counting_iterator
the cases when the Incrementable type is a numeric type.]
The Incrementable type must be Default Constructible, Copy
Constructible, and Assignable. The default distance is
an implementation defined signed integral type.
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.
@@ -2271,7 +2043,7 @@ The resulting function_output_iterator
The iterator_category member is a type convertible to the tags
@@ -406,9 +184,8 @@ operations.
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.
+
Returns:
a filter_iterator whose``m_pred``, m_iter, and m_end
+members are a default constructed.
@@ -417,8 +194,10 @@ whose end is a default constru
-
Returns:
A filter_iterator at the first position in the range [x,end)
-such that f(*this->base())==true or else at position end.
+
Returns:
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.
@@ -429,13 +208,9 @@ such that f(*this->base())
Requires:
Predicate must be Default Constructible.
-
Returns:
A filter_iterator at the first position in the range [x,end)
-such that f(*this->base())==true, where f is a default
-constructed Predicate, or else at position end.
-
-
Returns:
A filter_iterator at position x that filters
-according to a default constructed Predicate
-and that will not increment past end.
+
Returns:
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.
@@ -452,8 +227,7 @@ filter_iterator(
Requires:
OtherIterator is implicitly convertible to Iterator.
-
Returns:
A filter iterator at the same position as iterator t
-whose predicate and end are copies of t.predicate and t.end() .
+
Returns:
A filter iterator whose members are copied from t.
@@ -462,7 +236,7 @@ whose predicate and end are copies of t.pr
-
Returns:
A copy of the predicate object used to construct *this.
+
Returns:
m_pred
@@ -471,7 +245,16 @@ whose predicate and end are copies of t.pr
-
Returns:
A copy of the object end used to construct *this.
+
Returns:
m_end
+
+
+
+
Iteratorbase()const;
+
+
+
+
+
Returns:
m_iterator
@@ -480,7 +263,7 @@ whose predicate and end are copies of t.pr
-
Returns:
*(this->base())
+
Returns:
*m_iter
@@ -489,9 +272,9 @@ whose predicate and end are copies of t.pr
-
Effects:
Increments *this and then continues to
-increment *this until either this->base()==this->end()
-or f(**this)==true.
+
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
@@ -591,11 +374,5 @@ int main()
-
-
diff --git a/doc/filter_iterator_eg.rst b/doc/filter_iterator_eg.rst
index 6b3f4af..9b19db3 100644
--- a/doc/filter_iterator_eg.rst
+++ b/doc/filter_iterator_eg.rst
@@ -1,6 +1,6 @@
Example
--------
+.......
This example uses ``filter_iterator`` and then
``make_filter_iterator`` to output only the positive integers from an
diff --git a/doc/filter_iterator_ref.rst b/doc/filter_iterator_ref.rst
index 5321053..c668555 100644
--- a/doc/filter_iterator_ref.rst
+++ b/doc/filter_iterator_ref.rst
@@ -20,8 +20,13 @@
);
Predicate predicate() const;
Iterator end() const;
+ Iterator base() const;
reference operator*() const;
filter_iterator& operator++();
+ private:
+ Predicate m_pred; // exposition
+ Iterator m_iter; // exposition
+ Iterator m_end; // exposition
};
@@ -32,7 +37,7 @@ as described in the models section.
``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
@@ -47,7 +52,7 @@ Input Iterator.
``filter_iterator`` models
---------------------------
+..........................
The concepts that ``filter_iterator`` models are dependent on what
concepts the ``Iterator`` argument models, as specified in the
@@ -83,7 +88,7 @@ following tables.
``filter_iterator`` operations
-------------------------------
+..............................
In addition to those operations required by the concepts that
``filter_iterator`` models, ``filter_iterator`` provides the following
@@ -93,28 +98,25 @@ 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``.
+:Returns: 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 the first position in the range ``[x,end)``
- such that ``f(*this->base()) == true`` or else at position ``end``.
+:Returns: 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 the first position in the range ``[x,end)``
- such that ``f(*this->base()) == true``, where ``f`` is a default
- constructed ``Predicate``, or else at position ``end``.
-
-
-:Returns: A ``filter_iterator`` at position ``x`` that filters
- according to a default constructed ``Predicate``
- and that will not increment past ``end``.
+:Returns: 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.
::
@@ -126,29 +128,33 @@ operations.
);``
:Requires: ``OtherIterator`` is implicitly convertible to ``Iterator``.
-:Returns: A filter iterator at the same position as iterator ``t``
- whose predicate and end are copies of ``t.predicate`` and ``t.end()`` .
+:Returns: 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: A copy of the object ``end`` used to construct ``*this``.
+:Returns: ``m_end``
+
+
+``Iterator base() const;``
+
+:Returns: ``m_iterator``
``reference operator*() const;``
-:Returns: ``*(this->base())``
+:Returns: ``*m_iter``
``filter_iterator& operator++();``
-:Effects: Increments ``*this`` and then continues to
- increment ``*this`` until either ``this->base() == this->end()``
- or ``f(**this) == true``.
+: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``
\ No newline at end of file
diff --git a/doc/function_output_iterator.html b/doc/function_output_iterator.html
index d1fedc3..9349fb0 100644
--- a/doc/function_output_iterator.html
+++ b/doc/function_output_iterator.html
@@ -3,240 +3,13 @@
-
+
Function Output Iterator
-
+
@@ -343,14 +120,96 @@ same concept as the IndexIterator. Thus for instance, although the
permutation iterator provides operator+=(distance), this operation
will take linear time in case the IndexIterator is a model of
ForwardIterator instead of amortized constant time.
+
+template <class ElementIterator, class IndexIterator>
+permutation_iterator<ElementIterator, IndexIterator>
+make_permutation_iterator(ElementIterator e, IndexIterator i);
+
+
+
+
+
+
Returns:
An instance of permutation_iterator<ElementIterator,IndexIterator>
+that views the range of elements starting at e`intheordergiven
+by``i.
+using namespace boost;
+int i = 0;
+
+typedef std::vector< int > element_range_type;
+typedef std::list< int > index_type;
+
+static const int element_range_size = 10;
+static const int index_size = 4;
+
+element_range_type elements( element_range_size );
+for(element_range_type::iterator el_it = elements.begin() ; el_it != elements.end() ; ++el_it)
+ *el_it = std::distance(elements.begin(), el_it);
+
+index_type indices( index_size );
+for(index_type::iterator i_it = indices.begin() ; i_it != indices.end() ; ++i_it )
+ *i_it = element_range_size - index_size + std::distance(indices.begin(), i_it);
+std::reverse( indices.begin(), indices.end() );
+
+typedef permutation_iterator< element_range_type::iterator, index_type::iterator > permutation_type;
+permutation_type begin = make_permutation_iterator( elements.begin(), indices.begin() );
+permutation_type it = begin;
+permutation_type end = make_permutation_iterator( elements.begin(), indices.end() );
+
+std::cout << "The original range is : ";
+std::copy( elements.begin(), elements.end(), std::ostream_iterator< int >( std::cout, " " ) );
+std::cout << "\n";
+
+std::cout << "The reindexing scheme is : ";
+std::copy( indices.begin(), indices.end(), std::ostream_iterator< int >( std::cout, " " ) );
+std::cout << "\n";
+
+std::cout << "The permutated range is : ";
+std::copy( begin, end, std::ostream_iterator< int >( std::cout, " " ) );
+std::cout << "\n";
+
+std::cout << "Elements at even indices in the permutation : ";
+it = begin;
+for(i = 0; i < index_size / 2 ; ++i, it+=2 ) std::cout << *it << " ";
+std::cout << "\n";
+
+std::cout << "Permutation backwards : ";
+it = begin + (index_size);
+assert( it != begin );
+for( ; it-- != begin ; ) std::cout << *it << " ";
+std::cout << "\n";
+
+std::cout << "Iterate backward with stride 2 : ";
+it = begin + (index_size - 1);
+for(i = 0 ; i < index_size / 2 ; ++i, it-=2 ) std::cout << *it << " ";
+std::cout << "\n";
+
+
The output is:
+
+The original range is : 0 1 2 3 4 5 6 7 8 9
+The reindexing scheme is : 9 8 7 6
+The permutated range is : 9 8 7 6
+Elements at even indices in the permutation : 9 7
+Permutation backwards : 6 7 8 9
+Iterate backward with stride 2 : 6 8
+
-
-
diff --git a/doc/permutation_iterator_ref.rst b/doc/permutation_iterator_ref.rst
index 4f73a31..1beaabb 100644
--- a/doc/permutation_iterator_ref.rst
+++ b/doc/permutation_iterator_ref.rst
@@ -18,6 +18,9 @@
, typename enable_if_convertible::type* = 0
, typename enable_if_convertible::type* = 0
);
+ ElementIterator base() const;
+ private:
+ ElementIterator m_iterator; // exposition
};
template
@@ -63,4 +66,9 @@ __ http://www.sgi.com/tech/stl/RandomAccessIterator.html
:Returns: An instance of ``permutation_iterator``
that views the range of elements starting at ``e` in the order given
- by ``i``.
\ No newline at end of file
+ by ``i``.
+
+
+``ElementIterator base() const;``
+
+:Returns: ``m_iterator``
\ No newline at end of file
diff --git a/doc/reverse_iterator.html b/doc/reverse_iterator.html
index 46a933c..fed8ba7 100644
--- a/doc/reverse_iterator.html
+++ b/doc/reverse_iterator.html
@@ -3,240 +3,13 @@
-
+
Reverse Iterator
-
+
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.
-
-
diff --git a/doc/reverse_iterator_eg.rst b/doc/reverse_iterator_eg.rst
index eee8f66..ab8dd90 100644
--- a/doc/reverse_iterator_eg.rst
+++ b/doc/reverse_iterator_eg.rst
@@ -1,6 +1,6 @@
Example
--------
+.......
The following example prints an array of characters in reverse order
using ``reverse_iterator``.
diff --git a/doc/reverse_iterator_ref.rst b/doc/reverse_iterator_ref.rst
index 8846cc9..0e9b35b 100644
--- a/doc/reverse_iterator_ref.rst
+++ b/doc/reverse_iterator_ref.rst
@@ -12,22 +12,23 @@
reverse_iterator const& r
, typename enable_if_convertible::type* = 0 // exposition
);
+ Iterator base() const;
reference operator*() const;
reverse_iterator& operator++();
private:
- Iterator current; // exposition
+ Iterator m_iterator; // exposition
};
``reverse_iterator`` requirements
----------------------------------
+.................................
The base ``Iterator`` must be a model of Bidirectional Traversal
Iterator and Readable Iterator.
``reverse_iterator`` models
----------------------------
+...........................
``reverse_iterator`` models Bidirectional Traversal Iterator and
Readable Iterator. In addition, ``reverse_iterator`` models the same
@@ -37,18 +38,18 @@ argument models.
``reverse_iterator`` operations
--------------------------------
+...............................
``reverse_iterator();``
:Requires: ``Iterator`` must be Default Constructible.
-:Returns: An instance of ``reverse_iterator`` with ``current``
+:Returns: An instance of ``reverse_iterator`` with ``m_iterator``
default constructed.
``explicit reverse_iterator(Iterator x);``
:Returns: An instance of ``reverse_iterator`` with a
- ``current`` constructed from ``x``.
+ ``m_iterator`` constructed from ``x``.
::
@@ -63,17 +64,24 @@ argument models.
:Returns: An instance of ``reverse_iterator`` that is a copy of ``r``.
+
+
+``Iterator base() const;``
+
+:Returns: ``m_iterator``
+
+
``reference operator*() const;``
:Effects:
::
- Iterator tmp = current;
- return *--tmp;
+ Iterator tmp = m_iterator;
+ return *..tmp;
``reverse_iterator& operator++();``
-:Effects: ``--current``
+:Effects: ``--m_iterator``
:Returns: ``*this``
diff --git a/doc/transform_iterator_ref.rst b/doc/transform_iterator_ref.rst
index 08a52ef..247378a 100644
--- a/doc/transform_iterator_ref.rst
+++ b/doc/transform_iterator_ref.rst
@@ -30,7 +30,7 @@
``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
@@ -42,7 +42,7 @@ The type ``Iterator`` must at least model Readable Iterator.
``transform_iterator`` models
------------------------------
+.............................
The resulting ``transform_iterator`` models the most refined of the
following options that is also modeled by ``Iterator``.
@@ -64,7 +64,7 @@ The ``value_type`` is ``remove_cv >::type``.
``transform_iterator`` operations
----------------------------------
+.................................
``transform_iterator();``
diff --git a/example/function_output_iterator_example.cpp b/example/function_output_iterator_example.cpp
new file mode 100644
index 0000000..de0feae
--- /dev/null
+++ b/example/function_output_iterator_example.cpp
@@ -0,0 +1,48 @@
+// (C) Copyright Jeremy Siek 2001-2004.
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all
+// copies. This software is provided "as is" without express or
+// implied warranty, and with no claim as to its suitability for any
+// purpose.
+
+// Revision History:
+
+// 27 Feb 2001 Jeremy Siek
+// Initial checkin.
+
+#include
+#include
+#include
+
+#include
+
+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 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/example/indirect_iterator_example.cpp b/example/indirect_iterator_example.cpp
new file mode 100644
index 0000000..1ff98e6
--- /dev/null
+++ b/example/indirect_iterator_example.cpp
@@ -0,0 +1,59 @@
+// (C) Copyright Jeremy Siek 2000. Permission to copy, use, modify, sell and
+// distribute this software is granted provided this copyright notice appears
+// in all copies. This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+int main(int, char*[])
+{
+ char characters[] = "abcdefg";
+ const int N = sizeof(characters)/sizeof(char) - 1; // -1 since characters has a null char
+ char* pointers_to_chars[N]; // at the end.
+ for (int i = 0; i < N; ++i)
+ pointers_to_chars[i] = &characters[i];
+
+ // Example of using indirect_iterator
+
+ boost::indirect_iterator
+ indirect_first(pointers_to_chars), indirect_last(pointers_to_chars + N);
+
+ std::copy(indirect_first, indirect_last, std::ostream_iterator(std::cout, ","));
+ std::cout << std::endl;
+
+
+ // Example of making mutable and constant indirect iterators
+
+ char mutable_characters[N];
+ char* pointers_to_mutable_chars[N];
+ for (int j = 0; j < N; ++j)
+ pointers_to_mutable_chars[j] = &mutable_characters[j];
+
+ boost::indirect_iterator mutable_indirect_first(pointers_to_mutable_chars),
+ mutable_indirect_last(pointers_to_mutable_chars + N);
+ boost::indirect_iterator const_indirect_first(pointers_to_chars),
+ const_indirect_last(pointers_to_chars + N);
+
+ std::transform(const_indirect_first, const_indirect_last,
+ mutable_indirect_first, std::bind1st(std::plus(), 1));
+
+ std::copy(mutable_indirect_first, mutable_indirect_last,
+ std::ostream_iterator(std::cout, ","));
+ std::cout << std::endl;
+
+
+ // Example of using make_indirect_iterator()
+
+ std::copy(boost::make_indirect_iterator(pointers_to_chars),
+ boost::make_indirect_iterator(pointers_to_chars + N),
+ std::ostream_iterator(std::cout, ","));
+ std::cout << std::endl;
+
+ return 0;
+}