mirror of
https://github.com/boostorg/range.git
synced 2025-07-29 12:27:42 +02:00
[range] docs for writing adaptors: removed clarification added in r82315 (it was redundant); fixed typos that messed up numbering
[SVN r82326]
This commit is contained in:
@ -147,7 +147,7 @@
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"><p><small>Last revised: January 02, 2013 at 23:39:56 GMT</small></p></td>
|
||||
<td align="left"><p><small>Last revised: January 03, 2013 at 00:57:19 GMT</small></p></td>
|
||||
<td align="right"><div class="copyright-footer"></div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
|
@ -90,12 +90,6 @@
|
||||
<span class="keyword">const</span> <span class="identifier">detail</span><span class="special">::</span><span class="identifier">reverse_forwarder</span> <span class="identifier">reversed</span> <span class="special">=</span> <span class="identifier">detail</span><span class="special">::</span><span class="identifier">reverse_forwarder</span><span class="special">();</span>
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
Note that this last step only applies if the adaptor takes no arguments.
|
||||
If the adaptor takes arguments (such as <code class="computeroutput"><span class="identifier">indexed</span></code>),
|
||||
then there is no need for a variable. Instead, give the tag type
|
||||
a constructor that takes the arguments (and store those arguments
|
||||
in the tag object). A usage of the adaptor will then involve construction
|
||||
of an object of the tag type.
|
||||
</li>
|
||||
</ol></div>
|
||||
</div>
|
||||
|
@ -80,15 +80,8 @@
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Implement a holder class to hold the arguments required to construct
|
||||
the RangeAdaptor.
|
||||
</li>
|
||||
</ol></div>
|
||||
<p>
|
||||
The holder combines multiple parameters into one that can be passed as
|
||||
the right operand of <code class="computeroutput"><span class="keyword">operator</span><span class="special">|()</span></code>.
|
||||
</p>
|
||||
<p>
|
||||
</p>
|
||||
the RangeAdaptor. The holder combines multiple parameters into one
|
||||
that can be passed as the right operand of <code class="computeroutput"><span class="keyword">operator</span><span class="special">|()</span></code>.
|
||||
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">replace_holder</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">range_detail</span><span class="special">::</span><span class="identifier">holder2</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span>
|
||||
<span class="special">{</span>
|
||||
@ -100,23 +93,15 @@
|
||||
<span class="keyword">void</span> <span class="keyword">operator</span><span class="special">=(</span><span class="keyword">const</span> <span class="identifier">replace_holder</span><span class="special">&);</span>
|
||||
<span class="special">};</span>
|
||||
</pre>
|
||||
<p>
|
||||
</p>
|
||||
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Define an instance of the holder with the name of the adaptor
|
||||
</li></ol></div>
|
||||
<p>
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">range_detail</span><span class="special">::</span><span class="identifier">forwarder2</span><span class="special"><</span><span class="identifier">replace_holder</span><span class="special">></span>
|
||||
<span class="identifier">replaced</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">range_detail</span><span class="special">::</span><span class="identifier">forwarder2</span><span class="special"><</span><span class="identifier">replace_holder</span><span class="special">>();</span>
|
||||
</pre>
|
||||
<p>
|
||||
</p>
|
||||
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Define <code class="computeroutput"><span class="keyword">operator</span><span class="special">|</span></code>
|
||||
</li></ol></div>
|
||||
<p>
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">SinglePassRange</span><span class="special">></span>
|
||||
<span class="keyword">inline</span> <span class="identifier">replace_range</span><span class="special"><</span><span class="identifier">SinglePassRange</span><span class="special">></span>
|
||||
<span class="keyword">operator</span><span class="special">|(</span><span class="identifier">SinglePassRange</span><span class="special">&</span> <span class="identifier">rng</span><span class="special">,</span>
|
||||
@ -133,8 +118,8 @@
|
||||
<span class="keyword">return</span> <span class="identifier">replace_range</span><span class="special"><</span><span class="keyword">const</span> <span class="identifier">SinglePassRange</span><span class="special">>(</span><span class="identifier">rng</span><span class="special">,</span> <span class="identifier">f</span><span class="special">.</span><span class="identifier">val1</span><span class="special">,</span> <span class="identifier">f</span><span class="special">.</span><span class="identifier">val2</span><span class="special">);</span>
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
<p>
|
||||
</p>
|
||||
</li>
|
||||
</ol></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
|
@ -225,10 +225,6 @@ namespace
|
||||
const detail::reverse_forwarder reversed = detail::reverse_forwarder();
|
||||
}
|
||||
``
|
||||
Note that this last step only applies if the adaptor takes no arguments. If the adaptor takes arguments
|
||||
(such as `indexed`), then there is no need for a variable. Instead, give the tag type a
|
||||
constructor that takes the arguments (and store those arguments in the tag object). A usage
|
||||
of the adaptor will then involve construction of an object of the tag type.
|
||||
|
||||
[endsect]
|
||||
|
||||
@ -285,9 +281,7 @@ public:
|
||||
``
|
||||
|
||||
# Implement a holder class to hold the arguments required to construct the RangeAdaptor.
|
||||
|
||||
The holder combines multiple parameters into one that can be passed as the right operand of `operator|()`.
|
||||
|
||||
``
|
||||
template<typename T>
|
||||
class replace_holder : public boost::range_detail::holder2<T>
|
||||
@ -302,14 +296,12 @@ private:
|
||||
``
|
||||
|
||||
# Define an instance of the holder with the name of the adaptor
|
||||
|
||||
``
|
||||
static boost::range_detail::forwarder2<replace_holder>
|
||||
replaced = boost::range_detail::forwarder2<replace_holder>();
|
||||
``
|
||||
|
||||
# Define `operator|`
|
||||
|
||||
``
|
||||
template<typename SinglePassRange>
|
||||
inline replace_range<SinglePassRange>
|
||||
|
Reference in New Issue
Block a user