updated some issues for indirect_iterator

[SVN r21640]
This commit is contained in:
Jeremy Siek 2004-01-12 19:30:48 +00:00
parent 6085e03da0
commit db9d88ad7b
4 changed files with 117 additions and 155 deletions

View File

@ -130,8 +130,8 @@ by adapting other iterators.</td>
<li><a class="reference" href="#function-output-iterator" id="id66" name="id66">Function output iterator</a><ul>
<li><a class="reference" href="#class-template-function-output-iterator" id="id67" name="id67">Class template <tt class="literal"><span class="pre">function_output_iterator</span></tt></a></li>
<li><a class="reference" href="#function-output-iterator-requirements" id="id68" name="id68"><tt class="literal"><span class="pre">function_output_iterator</span></tt> requirements</a></li>
<li><a class="reference" href="#function-output-iterator-operations" id="id69" name="id69"><tt class="literal"><span class="pre">function_output_iterator</span></tt> operations</a></li>
<li><a class="reference" href="#function-output-iterator-output-proxy-operations" id="id70" name="id70"><tt class="literal"><span class="pre">function_output_iterator::output_proxy</span></tt> operations</a></li>
<li><a class="reference" href="#function-output-iterator-models" id="id69" name="id69"><tt class="literal"><span class="pre">function_output_iterator</span></tt> models</a></li>
<li><a class="reference" href="#function-output-iterator-operations" id="id70" name="id70"><tt class="literal"><span class="pre">function_output_iterator</span></tt> operations</a></li>
</ul>
</li>
</ul>
@ -2212,54 +2212,52 @@ proxy object.</p>
template &lt;class UnaryFunction&gt;
class function_output_iterator {
public:
typedef iterator_tag&lt;
writable_iterator
, incrementable_traversal_tag
&gt; 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&amp; f = UnaryFunction());
struct output_proxy {
output_proxy(UnaryFunction&amp; f);
template &lt;class T&gt; output_proxy&amp; operator=(const T&amp; value);
};
output_proxy operator*();
/* implementation defined */ operator*();
function_output_iterator&amp; operator++();
function_output_iterator&amp; operator++(int);
private:
UnaryFunction m_f; // exposition only
};
</pre>
</div>
<div class="section" id="function-output-iterator-requirements">
<h4><a class="toc-backref" href="#id68" name="function-output-iterator-requirements"><tt class="literal"><span class="pre">function_output_iterator</span></tt> requirements</a></h4>
<p>The <tt class="literal"><span class="pre">UnaryFunction</span></tt> must be Assignable, Copy Constructible, and the
expression <tt class="literal"><span class="pre">f(x)</span></tt> must be valid, where <tt class="literal"><span class="pre">f</span></tt> is an object of type
<tt class="literal"><span class="pre">UnaryFunction</span></tt> and <tt class="literal"><span class="pre">x</span></tt> is an object of a type accepted by <tt class="literal"><span class="pre">f</span></tt>.
The resulting <tt class="literal"><span class="pre">function_output_iterator</span></tt> is a model of the Writable
and Incrementable Iterator concepts.</p>
<p>The <tt class="literal"><span class="pre">UnaryFunction</span></tt> must be Assignable, Copy Constructible.</p>
</div>
<div class="section" id="function-output-iterator-models">
<h4><a class="toc-backref" href="#id69" name="function-output-iterator-models"><tt class="literal"><span class="pre">function_output_iterator</span></tt> models</a></h4>
<p><tt class="literal"><span class="pre">function_output_iterator</span></tt> is a model of the Writable and
Incrementable Iterator concepts.</p>
</div>
<div class="section" id="function-output-iterator-operations">
<h4><a class="toc-backref" href="#id69" name="function-output-iterator-operations"><tt class="literal"><span class="pre">function_output_iterator</span></tt> operations</a></h4>
<h4><a class="toc-backref" href="#id70" name="function-output-iterator-operations"><tt class="literal"><span class="pre">function_output_iterator</span></tt> operations</a></h4>
<p><tt class="literal"><span class="pre">explicit</span> <span class="pre">function_output_iterator(const</span> <span class="pre">UnaryFunction&amp;</span> <span class="pre">f</span> <span class="pre">=</span> <span class="pre">UnaryFunction());</span></tt></p>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">An instance of <tt class="literal"><span class="pre">function_output_iterator</span></tt> with
<tt class="literal"><span class="pre">f</span></tt> stored as a data member.</td>
<tt class="literal"><span class="pre">m_f</span></tt> constructed from <tt class="literal"><span class="pre">f</span></tt>.</td>
</tr>
</tbody>
</table>
<p><tt class="literal"><span class="pre">output_proxy</span> <span class="pre">operator*();</span></tt></p>
<p><tt class="literal"><span class="pre">/*</span> <span class="pre">implementation</span> <span class="pre">defined</span> <span class="pre">*/</span> <span class="pre">operator*();</span></tt></p>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">An instance of <tt class="literal"><span class="pre">output_proxy</span></tt> constructed with
a copy of the unary function <tt class="literal"><span class="pre">f</span></tt>.</td>
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">An object <tt class="literal"><span class="pre">r</span></tt> of implementation defined type
such that if <tt class="literal"><span class="pre">f(t)</span></tt> is a valid expression for
some object <tt class="literal"><span class="pre">t</span></tt> then <tt class="literal"><span class="pre">r</span> <span class="pre">=</span> <span class="pre">t</span></tt> is a valid expression.
<tt class="literal"><span class="pre">r</span> <span class="pre">=</span> <span class="pre">t</span></tt> will have the same effect as <tt class="literal"><span class="pre">f(t)</span></tt>.</td>
</tr>
</tbody>
</table>
@ -2281,32 +2279,6 @@ a copy of the unary function <tt class="literal"><span class="pre">f</span></tt>
</tr>
</tbody>
</table>
</div>
<div class="section" id="function-output-iterator-output-proxy-operations">
<h4><a class="toc-backref" href="#id70" name="function-output-iterator-output-proxy-operations"><tt class="literal"><span class="pre">function_output_iterator::output_proxy</span></tt> operations</a></h4>
<p><tt class="literal"><span class="pre">output_proxy(UnaryFunction&amp;</span> <span class="pre">f);</span></tt></p>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">An instance of <tt class="literal"><span class="pre">output_proxy</span></tt> with <tt class="literal"><span class="pre">f</span></tt> stored as
a data member.</td>
</tr>
</tbody>
</table>
<p><tt class="literal"><span class="pre">template</span> <span class="pre">&lt;class</span> <span class="pre">T&gt;</span> <span class="pre">output_proxy&amp;</span> <span class="pre">operator=(const</span> <span class="pre">T&amp;</span> <span class="pre">value);</span></tt></p>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Effects:</th><td class="field-body"><pre class="first last literal-block">
m_f(value);
return *this;
</pre>
</td>
</tr>
</tbody>
</table>
<!-- LocalWords: Abrahams Siek Witt istream ostream iter MTL strided interoperate
LocalWords: CRTP metafunctions inlining lvalue JGS incrementable BGL LEDA cv
LocalWords: GraphBase struct ptrdiff UnaryFunction const int typename bool pp
@ -2321,7 +2293,7 @@ LocalWords: OtherIncrementable Coplien -->
<hr class="footer"/>
<div class="footer">
<a class="reference" href="facade-and-adaptor.rst">View document source</a>.
Generated on: 2004-01-12 19:01 UTC.
Generated on: 2004-01-12 19:23 UTC.
Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
</div>
</body>

