mirror of
https://github.com/boostorg/utility.git
synced 2025-08-01 05:44:37 +02:00
changed named parameters doc to match new stuff
[SVN r11417]
This commit is contained in:
@@ -131,11 +131,11 @@
|
||||
<p><tt>iterator_adaptor</tt> is declared like this:
|
||||
<pre>
|
||||
template <class Base, class Policies,
|
||||
class ValueOrNamedParams = typename std::iterator_traits<Base>::value_type,
|
||||
class ReferenceOrNamedParams = <i>...(see below)</i>,
|
||||
class PointerOrNamedParams = <i>...(see below)</i>,
|
||||
class CategoryOrNamedParams = typename std::iterator_traits<Base>::iterator_category,
|
||||
class DistanceOrNamedParams = typename std::iterator_traits<Base>::difference_type>
|
||||
class ValueOrNamedParam = typename std::iterator_traits<Base>::value_type,
|
||||
class ReferenceOrNamedParam = <i>...(see below)</i>,
|
||||
class PointerOrNamedParam = <i>...(see below)</i>,
|
||||
class CategoryOrNamedParam = typename std::iterator_traits<Base>::iterator_category,
|
||||
class DistanceOrNamedParam = typename std::iterator_traits<Base>::difference_type>
|
||||
struct iterator_adaptor;
|
||||
</pre>
|
||||
|
||||
@@ -208,11 +208,9 @@ struct iterator_adaptor;
|
||||
<tt>std::iterator_traits<BaseType>::difference_type</tt>
|
||||
|
||||
<tr>
|
||||
<td><tt>NamedParams</tt>
|
||||
<td><tt>NamedParam</tt>
|
||||
|
||||
<td>A list of named template parameters generated using the
|
||||
<a href="#iterator_traits_generator">
|
||||
<tt>iterator_traits_generator</tt></a> class (see below).
|
||||
<td>A named template parameter (see below).
|
||||
</table>
|
||||
|
||||
<h3><a name="named_template_parameters">Named Template Parameters</a></h3>
|
||||
@@ -223,59 +221,32 @@ struct iterator_adaptor;
|
||||
template parameter, but use the defaults for the third through
|
||||
fifth. As a solution to these problems we provide a mechanism for
|
||||
naming the last five template parameters, and providing them in
|
||||
any order through the <tt>iterator_traits_generator</tt> class.
|
||||
|
||||
any order through a set of named template parameters. The following
|
||||
classes are provided for specifying the parameters. Any of these
|
||||
classes can be used for any of the last five template parameters
|
||||
of <tt>iterator_adaptor</tt>.
|
||||
<blockquote>
|
||||
<pre>
|
||||
<a name="iterator_traits_generator">class iterator_traits_generator</a>
|
||||
{
|
||||
public:
|
||||
template <class Value>
|
||||
struct value_type : public <i>recursive magic</i> { };
|
||||
|
||||
template <class Reference>
|
||||
struct reference : public <i>recursive magic</i> { };
|
||||
|
||||
template <class Pointer>
|
||||
struct pointer : public <i>recursive magic</i> { };
|
||||
|
||||
template <class Distance>
|
||||
struct difference_type : public <i>recursive magic</i> { };
|
||||
|
||||
template <class Category>
|
||||
struct iterator_category : public <i>recursive magic</i> { };
|
||||
};
|
||||
template <class Value> struct value_type_is;
|
||||
template <class Reference> struct reference_is;
|
||||
template <class Pointer> struct pointer_is;
|
||||
template <class Distance> struct difference_type_is;
|
||||
template <class Category> struct iterator_category_is;
|
||||
</pre>
|
||||
</blockquote>
|
||||
|
||||
The <tt>iterator_traits_generator</tt> is used to create a list of
|
||||
of template arguments. For example, suppose you want to set the
|
||||
<tt>Reference</tt> and <tt>Category</tt> parameters, and use the
|
||||
defaults for the rest. Then you can use the traits generator as
|
||||
follows:
|
||||
For example, the following adapts <tt>foo_iterator</tt> to create
|
||||
an <a href=
|
||||
"http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</a>
|
||||
with <tt>reference</tt> type <tt>foo</tt>, and whose other traits
|
||||
are determined according to the defaults described <a
|
||||
href="#template_parameters">above</a>.
|
||||
|
||||
<blockquote>
|
||||
<pre>
|
||||
iterator_traits_generator::reference<foo>::category<std::input_iterator_tag>
|
||||
</pre>
|
||||
</blockquote>
|
||||
|
||||
This generated type can then be passed into the <tt>iterator_adaptor</tt>
|
||||
class to replace any of the last five parameters. If you use the traits
|
||||
generator in the <i>i</i>th parameter position, then the parameters <i>i</i>
|
||||
through 7 will use the types specified in the generator. For example, the
|
||||
following adapts <tt>foo_iterator</tt> to create an <a href=
|
||||
"http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</a> with
|
||||
<tt>reference</tt> type <tt>foo</tt>, and whose other traits are determined
|
||||
according to the defaults described <a href="#template_parameters">above</a>.
|
||||
|
||||
<blockquote>
|
||||
<pre>
|
||||
iterator_adaptor<foo_iterator, foo_policies,
|
||||
iterator_traits_generator
|
||||
::reference<foo>
|
||||
::iterator_category<std::input_iterator_tag>
|
||||
>
|
||||
typedef iterator_adaptor<foo_iterator, foo_policies,
|
||||
reference_is<foo>, iterator_category_is<std::input_iterator_tag>
|
||||
> MyIterator;
|
||||
</pre>
|
||||
</blockquote>
|
||||
|
||||
|
Reference in New Issue
Block a user