major update wrt. new range concepts

[SVN r40962]
This commit is contained in:
Thorsten Jørgen Ottosen
2007-11-09 10:27:42 +00:00
parent 68a63cab85
commit 93deddde63
8 changed files with 393 additions and 344 deletions

View File

@ -94,14 +94,6 @@ class=identifier>range_difference</span></a><span class=special>;
</span><span class=keyword>struct </span><a
href="#range_reverse_iterator"><span
class=identifier>range_reverse_iterator</span></a><span class=special>;
</span><span class=comment>//
// Random Access Range metafunctions
//
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword>struct </span><a href="#range_size"><span
class=identifier>range_size</span></a><span class=special>;
</span><span class=comment>//
// Single Pass Range functions
@ -112,7 +104,7 @@ class=identifier>range_size</span></a><span class=special>;
</span><a href="#begin"><span class=identifier>begin</span></a><span class=special>( </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>c </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special>&lt;</span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type
</span><a href="#begin"><span class=identifier>begin</span></a><span class=special>( </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>c </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
@ -120,7 +112,7 @@ class=identifier>range_size</span></a><span class=special>;
</span><a href="#end"><span class=identifier>end</span></a><span class=special>( </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>c </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special>&lt;</span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type
</span><a href="#end"><span class=identifier>end</span></a><span class=special>( </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>c </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
@ -144,7 +136,7 @@ class=identifier>range_size</span></a><span class=special>;
</span><a href="#rbegin"><span class=identifier>rbegin</span></a><span class=special>( </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>c </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_reverse_iterator</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_reverse_iterator</span><span class=special>&lt;</span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type
</span><a href="#rbegin"><span class=identifier>rbegin</span></a><span class=special>( </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>c </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
@ -152,11 +144,10 @@ class=identifier>range_size</span></a><span class=special>;
</span><a href="#rend"><span class=identifier>rend</span></a><span class=special>( </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>c </span><span class=special>);
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_reverse_iterator</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_reverse_iterator</span><span class=special>&lt;</span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type
</span><a href="#rend"><span class=identifier>rend</span></a><span class=special>( </span><span class=keyword>const </span><span
class=identifier>T</span><span class=special>&amp; </span><span class=identifier>c </span><span class=special>);
</span>
</span><span class=comment>//
// Random Access Range functions
//
@ -164,7 +155,7 @@ class=identifier>T</span><span class=special>&amp; </span><span class=identifier
</span><span class=keyword>template</span><span class=special>&lt; </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>&gt;
</span><span class=keyword></span><span class=keyword>typename </span><span class=identifier>range_size</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;::</span><span class=identifier>type
</span><a href="#size"><span class=identifier>size</span></a><span class=special>( </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>&amp; </span><span class=identifier>c </span><span class=special>);
<span class=comment>//
// Special const Range functions
//
@ -247,10 +238,8 @@ class=identifier>T</span><span class=special>&amp; </span><span class=identifier
<tr>
<a name="range_value"></a>
<td><code>range_value&lt;X&gt;::type</code></td>
<td><code>T::value_type</code><br>
<code>boost::iterator_value&lt;P::first_type&gt;::type</code> <!--if <code>P</code> is an instantiation of <code>std::pair</code>--><br>
<code>A</code><br>
<code>Char</code>
<td><code>boost::iterator_value&lt;range_iterator&lt;X&gt;::type&gt;::type</code>
</td>
<td>compile time</td>
</tr>
<tr>
@ -264,7 +253,7 @@ class=identifier>T</span><span class=special>&amp; </span><span class=identifier
</tr>
<tr>
<a name="range_const_iterator"></a>
<td><code>range_const_iterator&lt;X&gt;::type</code></td>
<td><code>range_iterator&lt;const X&gt;::type</code></td>
<td><code>T::const_iterator</code><br>
<code>P::first_type</code><br>
<code>const A*</code><br>
@ -274,20 +263,11 @@ class=identifier>T</span><span class=special>&amp; </span><span class=identifier
<tr>
<a name="range_difference"></a>
<td><code>range_difference&lt;X&gt;::type</code></td>
<td><code>T::difference_type</code><br>
<code>boost::iterator_difference&lt;P::first_type&gt;::type</code><br>
<code>std::ptrdiff_t</code><br>
<code>std::ptrdiff_t</code><br>
<td>
<code>boost::iterator_difference&lt;range_iterator&lt;X&gt;::type&gt;::type</code></td>
<td>compile time</td>
</tr>
<tr>
<a name="range_size"></a>
<td><code>range_size&lt;X&gt;::type</code></td>
<td><code>T::size_type</code><br>
<code>std::size_t</code><br>
<code>std::size_t</code><br>
<code>std::size_t</code><br>
<td>compile time</td>
</tr>
<tr>
<a name="range_result_iterator"></a>
@ -301,31 +281,18 @@ class=identifier>T</span><span class=special>&amp; </span><span class=identifier
<tr>
<a name="range_reverse_iterator"></a>
<td><code>range_reverse_iterator&lt;X&gt;::type</code></td>
<td><code>boost::reverse_iterator&lt; typename range_iterator&lt;T&gt;::type &gt;</code><br>
<td><code>boost::reverse_iterator&lt;range_iterator&lt;X&gt;::type&gt;</code><br>
<td>compile time</td>
</tr>
<tr>
<a name="range_const_reverse_iterator"></a>
<td><code>range_const_reverse_iterator&lt;X&gt;::type</code></td>
<td><code>boost::reverse_iterator&lt; typename range_const_iterator&lt;T&gt;::type &gt;</code>
<td><code>range_reverse_iterator&lt;const X&gt;::type</code></td>
<td><code>boost::reverse_iterator&lt;range_iterator&lt;const X&gt;::type&gt;</code>
<br>
<td>compile time</td>
</tr>
<tr>
<a name="range_reverse_result_iterator"></a>
<td><code>range_reverse_result_iterator&lt;X&gt;::type</code></td>
<td><code>boost::reverse_iterator&lt; typename range_result_iterator&lt;T&gt;::type
&gt;</code>
<td>compile time</td>
</tr>
</table>
</p>
<p>
The special metafunctions <code>range_result_iterator</code> and <code>range_reverse_result_iterator</code>
are not part of any Range concept, but they are very useful when implementing
certain Range classes like <a href="utility_class.html#sub_range"><code>sub_range</code></a>
because of their ability to select iterators based on constness.
</p>
<h4>Functions</h4>
<p>
<table border="1" cellpadding="5">
@ -347,7 +314,7 @@ class=identifier>T</span><span class=special>&amp; </span><span class=identifier
<code>p.first</code> if <code>p</code> is of type <code>std::pair&ltT&gt;<code><br>
<code>a</code> if <code>a</code> is an array <br>
<code>s</code> if <code>s</code> is a string literal<br>
<code>boost_range_begin(x)</code> if that expression would invoke a function found by ADL <br>
<code>range_begin(x)</code> if that expression would invoke a function found by ADL <br>
<code>t.begin()</code> otherwise
<td>constant time</td>
@ -363,7 +330,7 @@ class=identifier>T</span><span class=special>&amp; </span><span class=identifier
<br>
<code>s + sz - 1</code> if <code>s</code> is a string literal of size <code>sz</code>
<br>
<code>boost_range_end(x)</code> if that expression would invoke a function found by ADL <br>
<code>range_end(x)</code> if that expression would invoke a function found by ADL <br>
<code>t.end()</code> otherwise
<td>linear if <code>X</code> is <code>Char*</code>
@ -380,27 +347,32 @@ class=identifier>T</span><span class=special>&amp; </span><span class=identifier
constant time otherwise<br>
</td>
</tr>
<tr>
<a name="distance"></a>
<td><code>distance(x)</code></td>
<td><code>range_difference&lt;X&gt;::type</code></td>
<td>
<code>
std::distance(boost::begin(x),boost::end(x))
</code>
</td>
<td>-</td>
</tr>
<tr>
<a name="size"></a>
<td><code>size(x)</code></td>
<td><code>range_size&lt;X&gt;::type</code></td>
<td>
<code>std::distance(p.first,p.second)</code> if <code>p</code> is of type <code>std::pair&ltT&gt;<code><br>
<code>sz</code> if <code>a</code> is an array of size <code>sz</code><br>
<code>end(s) - s</code> if <code>s</code> is a string literal or a <code>Char*</code><br>
<code>boost_range_size(x)</code> if that expression would invoke a function found by ADL <br>
<code>t.size()</code> otherwise
<td>linear if <code>X</code> is <code>Char*</code>
<br>
or if <code>std::distance()</code> is linear
<br>
constant time otherwise</td>
<td><code>range_difference&lt;X&gt;::type</code></td>
<td><code> boost::end(x) - boost::begin(x)</code>
<td> constant time </td>
</tr>
<tr>
<a name="rbegin"></a>
<td><code>rbegin(x)</code></td>
<td><code>range_reverse_result_iterator&lt;X&gt;::type</code></td>
<td><code>range_reverse_result_iterator&lt;X&gt;::type( end(x) )</code>
<td><code>range_reverse_iterator&lt;X&gt;::type</code></td>
<td><code>range_reverse_iterator&lt;X&gt;::type( end(x) )</code>
<br>
<td>same as <code>end(x)</code>
</td>
@ -408,15 +380,15 @@ class=identifier>T</span><span class=special>&amp; </span><span class=identifier
<tr>
<a name="rend"></a>
<td><code>rend(x)</code></td>
<td><code>range_reverse_result_iterator&lt;X&gt;::type</code></td>
<td><code>range_reverse_result_iterator&lt;X&gt;::type( begin(x) )</code>
<td><code>range_reverse_iterator&lt;X&gt;::type</code></td>
<td><code>range_reverse_iterator&lt;X&gt;::type( begin(x) )</code>
<td>same as <code>begin(x)</code></td>
</tr>
<tr>
<a name="const_begin"></a>
<td><code>const_begin(x)</code></td>
<td><code>range_const_iterator&lt;X&gt;::type</code></td>
<td><code>range_const_iterator&lt;X&gt;::type( begin(x) )</code>
<td><code>range_iterator&lt;const X&gt;::type</code></td>
<td><code>range_iterator&lt;const X&gt;::type( begin(x) )</code>
<br>
<td>same as <code>begin(x)</code>
</td>
@ -424,15 +396,15 @@ class=identifier>T</span><span class=special>&amp; </span><span class=identifier
<tr>
<a name="const_end"></a>
<td><code>const_end(x)</code></td>
<td><code>range_const_iterator&lt;X&gt;::type</code></td>
<td><code>range_const_iterator&lt;X&gt;::type( end(x) )</code>
<td><code>range_iterator&lt;const X&gt;::type</code></td>
<td><code>range_iterator&lt;const X&gt;::type( end(x) )</code>
<td>same as <code>end(x)</code></td>
</tr>
<tr>
<a name="const_rbegin"></a>
<td><code>const_rbegin(x)</code></td>
<td><code>range_const_reverse_iterator&lt;X&gt;::type</code></td>
<td><code>range_const_reverse_iterator&lt;X&gt;::type( rbegin(x) )</code>
<td><code>range_reverse_iterator&lt;const X&gt;::type</code></td>
<td><code>range_reverse_iterator&lt;const X&gt;::type( rbegin(x) )</code>
<br>
<td>same as <code>rbegin(x)</code>
</td>
@ -440,21 +412,22 @@ class=identifier>T</span><span class=special>&amp; </span><span class=identifier
<tr>
<a name="const_rend"></a>
<td><code>const_rend(x)</code></td>
<td><code>range_const_reverse_iterator&lt;X&gt;::type</code></td>
<td><code>range_const_reverse_iterator&lt;X&gt;::type( rend(x) )</code>
<td><code>range_reverse_iterator&lt;const X&gt;::type</code></td>
<td><code>range_reverse_iterator&lt;const X&gt;::type( rend(x) )</code>
<td>same as <code>rend(x)</code></td>
</tr>
</table>
</p>
<p>
The special <code>const</code> functions are not part of any Range concept, but
are very useful when you want to document clearly that your code is read-only.
The special <code>const_</code>-named functions are useful when you
want to document clearly that your code is read-only.
</p>
<hr>
<a name="minimal_interface"></a>
<h3>Extending the library</h3>
<ul>
<li><a href="#method1">Method 1: provide member functions and nested types</a></li>
<li><a href="#method2">Method 2: provide free-standing functions and specialize metafunctions</a></li>
</ul>
@ -491,10 +464,6 @@ class=identifier>T</span><span class=special>&amp; </span><span class=identifier
</td>
<td><a href="range.html#single_pass_range">Single Pass Range</a></td>
</tr>
<tr>
<td><code>size()</code></td>
<td><a href="range.html#forward_range">Forward Range</a></td>
</tr>
</table>
</p>
<p>
@ -520,10 +489,6 @@ class=identifier>T</span><span class=special>&amp; </span><span class=identifier
<td><code>const_iterator</code></td>
<td><a href="range.html#single_pass_range">Single Pass Range</a></td>
</tr>
<tr>
<td><code>size_type</code></td>
<td><a href="range.html#forward_range">Forward Range</a></td>
</tr>
</table>
</p>
<p>
@ -554,26 +519,23 @@ class=identifier>T</span><span class=special>&amp; </span><span class=identifier
<th>
Related concept</th>
<tr>
<td><code>boost_range_begin(x)</code></td>
<td><code>range_begin(x)</code></td>
<td><a href="range.html#single_pass_range">Single Pass Range</a></td>
</tr>
<tr>
<td><code>boost_range_end(x)</code>
<td><code>range_end(x)</code>
</td>
<td><a href="range.html#single_pass_range">Single Pass Range</a></td>
</tr>
<tr>
<td><code>boost_range_size(x)</code></td>
<td><a href="range.html#forward_range">Forward Range</a></td>
</tr>
</table>
</p>
<p><code>boost_range_begin()</code> and <code>boost_range_end()</code> must be
<p><code>range_begin()</code> and <code>range_end()</code> must be
overloaded for both <code>const</code> and mutable reference arguments.
</p>
<p>
You must also specialize 3 metafunctions for your type <code>X</code>:
You must also specialize two metafunctions for your type <code>X</code>:
</p>
<p>
<table cellpadding="5" border="1" ID="Table2">
@ -583,17 +545,14 @@ class=identifier>T</span><span class=special>&amp; </span><span class=identifier
<th>
Related concept</th>
<tr>
<td><code>boost::range_iterator</code></td>
<td><code>boost::range_mutable_iterator</code></td>
<td><a href="range.html#single_pass_range">Single Pass Range</a></td>
</tr>
<tr>
<td><code>boost::range_const_iterator</code></td>
<td><a href="range.html#single_pass_range">Single Pass Range</a></td>
</tr>
<tr>
<td><code>boost::range_size</code></td>
<td><a href="range.html#forward_range">Forward Range</a></td>
</tr>
</table>
</p>
<p>
@ -627,7 +586,7 @@ class=identifier>T</span><span class=special>&amp; </span><span class=identifier
//</span>
<span class=keyword>template</span><span class=special>&lt;</span> <span class=keyword>class</span> <span class=identifier>T</span> <span class=special>&gt;</span>
<span class=keyword>struct</span> <span class=identifier>range_iterator</span><span class=special>&lt;</span> <span class=identifier>Foo</span><span class=special>::</span><span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;</span> <span class=special>&gt;</span>
<span class=keyword>struct</span> <span class=identifier>range_mutable_iterator</span><span class=special>&lt;</span> <span class=identifier>Foo</span><span class=special>::</span><span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;</span> <span class=special>&gt;</span>
<span class=special>{</span>
<span class=keyword>typedef</span> <span class=identifier>T</span> <span class=identifier>type</span><span class=special>;</span>
<span class=special>};</span>
@ -636,20 +595,13 @@ class=identifier>T</span><span class=special>&amp; </span><span class=identifier
<span class=keyword>struct</span> <span class=identifier>range_const_iterator</span><span class=special>&lt;</span> <span class=identifier>Foo</span><span class=special>::</span><span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;</span> <span class=special>&gt;</span>
<span class=special>{</span>
<span class=comment>//
// Remark: this is defined similar to 'range_iterator'
// Remark: this is defined similar to 'range_mutable_iterator'
// because the 'Pair' type does not distinguish
// between an iterator and a const_iterator.
//</span>
<span class=keyword>typedef</span> <span class=identifier>T</span> <span class=identifier>type</span><span class=special>;</span>
<span class=special>};</span>
<span class=keyword>template</span><span class=special>&lt;</span> <span class=keyword>class</span> <span class=identifier>T</span> <span class=special>&gt;</span>
<span class=keyword>struct</span> <span class=identifier>range_size</span><span class=special>&lt;</span> <span class=identifier>Foo</span><span class=special>::</span><span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;</span> <span class=special>&gt;</span>
<span class=special>{</span>
<span class=keyword>typedef</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>size_t</span> <span class=identifier>type</span><span class=special>;</span>
<span class=special>};</span>
<span class=special>}</span> <span class=comment>// namespace 'boost'</span>
<span class=keyword>namespace</span> <span class=identifier>Foo</span>
@ -661,36 +613,29 @@ class=identifier>T</span><span class=special>&amp; </span><span class=identifier
//</span>
<span class=keyword>template</span><span class=special>&lt;</span> <span class=keyword>class</span> <span class=identifier>T</span> <span class=special>&gt;</span>
<span class=keyword>inline</span> <span class=identifier>T</span> <span class=identifier>boost_range_begin</span><span class=special>(</span> <span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;&amp;</span> <span class=identifier>x</span> <span class=special>)</span>
<span class=keyword>inline</span> <span class=identifier>T</span> <span class=identifier>range_begin</span><span class=special>(</span> <span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;&amp;</span> <span class=identifier>x</span> <span class=special>)</span>
<span class=special>{</span>
<span class=keyword>return</span> <span class=identifier>x</span><span class=special>.</span><span class=identifier>first</span><span class=special>;</span>
<span class=special>}</span>
<span class=keyword>template</span><span class=special>&lt;</span> <span class=keyword>class</span> <span class=identifier>T</span> <span class=special>&gt;</span>
<span class=keyword>inline</span> <span class=identifier>T</span> <span class=identifier>boost_range_begin</span><span class=special>(</span> <span class=keyword>const</span> <span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;&amp;</span> <span class=identifier>x</span> <span class=special>)</span>
<span class=keyword>inline</span> <span class=identifier>T</span> <span class=identifier>range_begin</span><span class=special>(</span> <span class=keyword>const</span> <span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;&amp;</span> <span class=identifier>x</span> <span class=special>)</span>
<span class=special>{</span>
<span class=keyword>return</span> <span class=identifier>x</span><span class=special>.</span><span class=identifier>first</span><span class=special>;</span>
<span class=special>}</span>
<span class=keyword>template</span><span class=special>&lt;</span> <span class=keyword>class</span> <span class=identifier>T</span> <span class=special>&gt;</span>
<span class=keyword>inline</span> <span class=identifier>T</span> <span class=identifier>boost_range_end</span><span class=special>(</span> <span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;&amp;</span> <span class=identifier>x</span> <span class=special>)</span>
<span class=keyword>inline</span> <span class=identifier>T</span> <span class=identifier>range_end</span><span class=special>(</span> <span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;&amp;</span> <span class=identifier>x</span> <span class=special>)</span>
<span class=special>{</span>
<span class=keyword>return</span> <span class=identifier>x</span><span class=special>.</span><span class=identifier>last</span><span class=special>;</span>
<span class=special>}</span>
<span class=keyword>template</span><span class=special>&lt;</span> <span class=keyword>class</span> <span class=identifier>T</span> <span class=special>&gt;</span>
<span class=keyword>inline</span> <span class=identifier>T</span> <span class=identifier>boost_range_end</span><span class=special>(</span> <span class=keyword>const</span> <span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;&amp;</span> <span class=identifier>x</span> <span class=special>)</span>
<span class=keyword>inline</span> <span class=identifier>T</span> <span class=identifier>range_end</span><span class=special>(</span> <span class=keyword>const</span> <span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;&amp;</span> <span class=identifier>x</span> <span class=special>)</span>
<span class=special>{</span>
<span class=keyword>return</span> <span class=identifier>x</span><span class=special>.</span><span class=identifier>last</span><span class=special>;</span>
<span class=special>}</span>
<span class=keyword>template</span><span class=special>&lt;</span> <span class=keyword>class</span> <span class=identifier>T</span> <span class=special>&gt;</span>
<span class=keyword>inline</span> <span class=keyword>typename</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>range_size</span><span class=special>&lt;</span> <span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;</span> <span class=special>&gt;::</span><span class=identifier>type</span>
<span class=identifier>boost_range_size</span><span class=special>(</span> <span class=keyword>const</span> <span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>T</span><span class=special>&gt;&amp;</span> <span class=identifier>x</span> <span class=special>)</span>
<span class=special>{</span>
<span class=keyword>return</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>distance</span><span class=special>(</span><span class=identifier>x</span><span class=special>.</span><span class=identifier>first</span><span class=special>,</span><span class=identifier>x</span><span class=special>.</span><span class=identifier>last</span><span class=special>);</span>
<span class=special>}</span>
<span class=special>}</span> <span class=comment>// namespace 'Foo'</span>
<span class=preprocessor>#include</span> <span class=special>&lt;</span><span class=identifier>vector</span><span class=special>&gt;</span>
@ -699,7 +644,7 @@ class=identifier>T</span><span class=special>&amp; </span><span class=identifier
<span class=special>{</span>
<span class=keyword>typedef</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>vector</span><span class=special>&lt;</span><span class=keyword>int</span><span class=special>&gt;::</span><span class=identifier>iterator</span> <span class=identifier>iter</span><span class=special>;</span>
<span class=identifier>std</span><span class=special>::</span><span class=identifier>vector</span><span class=special>&lt;</span><span class=keyword>int</span><span class=special>&gt;</span> <span class=identifier>vec</span><span class=special>;</span>
<span class=identifier>Foo</span><span class=special>::</span><span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>iter</span><span class=special>&gt;</span> <span class=identifier>pair</span> <span class=special>=</span> <span class=special>{</span> <span class=identifier>vec</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span> <span class=identifier>vec</span><span class=special>.</span><span class=identifier>end</span><span class=special>()</span> <span class=special>};</span>
<span class=identifier>Foo</span><span class=special>::</span><span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>iter</span><span class=special>&gt;</span> <span class=identifier>pair</span> <span class=special>=</span> <span class=special>{</span> <span class=identifier>vec</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span> <span class=identifier>vec</span><span class=special>.</span><span class=identifier>end</span><span class=special>()</span> <span class=special>};</span>
<span class=keyword>const</span> <span class=identifier>Foo</span><span class=special>::</span><span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>iter</span><span class=special>&gt;&amp;</span> <span class=identifier>cpair</span> <span class=special>=</span> <span class=identifier>pair</span><span class=special>;</span>
<span class=comment>//
// Notice that we call 'begin' etc with qualification.
@ -708,9 +653,9 @@ class=identifier>T</span><span class=special>&amp; </span><span class=identifier
<span class=identifier>iter</span> <span class=identifier>e</span> <span class=special>=</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>end</span><span class=special>(</span> <span class=identifier>pair</span> <span class=special>);</span>
<span class=identifier>i</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>cpair</span> <span class=special>);</span>
<span class=identifier>e</span> <span class=special>=</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>end</span><span class=special>(</span> <span class=identifier>cpair</span> <span class=special>);</span>
<span class=identifier>boost</span><span class=special>::</span><span class=identifier>range_size</span><span class=special>&lt;</span> <span class=identifier>Foo</span><span class=special>::</span><span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>iter</span><span class=special>&gt;</span> <span class=special>&gt;::</span><span class=identifier>type</span> <span class=identifier>s</span> <span class=special>=</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>size</span><span class=special>(</span> <span class=identifier>pair</span> <span class=special>);</span>
<span class=identifier>boost</span><span class=special>::</span><span class=identifier>range_difference</span><span class=special>&lt;</span> <span class=identifier>Foo</span><span class=special>::</span><span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>iter</span><span class=special>&gt;</span> <span class=special>&gt;::</span><span class=identifier>type</span> <span class=identifier>s</span> <span class=special>=</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>size</span><span class=special>(</span> <span class=identifier>pair</span> <span class=special>);</span>
<span class=identifier>s</span> <span class=special>=</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>size</span><span class=special>(</span> <span class=identifier>cpair</span> <span class=special>);</span>
<span class=identifier>boost</span><span class=special>::</span><span class=identifier>range_const_reverse_iterator</span><span class=special>&lt;</span> <span class=identifier>Foo</span><span class=special>::</span><span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>iter</span><span class=special>&gt;</span> <span class=special>&gt;::</span><span class=identifier>type</span>
<span class=identifier>boost</span><span class=special>::</span><span class=identifier>range_reverse_iterator</span><span class=special>&lt;</span> <span class=identifier>const Foo</span><span class=special>::</span><span class=identifier>Pair</span><span class=special>&lt;</span><span class=identifier>iter</span><span class=special>&gt;</span> <span class=special>&gt;::</span><span class=identifier>type</span>
<span class=identifier>ri</span> <span class=special>=</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>rbegin</span><span class=special>(</span> <span class=identifier>cpair</span> <span class=special>),</span>
<span class=identifier>re</span> <span class=special>=</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>rend</span><span class=special>(</span> <span class=identifier>cpair</span> <span class=special>);</span>
<span class=special>}</span>
@ -719,7 +664,7 @@ class=identifier>T</span><span class=special>&amp; </span><span class=identifier
<hr>
<p>
(C) Copyright Thorsten Ottosen 2003-2004
(C) Copyright Thorsten Ottosen 2003-2007
</p>
<br>
<br>

View File

@ -26,10 +26,6 @@
</li>
shows how to implement a container version of <code >std::find()</code> that
works with <code >char[],wchar_t[],char*,wchar_t*.</code>
<p>
<b>Warning:</b><i> support for null-terminated strings is deprecated and will
disappear in the next Boost release (1.34). </i>
</p>
<li >
<a href="../test/algorithm_example.cpp" target="_self" ><code >algorithm_example.cpp</code></a>

View File

@ -35,16 +35,14 @@
enough functionality to satisfy the needs of the generic code
<i>if a suitable layer of indirection is applied </i>. For
example, raw arrays are often suitable for use with generic code that
works with containers, provided a suitable adapter is used. Likewise, null
terminated strings can be treated as containers of characters, if suitably
adapted.
works with containers, provided a suitable adapter is used.
</p>
<p>
This library therefore provides the means to adapt standard-like
containers,
null terminated strings, <code>std::pairs</code> of iterators, and raw
arrays (and more), such that the same generic code can work with them all.
containers, <code>std::pairs</code> of iterators, and raw arrays (and
more), such that
the same generic code can work with them all.
The basic idea is to add another layer of indirection using <a
href="../../mpl/doc/refmanual/metafunction.html">metafunctions</a> and
free-standing functions so syntactic and/or semantic differences can be removed.

View File

@ -3,14 +3,289 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.4: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils 0.3.10: http://docutils.sourceforge.net/" />
<title>Boost Range MFC/ATL Extension</title>
<meta name="author" content="Shunsuke Sogame" />
<meta name="date" content="26th of May 2006" />
<meta name="copyright" content="Shunsuke Sogame 2005-2006. Use, modification and distribution is subject to the Boost Software License, Version 1.0 (see LICENSE_1_0.txt)." />
<style type="text/css">
@import "http://www.boost.org/libs/ptr_container/doc/default.css";
/*
:Author: David Goodger
:Contact: goodger@users.sourceforge.net
:Date: $Date: 2005-09-25 17:49:54 +0200 (Sun, 25 Sep 2005) $
:Revision: $Revision: 3901 $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* "! important" is used here to override other ``margin-top`` and
``margin-bottom`` styles that are later in the stylesheet or
more specific. See http://www.w3.org/TR/CSS1#the-cascade */
.first {
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin-left: 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left {
clear: left }
img.align-right {
clear: right }
img.borderless {
border: 0 }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font-family: serif ;
font-size: 100% }
pre.line-block {
font-family: serif ;
font-size: 100% }
pre.literal-block, pre.doctest-block {
margin-left: 2em ;
margin-right: 2em ;
background-color: #eeeeee }
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid thin gray }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid thin black }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
tt.docutils {
background-color: #eeeeee }
ul.auto-toc {
list-style-type: none }
</style>
</head>
@ -33,7 +308,7 @@
</table>
<div class="section">
<h1><a id="overview" name="overview">Overview</a></h1>
<p>Boost.Range MFC/ATL Extension provides <a class="reference" href="http://www.boost.org/libs/range/">Boost.Range</a> support for MFC/ATL collection and string types.</p>
<p>Boost.Range MFC/ATL Extension provides <a class="reference" href="../index.html">Boost.Range</a> support for MFC/ATL collection and string types.</p>
<pre class="literal-block">
CTypedPtrArray&lt;CPtrArray, CList&lt;CString&gt; *&gt; myArray;
...
@ -64,7 +339,7 @@ BOOST_FOREACH (CList&lt;CString&gt; *theList, myArray)
</div>
<div class="section">
<h1><a id="mfc-ranges" name="mfc-ranges">MFC Ranges</a></h1>
<p>If the <tt class="docutils literal"><span class="pre">&lt;boost/range/mfc.hpp&gt;</span></tt> is included before or after <a class="reference" href="http://www.boost.org/libs/range/">Boost.Range</a> headers,
<p>If the <tt class="docutils literal"><span class="pre">&lt;boost/range/mfc.hpp&gt;</span></tt> is included before or after <a class="reference" href="../index.html">Boost.Range</a> headers,
the MFC collections and strings become models of Range.
The table below lists the Traversal Category and <tt class="docutils literal"><span class="pre">range_reference</span></tt> of MFC ranges.</p>
<table border="1" class="docutils">
@ -170,7 +445,7 @@ The table below lists the Traversal Category and <tt class="docutils literal"><s
</tr>
</tbody>
</table>
<p>Other <a class="reference" href="http://www.boost.org/libs/range/">Boost.Range</a> metafunctions are defined by the following.
<p>Other <a class="reference" href="../index.html">Boost.Range</a> metafunctions are defined by the following.
Let <tt class="docutils literal"><span class="pre">Range</span></tt> be any type listed above and <tt class="docutils literal"><span class="pre">ReF</span></tt> be the same as <tt class="docutils literal"><span class="pre">range_reference&lt;Range&gt;::type</span></tt>.
<tt class="docutils literal"><span class="pre">range_value&lt;Range&gt;::type</span></tt> is the same as <tt class="docutils literal"><span class="pre">remove_reference&lt;remove_const&lt;Ref&gt;::type&gt;::type</span></tt>,
<tt class="docutils literal"><span class="pre">range_difference&lt;Range&gt;::type</span></tt> is the same as <tt class="docutils literal"><span class="pre">std::ptrdiff_t</span></tt>, and
@ -179,7 +454,7 @@ As for <tt class="docutils literal"><span class="pre">const</span> <span class="
</div>
<div class="section">
<h1><a id="atl-ranges" name="atl-ranges">ATL Ranges</a></h1>
<p>If the <tt class="docutils literal"><span class="pre">&lt;boost/range/atl.hpp&gt;</span></tt> is included before or after <a class="reference" href="http://www.boost.org/libs/range/">Boost.Range</a> headers,
<p>If the <tt class="docutils literal"><span class="pre">&lt;boost/range/atl.hpp&gt;</span></tt> is included before or after <a class="reference" href="../index.html">Boost.Range</a> headers,
the ATL collections and strings become models of Range.
The table below lists the Traversal Category and <tt class="docutils literal"><span class="pre">range_reference</span></tt> of ATL ranges.</p>
<table border="1" class="docutils">
@ -265,7 +540,7 @@ The table below lists the Traversal Category and <tt class="docutils literal"><s
</tr>
</tbody>
</table>
<p>Other <a class="reference" href="http://www.boost.org/libs/range/">Boost.Range</a> metafunctions are defined by the following.
<p>Other <a class="reference" href="../index.html">Boost.Range</a> metafunctions are defined by the following.
Let <tt class="docutils literal"><span class="pre">Range</span></tt> be any type listed above and <tt class="docutils literal"><span class="pre">ReF</span></tt> be the same as <tt class="docutils literal"><span class="pre">range_reference&lt;Range&gt;::type</span></tt>.
<tt class="docutils literal"><span class="pre">range_value&lt;Range&gt;::type</span></tt> is the same as <tt class="docutils literal"><span class="pre">remove_reference&lt;Ref&gt;::type</span></tt>,
<tt class="docutils literal"><span class="pre">range_difference&lt;Range&gt;::type</span></tt> is the same as <tt class="docutils literal"><span class="pre">std::ptrdiff_t</span></tt>, and
@ -288,7 +563,7 @@ else if (there is a type X such that X* const is the same as ReF)
else
return ReF
</pre>
<p>Other <a class="reference" href="http://www.boost.org/libs/range/">Boost.Range</a> metafunctions are defined by the following.
<p>Other <a class="reference" href="../index.html">Boost.Range</a> metafunctions are defined by the following.
<tt class="docutils literal"><span class="pre">range_value&lt;const</span> <span class="pre">Range&gt;::type</span></tt> is the same as <tt class="docutils literal"><span class="pre">range_value&lt;Range&gt;::type</span></tt>,
<tt class="docutils literal"><span class="pre">range_difference&lt;const</span> <span class="pre">Range&gt;::type</span></tt> is the same as <tt class="docutils literal"><span class="pre">std::ptrdiff_t</span></tt>, and
<tt class="docutils literal"><span class="pre">range_pointer&lt;const</span> <span class="pre">Range&gt;::type</span></tt> is the same as <tt class="docutils literal"><span class="pre">add_pointer&lt;remove_reference&lt;range_reference&lt;const</span> <span class="pre">Range&gt;::type&gt;::type&gt;::type</span></tt>.</p>
@ -296,18 +571,11 @@ else
<div class="section">
<h1><a id="references" name="references">References</a></h1>
<ul class="simple">
<li><a class="reference" href="http://www.boost.org/libs/range/">Boost.Range</a></li>
<li><a class="reference" href="../index.html">Boost.Range</a></li>
<li><a class="reference" href="http://msdn2.microsoft.com/en-us/library/942860sh.aspx">MFC Collections</a></li>
<li><a class="reference" href="http://msdn2.microsoft.com/en-US/library/15e672bd.aspx">ATL Collection Classes</a></li>
</ul>
</div>
</div>
<div class="footer">
<hr class="footer" />
<a class="reference" href="mfc_atl.rst">View document source</a>.
Generated on: 2006-06-04 22:37 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>
</html>

View File

@ -225,8 +225,8 @@ __ http://msdn2.microsoft.com/en-US/library/15e672bd.aspx
.. _Boost C++ Libraries: http://www.boost.org/
.. _Boost: `Boost C++ Libraries`_
.. _Boost.Range: http://www.boost.org/libs/range/
.. _forward: http://www.boost.org/libs/range/doc/range.html#forward_range
.. _bidirectional: http://www.boost.org/libs/range/doc/range.html#forward_range
.. _random access: http://www.boost.org/libs/range/doc/range.html#random_access_range
.. _Boost.Range: ../index.html
.. _forward: range.html#forward_range
.. _bidirectional: range.html#forward_range
.. _random access: range.html#random_access_range

View File

@ -36,7 +36,7 @@ href="http://boost.sourceforge.net/regression-logs/developer/range.html">here</a
<p >
Notice also that some compilers cannot do function template ordering properly.
In that case one must rely of <a
href="boost_range.html#range_result_iterator"><code >range_result_iterator</code></a>
href="boost_range.html#range_iterator"><code >range_iterator</code></a>
and a single function definition instead of overloaded versions for const and
non-const arguments.

View File

@ -50,7 +50,7 @@
Range provides iterators for accessing a half-open range
<code>[first,one_past_last)</code> of elements and provides
information about the number of elements in the Range. However, a Range has
fewer requirements than a Container.
<i>much</i> fewer requirements than a Container.
</p>
<p>
The motivation for the Range concept is
@ -78,9 +78,9 @@
The operations that can be performed on a Range is dependent on the
<a href="../../iterator/doc/new-iter-concepts.html#iterator-traversal-concepts-lib-iterator-traversal">traversal
category</a> of the underlying iterator type. Therefore
the range concepts are named to reflect which traversal category its
iterators support. See also <a href="style.html">terminology and style guidelines.</a>
for more information about naming of ranges.</p>
the range concepts are named to reflect which traversal category their
iterators support. See also <a href="style.html">terminology and style
guidelines.</a> for more information about naming of ranges.</p>
<p> The concepts described below specifies associated types as
<a href="../../mpl/doc/refmanual/metafunction.html">metafunctions</a> and all
@ -118,11 +118,7 @@ Single Pass Iterator</a>
<h3>Associated types</h3>
<table border="1" cellpadding="5">
<TR>
<TD VAlign="top">Value type</TD>
<TD VAlign="top"><code>boost::range_value&lt;X>::type</code></TD>
<TD VAlign="top">The type of the object stored in a Range.
</TR>
<TR>
<TD VAlign="top">Iterator type</TD>
<TD VAlign="top"><code>boost::range_iterator&lt;X>::type</code></TD>
@ -132,7 +128,7 @@ Single Pass Iterator</a>
</TR>
<TR>
<TD VAlign="top">Const iterator type</TD>
<TD VAlign="top"><code>boost::range_const_iterator&lt;X>::type</code></TD>
<TD VAlign="top"><code>boost::range_iterator&lt;const X>::type</code></TD>
<TD VAlign="top">A type of iterator that may be used to examine, but not to
modify, a Range's elements.</TD>
</TR>
@ -161,20 +157,16 @@ Single Pass Iterator</a>
<TD VAlign="top">Beginning of range</TD>
<TD VAlign="top"><code>boost::begin(a)</code></TD>
<TD VAlign="top"><code>boost::range_iterator&lt;X>::type</code> if
<code>a</code> is mutable, <code>boost::range_const_iterator&lt;X>::type</code>
<code>a</code> is mutable, <code>boost::range_iterator&lt;const X>::type</code>
otherwise</TD> </TR>
<TR>
<TD VAlign="top">End of range</TD>
<TD VAlign="top"><code>boost::end(a)</code></TD>
<TD VAlign="top"><code>boost::range_iterator&lt;X>::type</code> if
<code>a</code> is mutable, <code>boost::range_const_iterator&lt;X>::type</code>
<code>a</code> is mutable, <code>boost::range_iterator&lt;const X>::type</code>
otherwise</TD>
</TR>
<tr>
<TD VAlign="top">Is range empty?</TD>
<TD VAlign="top"><code>boost::empty(a)</code></TD>
<TD VAlign="top">Convertible to <code>bool</code></TD>
</TR>
</table>
<h3>Expression semantics</h3>
@ -188,7 +180,7 @@ otherwise</TD>
<TD VAlign="top"><code>boost::begin(a)</code></TD>
<TD VAlign="top">Returns an iterator pointing to the first element in the Range.</TD>
<TD VAlign="top"><code>boost::begin(a)</code> is either dereferenceable or past-the-end.
It is past-the-end if and only if <code>boost::size(a) == 0</code>.</TD>
It is past-the-end if and only if <code>boost::distance(a) == 0</code>.</TD>
</TR>
<TR>
<TD VAlign="top"><code>boost::end(a)</code></TD>
@ -196,19 +188,14 @@ otherwise</TD>
Range.</TD>
<TD VAlign="top"><code>boost::end(a)</code> is past-the-end.</TD>
</TR>
<TR>
<TD VAlign="top"><code>boost::empty(a)</code></TD>
<TD VAlign="top">Equivalent to <code>boost::begin(a) == boost::end(a)</code>. (But possibly
faster.)</TD>
<TD VAlign="top">&nbsp;-&nbsp;</TD>
</TR>
</table>
<h3>Complexity guarantees</h3>
All three functions are at most amortized linear time. For most practical
purposes, one can expect <code>boost::begin(a)</code>, <code>boost::end(a)</code> and <code>boost::empty(a)</code>
to be amortized constant time.
<code>boost::end(a)</code> is at most amortized linear time, <code>boost::begin(a)</code> is
amortized constant time. For most practical
purposes, one can expect both to be amortized constant time.
<h3>Invariants</h3>
<Table border>
@ -227,14 +214,17 @@ otherwise</TD>
<h3>See also</h3>
<p>
<A href="http://www.sgi.com/Technology/STL/Container.html">Container</A>
</p>
<p> <a href="boost_range.html#boost::range_value">implementation of
<p><a
href="boost_range.html#minimal_interface">Extending the library for UDTs </a></p>
<p> <a href="boost_range.html#boost::rang_difference">Implementation of
metafunctions </a></p>
<p> <a href="boost_range.html#begin">implementation of
<p> <a href="boost_range.html#begin">Implementation of
functions </a></p>
<p>
<A href="http://www.sgi.com/Technology/STL/Container.html">Container</A>
</p>
<hr>
<a name=forward_range><h2>Forward Range</h2>
@ -261,76 +251,8 @@ href="../../iterator/doc/new-iter-concepts.html#forward-traversal-iterators-lib-
<h3>Refinement of</h3> <a href="#single_pass_range">Single Pass
Range</a>
<h3>Associated types</h3>
<table cellpadding="5" border="1">
<TR>
<TD VAlign="top">Distance type</TD>
<TD VAlign="top"><code>boost::range_difference&lt;X>::type</code></TD>
<TD VAlign="top">A signed integral type used to represent the distance between
two of the Range's iterators. This type must be the same as the iterator's
distance type.</TD>
</TR>
<TR>
<TD VAlign="top">Size type</TD>
<TD VAlign="top"><code>boost::range_size&lt;X>::type</code></TD>
<TD VAlign="top">An unsigned integral type that can represent any nonnegative
value of the Range's distance type.</TD>
</tr>
</table>
<h3>Valid expressions</h3>
<table border="1" cellpadding="5">
<tr>
<th>Name</th>
<th>Expression</th>
<th>Return type</th>
</tr>
<TR>
<TD VAlign="top">Size of range</TD>
<TD VAlign="top"><code>boost::size(a)</code></TD>
<TD VAlign="top"><code>boost::range_size&lt;X>::type</code></TD>
</TR>
</table>
<h3>Expression semantics </h3>
<table border="1" cellpadding="5">
<TR>
<TH>Expression</TH>
<TH>Semantics</TH>
<TH>Postcondition</TH>
</TR>
<tr>
<TD VAlign="top"><code>boost::size(a)</code></TD>
<TD VAlign="top">Returns the size of the Range, that is, its number
of elements. Note <code>boost::size(a) == 0u</code> is equivalent to
<code>boost::empty(a).</code></TD>
<TD VAlign="top"><code>boost::size(a) &gt;= 0</TD>
</TR>
</table>
<h3>Complexity guarantees</h3>
<p><code>boost::size(a)</code> is at most amortized linear time.</p>
<h3>Invariants</h3>
<p>
<Table border="1" cellpadding="5">
<TR>
<TD VAlign="top">Range size</TD>
<TD VAlign="top"><code>boost::size(a)</code> is equal to the distance from <code>boost::begin(a)</code>
to <code>boost::end(a)</code>.</TD> </table>
</p>
<h3>See also</h3>
<p> <a href="boost_range.html#boost::range_difference">implementation of
metafunctions </a></p>
<p> <a href="boost_range.html#size">implementation of
functions </a></p>
</p>
<hr>
<a name="bidirectional_range"><h2>Bidirectional Range</h2>
@ -356,83 +278,8 @@ s-lib-bidirectional-traversal-iterators">Bidirectional Traversal Iterator.</a>
<h3>Refinement of</h3> <a href="#forward_range">Forward Range</a>
<h3>Associated types</h3>
<Table border>
<TR>
<TD VAlign="top">Reverse Iterator type</TD>
<TD VAlign="top"><code>boost::range_reverse_iterator&lt;X>::type</code></TD>
<TD VAlign="top">The type of iterator used to iterate through a Range's elements
in reverse order. The iterator's value type is expected to be the Range's value
type. A conversion from the reverse iterator type to the const reverse iterator
type must exist. </TD>
</TR>
<TR>
<TD VAlign="top">Const reverse iterator type</TD>
<TD
VAlign="top"><code>boost::range_const_reverse_iterator&ltX>::type</code></TD>
<TD VAlign="top">A type of reverse iterator that may be used to examine, but not
to modify, a Range's elements.</TD>
</TR>
</table>
<h3>Valid expressions</h3>
<Table border>
<TR>
<TH>Name</TH>
<TH>Expression</TH>
<TH>Return type</TH>
<TH>Semantics</TH>
</TR>
<TR>
<TD VAlign="top">Beginning of range</TD>
<TD VAlign="top"><code>boost::rbegin(a)</code></TD>
<TD VAlign="top"><code>boost::range_reverse_iterator&lt;X>::type</code> if
<code>a</code> is mutable, <code>boost::range_const_reverse_iterator&lt;X>::type</code>
otherwise.</TD>
<TD VAlign="top">Equivalent to
<code>boost::range_reverse_iterator&lt;X>::type(boost::end(a))</code>.</TD> </TR>
<TR>
<TD VAlign="top">End of range</TD>
<TD VAlign="top"><code>boost::rend(a)</code></TD>
<TD VAlign="top"><code>boost::range_reverse_iterator&lt;X>::type</code> if
<code>a</code> is mutable, <code>boost::range_const_reverse_iterator&lt;X>::type</code>
otherwise.</TD>
<TD VAlign="top">Equivalent to
<code>boost::range_reverse_iterator&lt;X>::type(boost::begin(a))</code>.</TD> </tr>
</table>
<h3>Complexity guarantees</h3>
<code>boost::rbegin(a)</code> has the same complexity as <code>boost::end(a)</code> and <code>boost::rend(a)</code>
has the same complexity as <code>boost::begin(a)</code> from <a
href="#forward_range">Forward Range</a>.
<h3>Invariants</h3>
<p>
<Table border="1" cellpadding="5">
<TR>
<TD VAlign="top">Valid reverse range</TD>
<TD VAlign="top">For any Bidirectional Range <code>a</code>, <code>[boost::rbegin(a),boost::rend(a))</code>
is a valid range, that is, <code>boost::rend(a)</code> is reachable from <code>boost::rbegin(a)</code>
in a finite number of increments.</TD>
</TR>
<TR>
<TD VAlign="top">Completeness</TD>
<TD VAlign="top">An algorithm that iterates through the range <code>[boost::rbegin(a),boost::rend(a))</code>
will pass through every element of <code>a</code>.</TD>
</tr>
</table>
</p>
<h3>See also</h3>
<p> <a href="boost_range.html#boost::range_reverse_iterator">implementation of metafunctions </a></p>
<p> <a href="boost_range.html#rbegin">implementation of
functions </a></p>
</p>
<hr>
@ -455,7 +302,7 @@ href="../../iterator/doc/new-iter-concepts.html#random-access-traversal-iterator
<a name=concept_checking><h2>Concept Checking</h2>
Each of the range concepts has a corresponding concept checking
class in the file boost/range/concepts.hpp. These classes may be
class in the file <code><boost/range/concepts.hpp></codE>. These classes may be
used in conjunction with the <a
href="../../concept_check/concept_check.htm">Boost Concept
Check</a> library to insure that the type of a template parameter
@ -529,7 +376,7 @@ href="../../iterator/doc/new-iter-concepts.html#random-access-traversal-iterator
<TD><A HREF=http://www.boost.org/people/jeremy_siek.htm>Jeremy Siek</A>
</TR>
<tr >
<TD nowrap>Copyright &copy 2004</TD>
<TD nowrap>Copyright &copy 2004-2007</TD>
<TD>Thorsten Ottosen.
</TABLE>

View File

@ -59,19 +59,16 @@ corresponding <code>const_iterator</code> is. </p>
<p>
If the template argument is not a model of Forward Traversal Iterator, one can
still use a subset of the interface. In particular, <code>size()</code> requires
Forward Traversal Iterators whereas <code>empty()</code> only requires Single
Random Access Iterators whereas <code>empty()</code> only requires Single
Pass Iterators.
</p>
<p>
Recall that many default constructed iterators
are <i>singular</i> and hence can only be assigned, but not compared or
incremented or anything. However, if one creates a default constructed
<code>iterator_range</code>, then one
can still call all its member functions. This means that the
<code>iterator_range</code> will still be usable in many contexts even
though the iterators underneath are not.
</p>
incremented or anything. Likewise, if one creates a default constructed
<code>iterator_range</code>, then one have to be careful about not doing
anything besides copying. </p>
<h3>Synopsis</h3>
@ -82,9 +79,6 @@ corresponding <code>const_iterator</code> is. </p>
</span><span class=keyword>class </span><span class=identifier>iterator_range
</span><span class=special>{
</span><span class=keyword>public</span><span class=special>: </span><span class=comment>// Forward Range types
</span><span class=keyword>typedef </span><span class=special>... </span><span class=identifier>value_type</span><span class=special>;
</span><span class=keyword>typedef </span><span class=special>... </span><span class=identifier>difference_type</span><span class=special>;
</span><span class=keyword>typedef </span><span class=special>... </span><span class=identifier>size_type</span><span class=special>;
</span><span class=keyword>typedef </span><span class=identifier>ForwardTraversalIterator </span><span class=identifier>iterator</span><span class=special>;
</span><span class=keyword>typedef </span><span class=identifier>ForwardTraversalIterator </span><span class=identifier>const_iterator</span><span class=special>;
@ -117,10 +111,11 @@ class=identifier><a href="#equal">equal</a></span><span
class=special>( </span><span class=keyword>const <span
class=identifier>iterator_range</span><span class=special>& ) </span><span
class=keyword>const;</span>
<span class=identifier>value_type</span><span class=special>&amp; </span><span class=identifier>front</span><span class=special>() </span><span class=keyword>const</span><span class=special>;</span>
<span class=identifier>value_type</span><span class=special>&amp; </span><span class=identifier>back</span><span class=special>() </span><span class=keyword>const</span><span class=special>;</span>
<span class=identifier>reference</span><span class=identifier>front</span><span class=special>() </span><span class=keyword>const</span><span class=special>;</span>
<span class=identifier>reference </span><span class=identifier>back</span><span class=special>() </span><span class=keyword>const</span><span class=special>;</span>
<span class=comment>// for Random Access Range only: </span>
<span class=identifier>value_type</span><span class=special>&amp; </span><span class=keyword>operator</span><span class=special>[]( </span><span class=identifier>size_type </span><span class=identifier>at </span><span class=special>) </span><span class=keyword>const</span><span class=special>;</span>
<span class=identifier>value_type</span>cial>&amp; </span><span class=keyword>operator</span><span class=special>()( </span><span class=identifier>size_type </span><span class=identifier>at </span><span class=special>) </span><span class=keyword>const</span><span class=special>;</span>
</span><span class=special>};
</span><span class=comment>// stream output