forked from boostorg/range
*** empty log message ***
[SVN r30508]
This commit is contained in:
76
doc/faq.html
76
doc/faq.html
@ -20,36 +20,36 @@
|
|||||||
<h2 >FAQ</h2> <a name="FAQ" ></a>
|
<h2 >FAQ</h2> <a name="FAQ" ></a>
|
||||||
<ol >
|
<ol >
|
||||||
<li >
|
<li >
|
||||||
<i>Why is there no difference between <code >range_iterator<C>::type</code>
|
<i>Why is there no difference between <code >range_iterator<C>::type</code>
|
||||||
and <code >range_const_iterator<C>::type</code> for <code>std::pair<iterator, iterator></code></i>.
|
and <code >range_const_iterator<C>::type</code> for <code>std::pair<iterator, iterator></code></i>.
|
||||||
</li>
|
</li>
|
||||||
<p >
|
<p >
|
||||||
In general it is not possible nor desirable to find a corresponding <code >const_iterator</code>.
|
In general it is not possible nor desirable to find a corresponding <code >const_iterator</code>.
|
||||||
When it is possible to come up with one, the client might choose to construct a <code >std::pair<const_iterator,const_iterator></code>
|
When it is possible to come up with one, the client might choose to construct a <code >std::pair<const_iterator,const_iterator></code>
|
||||||
object.
|
object.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Note that an <a href="utility_class.html#iter_range">iterator_range</a>
|
Note that an <a href="utility_class.html#iter_range">iterator_range</a>
|
||||||
is somewhat more convenient than a <code>pair</code> and that a <a
|
is somewhat more convenient than a <code>pair</code> and that a <a
|
||||||
href="utility_class.html#sub_range"><code>sub_range</code></a> do
|
href="utility_class.html#sub_range"><code>sub_range</code></a> does
|
||||||
propagate const-ness. </p>
|
propagate const-ness. </p>
|
||||||
|
|
||||||
<li >
|
<li >
|
||||||
<i>Why is there not supplied more types or more functions?</i>
|
<i>Why is there not supplied more types or more functions?</i>
|
||||||
<p >
|
<p >
|
||||||
The library has been kept small because its current interface will
|
The library has been kept small because its current interface will
|
||||||
serve most
|
serve most
|
||||||
purposes. If and when a genuine need arises for more functionality, it can be
|
purposes. If and when a genuine need arises for more functionality, it can be
|
||||||
implemented.
|
implemented.
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
<li >
|
<li >
|
||||||
<i>How should I implement generic algorithms for ranges?</i>
|
<i>How should I implement generic algorithms for ranges?</i>
|
||||||
<p >
|
<p >
|
||||||
One should always start with a generic algorithm that takes two iterators (or
|
One should always start with a generic algorithm that takes two iterators (or
|
||||||
more) as input. Then use Boost.Range to build handier versions on top of the
|
more) as input. Then use Boost.Range to build handier versions on top of the
|
||||||
iterator based algorithm. Please notice that once the range version of the
|
iterator based algorithm. Please notice that once the range version of the
|
||||||
algorithm is done, it makes sense <i>not</i> to expose the iterator version in
|
algorithm is done, it makes sense <i>not</i> to expose the iterator version in
|
||||||
the public interface.
|
the public interface.
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
@ -57,59 +57,59 @@
|
|||||||
<i>Why is there no Incrementable Range concept?</i>
|
<i>Why is there no Incrementable Range concept?</i>
|
||||||
<p>
|
<p>
|
||||||
Even though we speak of incrementable iterators, it would not make
|
Even though we speak of incrementable iterators, it would not make
|
||||||
much sense for ranges; for example, we cannot determine the size and
|
much sense for ranges; for example, we cannot determine the size and
|
||||||
emptiness of a range since we cannot even compare
|
emptiness of a range since we cannot even compare
|
||||||
its iterators.
|
its iterators.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Note also that incrementable iterators are derived from output
|
Note also that incrementable iterators are derived from output
|
||||||
iterators and so there exist no output range.
|
iterators and so there exist no output range.
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
<!--
|
<!--
|
||||||
<li>
|
<li>
|
||||||
<i>Should I use qualified syntax, for example
|
<i>Should I use qualified syntax, for example
|
||||||
<blockquote><pre>
|
<blockquote><pre>
|
||||||
<span class=identifier>boost</span><span class=special>::</span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>r </span><span class=special>); </span>
|
<span class=identifier>boost</span><span class=special>::</span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>r </span><span class=special>); </span>
|
||||||
</pre></blockquote>
|
</pre></blockquote>
|
||||||
instead of
|
instead of
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre><span class=keyword>using </span><span class=keyword>namespace </span><span class=identifier>boost</span><span class=special>;</span>
|
<pre><span class=keyword>using </span><span class=keyword>namespace </span><span class=identifier>boost</span><span class=special>;</span>
|
||||||
<span class=identifier>begin</span><span class=special>( </span><span class=identifier>r </span><span class=special>)</span></pre></blockquote>
|
<span class=identifier>begin</span><span class=special>( </span><span class=identifier>r </span><span class=special>)</span></pre></blockquote>
|
||||||
when calling functions in this library? If so, can I still rely on argument
|
when calling functions in this library? If so, can I still rely on argument
|
||||||
dependent lookup (ADL) to kick in?</i>
|
dependent lookup (ADL) to kick in?</i>
|
||||||
<p>
|
<p>
|
||||||
The answer to the first question is that "it's up to you". The
|
The answer to the first question is that "it's up to you". The
|
||||||
answer to the second question is Yes. Normally qualified syntax
|
answer to the second question is Yes. Normally qualified syntax
|
||||||
disables ADL, but the functions are implemented in a special
|
disables ADL, but the functions are implemented in a special
|
||||||
manner that preserves ADL properties. The trick was explained by
|
manner that preserves ADL properties. The trick was explained by
|
||||||
Daniel Frey on comp.lang.std.c++ in the thread "Whence Swap" and
|
Daniel Frey on comp.lang.std.c++ in the thread "Whence Swap" and
|
||||||
it is best explained by some code: <blockquote>
|
it is best explained by some code: <blockquote>
|
||||||
<pre>
|
<pre>
|
||||||
<span class=keyword>namespace </span><span class=identifier>boost</span>
|
<span class=keyword>namespace </span><span class=identifier>boost</span>
|
||||||
<span class=special>{
|
<span class=special>{
|
||||||
</span><span class=keyword>namespace </span><span class=identifier>range_detail
|
</span><span class=keyword>namespace </span><span class=identifier>range_detail
|
||||||
</span><span class=special>{
|
</span><span class=special>{
|
||||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||||
</span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special><</span><span class=identifier>T</span><span class=special>>:</span><span class=identifier>type </span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>r </span><span class=special>)
|
</span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special><</span><span class=identifier>T</span><span class=special>>:</span><span class=identifier>type </span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>r </span><span class=special>)
|
||||||
</span><span class=special>{ </span><span class=comment>/* normal implementation */ </span><span class=special>}
|
</span><span class=special>{ </span><span class=comment>/* normal implementation */ </span><span class=special>}
|
||||||
</span><span class=special>}
|
</span><span class=special>}
|
||||||
|
|
||||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||||
</span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special><</span><span class=identifier>T</span><span class=special>>::</span><span class=identifier>type </span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>r </span><span class=special>)
|
</span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special><</span><span class=identifier>T</span><span class=special>>::</span><span class=identifier>type </span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>r </span><span class=special>)
|
||||||
</span><span class=special>{
|
</span><span class=special>{
|
||||||
</span><span class=comment>//
|
</span><span class=comment>//
|
||||||
// Create ADL hook
|
// Create ADL hook
|
||||||
//
|
//
|
||||||
</span><span class=keyword>using </span><span class=identifier>range_detail</span><span class=special>::</span><span class=identifier>begin</span><span class=special>;
|
</span><span class=keyword>using </span><span class=identifier>range_detail</span><span class=special>::</span><span class=identifier>begin</span><span class=special>;
|
||||||
</span><span class=keyword>return </span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>r </span><span class=special>);
|
</span><span class=keyword>return </span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>r </span><span class=special>);
|
||||||
</span><span class=special>}</span>
|
</span><span class=special>}</span>
|
||||||
<span class=special>} </span>
|
<span class=special>} </span>
|
||||||
</pre>
|
</pre>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
Cool indeed!
|
Cool indeed!
|
||||||
</p>
|
</p>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user