View File

@ -51,8 +51,8 @@ proxy object.</p>
<p class="topic-title"><a name="table-of-contents">Table of Contents</a></p>
<ul class="simple">
<li><a class="reference" href="#function-output-iterator-requirements" id="id1" name="id1"><tt class="literal"><span class="pre">function_output_iterator</span></tt> requirements</a></li>
<li><a class="reference" href="#function-output-iterator-operations" id="id2" name="id2"><tt class="literal"><span class="pre">function_output_iterator</span></tt> operations</a></li>
<li><a class="reference" href="#function-output-iterator-output-proxy-operations" id="id3" name="id3"><tt class="literal"><span class="pre">function_output_iterator::output_proxy</span></tt> operations</a></li>
<li><a class="reference" href="#function-output-iterator-models" id="id2" name="id2"><tt class="literal"><span class="pre">function_output_iterator</span></tt> models</a></li>
<li><a class="reference" href="#function-output-iterator-operations" id="id3" name="id3"><tt class="literal"><span class="pre">function_output_iterator</span></tt> operations</a></li>
<li><a class="reference" href="#example" id="id4" name="id4">Example</a></li>
</ul>
</div>
@ -60,53 +60,51 @@ proxy object.</p>
template &lt;class UnaryFunction&gt;
class function_output_iterator {
public:
typedef iterator_tag&lt;
writable_iterator
, incrementable_traversal_tag
&gt; 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&amp; f = UnaryFunction());
struct output_proxy {
output_proxy(UnaryFunction&amp; f);
template &lt;class T&gt; output_proxy&amp; operator=(const T&amp; value);
};
output_proxy operator*();
/* implementation defined */ operator*();
function_output_iterator&amp; operator++();
function_output_iterator&amp; operator++(int);
private:
UnaryFunction m_f; // exposition only
};
</pre>
<div class="section" id="function-output-iterator-requirements">
<h1><a class="toc-backref" href="#id1" name="function-output-iterator-requirements"><tt class="literal"><span class="pre">function_output_iterator</span></tt> requirements</a></h1>
<p>The <tt class="literal"><span class="pre">UnaryFunction</span></tt> must be Assignable, Copy Constructible, and the
expression <tt class="literal"><span class="pre">f(x)</span></tt> must be valid, where <tt class="literal"><span class="pre">f</span></tt> is an object of type
<tt class="literal"><span class="pre">UnaryFunction</span></tt> and <tt class="literal"><span class="pre">x</span></tt> is an object of a type accepted by <tt class="literal"><span class="pre">f</span></tt>.
The resulting <tt class="literal"><span class="pre">function_output_iterator</span></tt> is a model of the Writable
and Incrementable Iterator concepts.</p>
<p>The <tt class="literal"><span class="pre">UnaryFunction</span></tt> must be Assignable, Copy Constructible.</p>
</div>
<div class="section" id="function-output-iterator-models">
<h1><a class="toc-backref" href="#id2" name="function-output-iterator-models"><tt class="literal"><span class="pre">function_output_iterator</span></tt> models</a></h1>
<p><tt class="literal"><span class="pre">function_output_iterator</span></tt> is a model of the Writable and
Incrementable Iterator concepts.</p>
</div>
<div class="section" id="function-output-iterator-operations">
<h1><a class="toc-backref" href="#id2" name="function-output-iterator-operations"><tt class="literal"><span class="pre">function_output_iterator</span></tt> operations</a></h1>
<h1><a class="toc-backref" href="#id3" name="function-output-iterator-operations"><tt class="literal"><span class="pre">function_output_iterator</span></tt> operations</a></h1>
<p><tt class="literal"><span class="pre">explicit</span> <span class="pre">function_output_iterator(const</span> <span class="pre">UnaryFunction&amp;</span> <span class="pre">f</span> <span class="pre">=</span> <span class="pre">UnaryFunction());</span></tt></p>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">An instance of <tt class="literal"><span class="pre">function_output_iterator</span></tt> with
<tt class="literal"><span class="pre">f</span></tt> stored as a data member.</td>
<tt class="literal"><span class="pre">m_f</span></tt> constructed from <tt class="literal"><span class="pre">f</span></tt>.</td>
</tr>
</tbody>
</table>
<p><tt class="literal"><span class="pre">output_proxy</span> <span class="pre">operator*();</span></tt></p>
<p><tt class="literal"><span class="pre">/*</span> <span class="pre">implementation</span> <span class="pre">defined</span> <span class="pre">*/</span> <span class="pre">operator*();</span></tt></p>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">An instance of <tt class="literal"><span class="pre">output_proxy</span></tt> constructed with
a copy of the unary function <tt class="literal"><span class="pre">f</span></tt>.</td>
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">An object <tt class="literal"><span class="pre">r</span></tt> of implementation defined type
such that if <tt class="literal"><span class="pre">f(t)</span></tt> is a valid expression for
some object <tt class="literal"><span class="pre">t</span></tt> then <tt class="literal"><span class="pre">r</span> <span class="pre">=</span> <span class="pre">t</span></tt> is a valid expression.
<tt class="literal"><span class="pre">r</span> <span class="pre">=</span> <span class="pre">t</span></tt> will have the same effect as <tt class="literal"><span class="pre">f(t)</span></tt>.</td>
</tr>
</tbody>
</table>
@ -129,32 +127,6 @@ a copy of the unary function <tt class="literal"><span class="pre">f</span></tt>
</tbody>
</table>
</div>
<div class="section" id="function-output-iterator-output-proxy-operations">
<h1><a class="toc-backref" href="#id3" name="function-output-iterator-output-proxy-operations"><tt class="literal"><span class="pre">function_output_iterator::output_proxy</span></tt> operations</a></h1>
<p><tt class="literal"><span class="pre">output_proxy(UnaryFunction&amp;</span> <span class="pre">f);</span></tt></p>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">An instance of <tt class="literal"><span class="pre">output_proxy</span></tt> with <tt class="literal"><span class="pre">f</span></tt> stored as
a data member.</td>
</tr>
</tbody>
</table>
<p><tt class="literal"><span class="pre">template</span> <span class="pre">&lt;class</span> <span class="pre">T&gt;</span> <span class="pre">output_proxy&amp;</span> <span class="pre">operator=(const</span> <span class="pre">T&amp;</span> <span class="pre">value);</span></tt></p>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Effects:</th><td class="field-body"><pre class="first last literal-block">
m_f(value);
return *this;
</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="example">
<h1><a class="toc-backref" href="#id4" name="example">Example</a></h1>
<pre class="literal-block">
@ -194,7 +166,7 @@ int main(int, char*[])
<hr class="footer"/>
<div class="footer">
<a class="reference" href="function_output_iterator.rst">View document source</a>.
Generated on: 2004-01-12 15:20 UTC.
Generated on: 2004-01-12 19:23 UTC.
Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
</div>
</body>

