mirror of
https://github.com/boostorg/iterator.git
synced 2025-05-09 23:23:54 +00:00
Allow for bidirectional filtered_iterators
[SVN r26491]
This commit is contained in:
parent
295ae05e40
commit
ba3e7a459e
@ -52,15 +52,15 @@ sequence to be traversed.</td>
|
||||
<div class="contents topic" id="table-of-contents">
|
||||
<p class="topic-title first"><a name="table-of-contents">Table of Contents</a></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="#filter-iterator-synopsis" id="id2" name="id2"><tt class="literal"><span class="pre">filter_iterator</span></tt> synopsis</a></li>
|
||||
<li><a class="reference" href="#filter-iterator-requirements" id="id3" name="id3"><tt class="literal"><span class="pre">filter_iterator</span></tt> requirements</a></li>
|
||||
<li><a class="reference" href="#filter-iterator-models" id="id4" name="id4"><tt class="literal"><span class="pre">filter_iterator</span></tt> models</a></li>
|
||||
<li><a class="reference" href="#filter-iterator-operations" id="id5" name="id5"><tt class="literal"><span class="pre">filter_iterator</span></tt> operations</a></li>
|
||||
<li><a class="reference" href="#example" id="id6" name="id6">Example</a></li>
|
||||
<li><a class="reference" href="#filter-iterator-synopsis" id="id3" name="id3"><tt class="literal"><span class="pre">filter_iterator</span></tt> synopsis</a></li>
|
||||
<li><a class="reference" href="#filter-filter-iterator" id="id4" name="id4"><tt class="literal"><span class="pre">filter_iterator</span></tt> requirements</a></li>
|
||||
<li><a class="reference" href="#filter-iterator-models" id="id5" name="id5"><tt class="literal"><span class="pre">filter_iterator</span></tt> models</a></li>
|
||||
<li><a class="reference" href="#id1" id="id6" name="id6"><tt class="literal"><span class="pre">filter_iterator</span></tt> operations</a></li>
|
||||
<li><a class="reference" href="#example" id="id7" name="id7">Example</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="filter-iterator-synopsis">
|
||||
<h1><a class="toc-backref" href="#id2" name="filter-iterator-synopsis"><tt class="literal"><span class="pre">filter_iterator</span></tt> synopsis</a></h1>
|
||||
<h1><a class="toc-backref" href="#id3" name="filter-iterator-synopsis"><tt class="literal"><span class="pre">filter_iterator</span></tt> synopsis</a></h1>
|
||||
<!-- 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 -->
|
||||
@ -95,13 +95,17 @@ private:
|
||||
Iterator m_end; // exposition only
|
||||
};
|
||||
</pre>
|
||||
<p>If <tt class="literal"><span class="pre">Iterator</span></tt> models Readable Lvalue Iterator and Forward Traversal
|
||||
<p>If <tt class="literal"><span class="pre">Iterator</span></tt> models Readable Lvalue Iterator and Bidirectional Traversal
|
||||
Iterator then <tt class="literal"><span class="pre">iterator_category</span></tt> is convertible to
|
||||
<tt class="literal"><span class="pre">std::forward_iterator_tag</span></tt>. Otherwise <tt class="literal"><span class="pre">iterator_category</span></tt> is
|
||||
<tt class="literal"><span class="pre">std::bidirectional_iterator_tag</span></tt>.
|
||||
Otherwise, if <tt class="literal"><span class="pre">Iterator</span></tt> models Readable Lvalue Iterator and Forward Traversal
|
||||
Iterator then <tt class="literal"><span class="pre">iterator_category</span></tt> is convertible to
|
||||
<tt class="literal"><span class="pre">std::forward_iterator_tag</span></tt>.
|
||||
Otherwise <tt class="literal"><span class="pre">iterator_category</span></tt> is
|
||||
convertible to <tt class="literal"><span class="pre">std::input_iterator_tag</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section" id="filter-iterator-requirements">
|
||||
<h1><a class="toc-backref" href="#id3" name="filter-iterator-requirements"><tt class="literal"><span class="pre">filter_iterator</span></tt> requirements</a></h1>
|
||||
<div class="section" id="filter-filter-iterator">
|
||||
<h1><a class="toc-backref" href="#id4" name="filter-filter-iterator"><tt class="literal"><span class="pre">filter_iterator</span></tt> requirements</a></h1>
|
||||
<p>The <tt class="literal"><span class="pre">Iterator</span></tt> argument shall meet the requirements of Readable
|
||||
Iterator and Single Pass Iterator or it shall meet the requirements of
|
||||
Input Iterator.</p>
|
||||
@ -112,14 +116,14 @@ the expression <tt class="literal"><span class="pre">p(x)</span></tt> must be va
|
||||
<tt class="literal"><span class="pre">p(x)</span></tt> must be convertible to <tt class="literal"><span class="pre">bool</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section" id="filter-iterator-models">
|
||||
<h1><a class="toc-backref" href="#id4" name="filter-iterator-models"><tt class="literal"><span class="pre">filter_iterator</span></tt> models</a></h1>
|
||||
<h1><a class="toc-backref" href="#id5" name="filter-iterator-models"><tt class="literal"><span class="pre">filter_iterator</span></tt> models</a></h1>
|
||||
<p>The concepts that <tt class="literal"><span class="pre">filter_iterator</span></tt> models are dependent on which
|
||||
concepts the <tt class="literal"><span class="pre">Iterator</span></tt> argument models, as specified in the
|
||||
following tables.</p>
|
||||
<table border="1" class="table">
|
||||
<colgroup>
|
||||
<col width="33%" />
|
||||
<col width="67%" />
|
||||
<col width="44%" />
|
||||
<col width="56%" />
|
||||
</colgroup>
|
||||
<thead valign="bottom">
|
||||
<tr><th>If <tt class="literal"><span class="pre">Iterator</span></tt> models</th>
|
||||
@ -133,6 +137,9 @@ following tables.</p>
|
||||
<tr><td>Forward Traversal Iterator</td>
|
||||
<td>Forward Traversal Iterator</td>
|
||||
</tr>
|
||||
<tr><td>Bidirectional Traversal Iterator</td>
|
||||
<td>Bidirectional Traversal Iterator</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table border="1" class="table">
|
||||
@ -177,13 +184,16 @@ following tables.</p>
|
||||
<tr><td>Writable Lvalue Iterator, Forward Traversal Iterator</td>
|
||||
<td>Mutable Forward Iterator</td>
|
||||
</tr>
|
||||
<tr><td>Writable Lvalue Iterator, Bidirectional Iterator</td>
|
||||
<td>Mutable Bidirectional Iterator</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p><tt class="literal"><span class="pre">filter_iterator<P1,</span> <span class="pre">X></span></tt> is interoperable with <tt class="literal"><span class="pre">filter_iterator<P2,</span> <span class="pre">Y></span></tt>
|
||||
if and only if <tt class="literal"><span class="pre">X</span></tt> is interoperable with <tt class="literal"><span class="pre">Y</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section" id="filter-iterator-operations">
|
||||
<h1><a class="toc-backref" href="#id5" name="filter-iterator-operations"><tt class="literal"><span class="pre">filter_iterator</span></tt> operations</a></h1>
|
||||
<div class="section" id="id1">
|
||||
<h1><a class="toc-backref" href="#id6" name="id1"><tt class="literal"><span class="pre">filter_iterator</span></tt> operations</a></h1>
|
||||
<p>In addition to those operations required by the concepts that
|
||||
<tt class="literal"><span class="pre">filter_iterator</span></tt> models, <tt class="literal"><span class="pre">filter_iterator</span></tt> provides the following
|
||||
operations.</p>
|
||||
@ -319,7 +329,7 @@ make_filter_iterator(Iterator x, Iterator end = Iterator());
|
||||
</table>
|
||||
</div>
|
||||
<div class="section" id="example">
|
||||
<h1><a class="toc-backref" href="#id6" name="example">Example</a></h1>
|
||||
<h1><a class="toc-backref" href="#id7" name="example">Example</a></h1>
|
||||
<p>This example uses <tt class="literal"><span class="pre">filter_iterator</span></tt> and then
|
||||
<tt class="literal"><span class="pre">make_filter_iterator</span></tt> to output only the positive integers from an
|
||||
array of integers. Then <tt class="literal"><span class="pre">make_filter_iterator</span></tt> is is used to output
|
||||
|
Binary file not shown.
@ -43,12 +43,16 @@ private:
|
||||
Iterator m_end; // exposition only
|
||||
};
|
||||
</pre>
|
||||
<p>If <tt class="literal"><span class="pre">Iterator</span></tt> models Readable Lvalue Iterator and Forward Traversal
|
||||
<p>If <tt class="literal"><span class="pre">Iterator</span></tt> models Readable Lvalue Iterator and Bidirectional Traversal
|
||||
Iterator then <tt class="literal"><span class="pre">iterator_category</span></tt> is convertible to
|
||||
<tt class="literal"><span class="pre">std::forward_iterator_tag</span></tt>. Otherwise <tt class="literal"><span class="pre">iterator_category</span></tt> is
|
||||
<tt class="literal"><span class="pre">std::bidirectional_iterator_tag</span></tt>.
|
||||
Otherwise, if <tt class="literal"><span class="pre">Iterator</span></tt> models Readable Lvalue Iterator and Forward Traversal
|
||||
Iterator then <tt class="literal"><span class="pre">iterator_category</span></tt> is convertible to
|
||||
<tt class="literal"><span class="pre">std::forward_iterator_tag</span></tt>.
|
||||
Otherwise <tt class="literal"><span class="pre">iterator_category</span></tt> is
|
||||
convertible to <tt class="literal"><span class="pre">std::input_iterator_tag</span></tt>.</p>
|
||||
<div class="section" id="filter-iterator-requirements">
|
||||
<h1><a name="filter-iterator-requirements"><tt class="literal"><span class="pre">filter_iterator</span></tt> requirements</a></h1>
|
||||
<div class="section" id="filter-iterator">
|
||||
<h1><a name="filter-iterator"><tt class="literal"><span class="pre">filter_iterator</span></tt> requirements</a></h1>
|
||||
<p>The <tt class="literal"><span class="pre">Iterator</span></tt> argument shall meet the requirements of Readable
|
||||
Iterator and Single Pass Iterator or it shall meet the requirements of
|
||||
Input Iterator.</p>
|
||||
@ -65,8 +69,8 @@ concepts the <tt class="literal"><span class="pre">Iterator</span></tt> argument
|
||||
following tables.</p>
|
||||
<table border="1" class="table">
|
||||
<colgroup>
|
||||
<col width="33%" />
|
||||
<col width="67%" />
|
||||
<col width="44%" />
|
||||
<col width="56%" />
|
||||
</colgroup>
|
||||
<thead valign="bottom">
|
||||
<tr><th>If <tt class="literal"><span class="pre">Iterator</span></tt> models</th>
|
||||
@ -80,6 +84,9 @@ following tables.</p>
|
||||
<tr><td>Forward Traversal Iterator</td>
|
||||
<td>Forward Traversal Iterator</td>
|
||||
</tr>
|
||||
<tr><td>Bidirectional Traversal Iterator</td>
|
||||
<td>Bidirectional Traversal Iterator</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table border="1" class="table">
|
||||
@ -124,13 +131,16 @@ following tables.</p>
|
||||
<tr><td>Writable Lvalue Iterator, Forward Traversal Iterator</td>
|
||||
<td>Mutable Forward Iterator</td>
|
||||
</tr>
|
||||
<tr><td>Writable Lvalue Iterator, Bidirectional Iterator</td>
|
||||
<td>Mutable Bidirectional Iterator</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p><tt class="literal"><span class="pre">filter_iterator<P1,</span> <span class="pre">X></span></tt> is interoperable with <tt class="literal"><span class="pre">filter_iterator<P2,</span> <span class="pre">Y></span></tt>
|
||||
if and only if <tt class="literal"><span class="pre">X</span></tt> is interoperable with <tt class="literal"><span class="pre">Y</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section" id="filter-iterator-operations">
|
||||
<h1><a name="filter-iterator-operations"><tt class="literal"><span class="pre">filter_iterator</span></tt> operations</a></h1>
|
||||
<div class="section" id="id1">
|
||||
<h1><a name="id1"><tt class="literal"><span class="pre">filter_iterator</span></tt> operations</a></h1>
|
||||
<p>In addition to those operations required by the concepts that
|
||||
<tt class="literal"><span class="pre">filter_iterator</span></tt> models, <tt class="literal"><span class="pre">filter_iterator</span></tt> provides the following
|
||||
operations.</p>
|
||||
|
@ -35,9 +35,13 @@
|
||||
};
|
||||
|
||||
|
||||
If ``Iterator`` models Readable Lvalue Iterator and Forward Traversal
|
||||
If ``Iterator`` models Readable Lvalue Iterator and Bidirectional Traversal
|
||||
Iterator then ``iterator_category`` is convertible to
|
||||
``std::forward_iterator_tag``. Otherwise ``iterator_category`` is
|
||||
``std::bidirectional_iterator_tag``.
|
||||
Otherwise, 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``.
|
||||
|
||||
|
||||
@ -62,13 +66,15 @@ 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 |
|
||||
+=================================+==========================================+
|
||||
|Single Pass Iterator |Single Pass Iterator |
|
||||
+---------------------------------+------------------------------------------+
|
||||
|Forward Traversal Iterator |Forward Traversal Iterator |
|
||||
+---------------------------------+------------------------------------------+
|
||||
|Bidirectional Traversal Iterator |Bidirectional Traversal Iterator |
|
||||
+---------------------------------+------------------------------------------+
|
||||
|
||||
+--------------------------------+----------------------------------------------+
|
||||
| If ``Iterator`` models | then ``filter_iterator`` models |
|
||||
@ -81,13 +87,15 @@ following tables.
|
||||
+--------------------------------+----------------------------------------------+
|
||||
|
||||
+-------------------------------------------------------+---------------------------------+
|
||||
| If ``Iterator`` models | then ``filter_iterator`` models |
|
||||
|If ``Iterator`` models | then ``filter_iterator`` models |
|
||||
+=======================================================+=================================+
|
||||
| Readable Iterator, Single Pass Iterator | Input Iterator |
|
||||
|Readable Iterator, Single Pass Iterator | Input Iterator |
|
||||
+-------------------------------------------------------+---------------------------------+
|
||||
| Readable Lvalue Iterator, Forward Traversal Iterator | Forward Iterator |
|
||||
|Readable Lvalue Iterator, Forward Traversal Iterator | Forward Iterator |
|
||||
+-------------------------------------------------------+---------------------------------+
|
||||
| Writable Lvalue Iterator, Forward Traversal Iterator | Mutable Forward Iterator |
|
||||
|Writable Lvalue Iterator, Forward Traversal Iterator | Mutable Forward Iterator |
|
||||
+-------------------------------------------------------+---------------------------------+
|
||||
|Writable Lvalue Iterator, Bidirectional Iterator | Mutable Bidirectional Iterator |
|
||||
+-------------------------------------------------------+---------------------------------+
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
PYTHONPATH="c:/src/docutils/docutils;c:/src/docutils/docutils/extras"
|
||||
export PYTHONPATH
|
||||
python c:/src/docutils/docutils/tools/rst2latex.py --documentoptions pdftex --stylesheet=docutils.sty --embed-stylesheet $1 `echo $1 | sed 's/\(.*\)\..*/\1.tex/'`
|
||||
python c:/src/docutils/docutils/tools/rst2latex.py --documentoptions pdftex --stylesheet=docutils.sty $1 `echo $1 | sed 's/\(.*\)\..*/\1.tex/'`
|
||||
|
@ -31,9 +31,9 @@ namespace boost
|
||||
, typename mpl::if_<
|
||||
is_convertible<
|
||||
typename iterator_traversal<Iterator>::type
|
||||
, bidirectional_traversal_tag
|
||||
, random_access_traversal_tag
|
||||
>
|
||||
, forward_traversal_tag
|
||||
, bidirectional_traversal_tag
|
||||
, use_default
|
||||
>::type
|
||||
> type;
|
||||
|
@ -63,6 +63,32 @@ int main()
|
||||
boost::function_requires< boost_concepts::WritableIteratorConcept<Iter> >();
|
||||
boost::function_requires< boost_concepts::ForwardTraversalConcept<Iter> >();
|
||||
}
|
||||
{
|
||||
typedef boost::filter_iterator<one_or_four, boost::bidirectional_iterator_archetype<dummyT> > Iter;
|
||||
boost::function_requires< boost::BidirectionalIteratorConcept<Iter> >();
|
||||
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
|
||||
boost::function_requires< boost_concepts::BidirectionalTraversalConcept<Iter> >();
|
||||
}
|
||||
{
|
||||
typedef boost::filter_iterator<one_or_four, boost::mutable_bidirectional_iterator_archetype<dummyT> > Iter;
|
||||
boost::function_requires< boost::Mutable_BidirectionalIteratorConcept<Iter> >();
|
||||
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
|
||||
boost::function_requires< boost_concepts::WritableIteratorConcept<Iter> >();
|
||||
boost::function_requires< boost_concepts::BidirectionalTraversalConcept<Iter> >();
|
||||
}
|
||||
{
|
||||
typedef boost::filter_iterator<one_or_four, boost::random_access_iterator_archetype<dummyT> > Iter;
|
||||
boost::function_requires< boost::BidirectionalIteratorConcept<Iter> >();
|
||||
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
|
||||
boost::function_requires< boost_concepts::BidirectionalTraversalConcept<Iter> >();
|
||||
}
|
||||
{
|
||||
typedef boost::filter_iterator<one_or_four, boost::mutable_random_access_iterator_archetype<dummyT> > Iter;
|
||||
boost::function_requires< boost::Mutable_BidirectionalIteratorConcept<Iter> >();
|
||||
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
|
||||
boost::function_requires< boost_concepts::WritableIteratorConcept<Iter> >();
|
||||
boost::function_requires< boost_concepts::BidirectionalTraversalConcept<Iter> >();
|
||||
}
|
||||
// Adapting new-style iterators
|
||||
{
|
||||
typedef boost::iterator_archetype<
|
||||
@ -141,6 +167,56 @@ int main()
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
typedef boost::iterator_archetype<
|
||||
const dummyT
|
||||
, boost::iterator_archetypes::readable_iterator_t
|
||||
, boost::random_access_traversal_tag
|
||||
> BaseIter;
|
||||
typedef boost::filter_iterator<one_or_four, BaseIter> Iter;
|
||||
boost::function_requires< boost::InputIteratorConcept<Iter> >();
|
||||
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
|
||||
boost::function_requires< boost_concepts::BidirectionalTraversalConcept<Iter> >();
|
||||
}
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, == 1200) // Causes Internal Error in linker.
|
||||
{
|
||||
typedef boost::iterator_archetype<
|
||||
dummyT
|
||||
, boost::iterator_archetypes::readable_writable_iterator_t
|
||||
, boost::random_access_traversal_tag
|
||||
> BaseIter;
|
||||
typedef boost::filter_iterator<one_or_four, BaseIter> Iter;
|
||||
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
|
||||
boost::function_requires< boost_concepts::WritableIteratorConcept<Iter> >();
|
||||
boost::function_requires< boost_concepts::BidirectionalTraversalConcept<Iter> >();
|
||||
}
|
||||
{
|
||||
typedef boost::iterator_archetype<
|
||||
const dummyT
|
||||
, boost::iterator_archetypes::readable_lvalue_iterator_t
|
||||
, boost::random_access_traversal_tag
|
||||
> BaseIter;
|
||||
typedef boost::filter_iterator<one_or_four, BaseIter> Iter;
|
||||
boost::function_requires< boost::BidirectionalIteratorConcept<Iter> >();
|
||||
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
|
||||
boost::function_requires< boost_concepts::LvalueIteratorConcept<Iter> >();
|
||||
boost::function_requires< boost_concepts::BidirectionalTraversalConcept<Iter> >();
|
||||
}
|
||||
{
|
||||
typedef boost::iterator_archetype<
|
||||
dummyT
|
||||
, boost::iterator_archetypes::writable_lvalue_iterator_t
|
||||
, boost::random_access_traversal_tag
|
||||
> BaseIter;
|
||||
typedef boost::filter_iterator<one_or_four, BaseIter> Iter;
|
||||
boost::function_requires< boost::Mutable_BidirectionalIteratorConcept<Iter> >();
|
||||
boost::function_requires< boost_concepts::WritableIteratorConcept<Iter> >();
|
||||
boost::function_requires< boost_concepts::LvalueIteratorConcept<Iter> >();
|
||||
boost::function_requires< boost_concepts::BidirectionalTraversalConcept<Iter> >();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Run-time tests
|
||||
|
||||
dummyT array[] = { dummyT(0), dummyT(1), dummyT(2),
|
||||
|
Loading…
x
Reference in New Issue
Block a user