diff --git a/iterator_adaptors.htm b/iterator_adaptors.htm index c471a4e..2778b97 100644 --- a/iterator_adaptors.htm +++ b/iterator_adaptors.htm @@ -129,11 +129,11 @@

iterator_adaptor is declared like this:

 template <class Base, class Policies, 
-    class Value = typename std::iterator_traits<Base>::value_type,
-    class Reference = ...(see below),
-    class Pointer = ...(see below),
-    class Category = typename std::iterator_traits<Base>::iterator_category,
-    class Distance = typename std::iterator_traits<Base>::difference_type>
+    class ValueOrNamedParams = typename std::iterator_traits<Base>::value_type,
+    class ReferenceOrNamedParams = ...(see below),
+    class PointerOrNamedParams = ...(see below),
+    class CategoryOrNamedParams = typename std::iterator_traits<Base>::iterator_category,
+    class DistanceOrNamedParams = typename std::iterator_traits<Base>::difference_type>
 struct iterator_adaptor;
 
@@ -203,8 +203,79 @@ struct iterator_adaptor; The difference_type for the resulting iterator.
Default: std::iterator_traits<BaseType>::difference_type + + + NamedParams + + A list of named template parameters generated using the + + iterator_traits_generator class (see below). +

Named Template Parameters

+ + With seven template parameters, providing arguments for + iterator_adaptor in the correct order can be challenging. + Also, often times one would like to specify the sixth or seventh + 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 iterator_traits_generator class. + + +
+
+class iterator_traits_generator
+{
+public:
+  template <class Value>
+  struct value_type : public recursive magic { };
+
+  template <class Reference>
+  struct reference : public recursive magic { };
+
+  template <class Pointer>
+  struct pointer : public recursive magic { };
+
+  template <class Distance>
+  struct difference_type : public recursive magic { };
+
+  template <class Category>
+  struct iterator_category : public recursive magic { };
+};
+
+
+
+ + The iterator_traits_generator is used to create a list of + of template arguments. For example, suppose you want to set the + Reference and Category parameters, and use the + defaults for the rest. Then you can use the traits generator as + follows: + +
+
+iterator_traits_generator::reference<foo>::category<std::input_iterator_tag>
+
+
+ + This generated type can then be passed into the + iterator_adaptor class to replace any of the last five + parameters. If you use the traits generator in the ith + parameter position, then the parameters i through 7 will + use the types specified in the generator. + +
+
+iterator_adaptor<foo_iterator, foo_policies,
+    iterator_traits_generator
+    ::reference<foo>
+    ::category<std::input_iterator_tag>
+>
+
+
+ +

The Policies Class

The main task in using iterator_adaptor is creating an