View File

@ -3,35 +3,36 @@
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());
struct output_proxy {
output_proxy(UnaryFunction& f);
template <class T> output_proxy& operator=(const T& value);
};
output_proxy operator*();
/* implementation defined */ 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.
The ``UnaryFunction`` must be Assignable, Copy Constructible.
``function_output_iterator`` models
...................................
``function_output_iterator`` is a model of the Writable and
Incrementable Iterator concepts.
``function_output_iterator`` operations
@ -40,13 +41,15 @@ and Incrementable Iterator concepts.
``explicit function_output_iterator(const UnaryFunction& f = UnaryFunction());``
:Returns: An instance of ``function_output_iterator`` with
``f`` stored as a data member.
``m_f`` constructed from ``f``.
``output_proxy operator*();``
``/* implementation defined */ operator*();``
:Returns: An instance of ``output_proxy`` constructed with
a copy of the unary function ``f``.
:Returns: An object ``r`` of implementation defined type
such that if ``f(t)`` is a valid expression for
some object ``t`` then ``r = t`` is a valid expression.
``r = t`` will have the same effect as ``f(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 <class T> output_proxy& operator=(const T& value);``
:Effects:
::
m_f(value);
return *this;

View File

@ -679,10 +679,18 @@ with the iterator_adaptor subobject copy constructed from x." The latter is the
it does not reach inside the base class for its semantics. So the default constructor shoudl return
"An instance of indirect_iterator with a default-constructed iterator_adaptor subobject."
:Proposed resolution: Change the effects clause to
:Proposed resolution: Change the specification of the default constructor to
Effects: Constructs an instance of indirect_iterator with a default
constructed iterator_adaptor subobject.
``indirect_iterator();``
:Requires: ``Iterator`` must be Default Constructible.
:Returns: An instance of ``indirect_iterator`` with
a default-constructed ``m_iterator``.
:Rationale: Inheritance from iterator_adaptor has been removed, so we instead
give the semantics in terms of the (exposition only) member
``m_iterator``.
9.29 indirect_iterator: unclear specification of template constructor
@ -702,14 +710,30 @@ Is that what's meant here?
constructor like this: the constructor returns "a copy" of the argument without saying what a
copy is.)
:Proposed resolution: Change the effects clause
to
:Proposed resolution: Change the specification to
Effects: Constructs an instance of indirect_iterator whose
iterator_adaptor subobject is constructed from y.base().
::
template <
class Iterator2, class Value2, unsigned Access, class Traversal
, class Reference2, class Difference2
>
indirect_iterator(
indirect_iterator<
Iterator2, Value2, Access, Traversal, Reference2, Difference2
> const& y
, typename enable_if_convertible<Iterator2, Iterator>::type* = 0 // exposition
);
:Requires: ``Iterator2`` is implicitly convertible to ``Iterator``.
:Returns: An instance of ``indirect_iterator`` whose
``m_iterator`` subobject is constructed from ``y.base()``.
:Rationale: Inheritance from iterator_adaptor has been removed, so we
instead give the semantics in terms of the (exposition only) member
``m_iterator``.
Note/DWA: isn't the iterator_adaptor base class an
implementation detail? I'm marking this **Needs Work**
9.30 transform_iterator argument irregularity
=============================================
@ -742,8 +766,16 @@ and to increment such an object. It's only when you try to assign through a dere
that f(x) has to work, and then only for the particular function object that the iterator holds and
for the particular value that is being assigned.
:Proposed resolution: **Needs work** (Jeremy) Agree, need to find wording.
:Proposed resolution:
Remove the part of the sentence after "and". Remove the use of
``output_proxy`` and instead specify ``operator*`` in the following way.
``/* implementation defined */ operator*();``
:Returns: An object ``r`` of implementation defined type
such that if ``f(t)`` is a valid expression for
some object ``t`` then ``r = t`` is a valid expression.
``r = t`` will have the same effect as ``f(t)``.
9.32 Should output_proxy really be a named type?
@ -756,7 +788,8 @@ This means someone can store an output_proxy object for later use, whatever that
constrains output_proxy to hold a copy of the function object, rather than a pointer to the iterator
object. Is all this mechanism really necessary?
:Proposed resolution: **Needs work** (Jeremy) Agree, need to find wording.
:Proposed resolution:
See issue 9.31.