diff --git a/indirect_iterator.htm b/indirect_iterator.htm index 5e20d42..fda27b9 100644 --- a/indirect_iterator.htm +++ b/indirect_iterator.htm @@ -66,9 +66,9 @@ purpose is to construct an indirect iterator type. The main template parameter for this class is the BaseIterator type that is being wrapped. In most cases the type of the elements being pointed to can be deduced using std::iterator_traits, but in some -sitatuions the user may want to override these types, so there are -also template parameters for the type being pointed to (the -Value) as well as reference and pointer versions of the type. +situations the user may want to override this type, so there are also +template parameters for the type being pointed to (the Value) +as well as reference and pointer versions of the type.
template <class BaseIterator, @@ -108,8 +108,7 @@ int main(int, char*[]) std::copy(indirect_first, indirect_last, std::ostream_iterator<char>(std::cout, ",")); std::cout << std::endl; - return 0; -} + // to be continued...
-
+template <class BaseIterator, + class Value, class Pointer, class Reference, + class ConstPointer, class ConstReference> +class indirect_iterator_pair_generator +{ +public: + typedef iterator_adaptor<...> iterator; // the mutable indirect iterator type + typedef iterator_adaptor<...> const_iterator; // the immutable indirect iterator type +}; ++ +
+ // continuing from the last example... + + typedef boost::indirect_iterator_pair_generator+The output is: +PairGen; + + char mutable_characters[N]; + char* pointers_to_mutable_chars[N]; + for (int i = 0; i < N; ++i) + pointers_to_mutable_chars[i] = &mutable_characters[i]; + + PairGen::iterator mutable_indirect_first(pointers_to_mutable_chars), + mutable_indirect_last(pointers_to_mutable_chars + N); + PairGen::const_iterator const_indirect_first(pointers_to_chars), + const_indirect_last(pointers_to_chars + N); + + std::transform(const_indirect_first, const_indirect_last, + mutable_indirect_first, std::bind1st(std::plus (), 1)); + + std::copy(mutable_indirect_first, mutable_indirect_last, + std::ostream_iterator (std::cout, ",")); + std::cout << std::endl; + // to be continued... +
+b,c,d,e,f,g,h, ++ +
Parameter | Description | +
---|---|
BaseIterator | +The iterator type being wrapped. The value type of the base iterator +should be a pointer (a Trivial +Iterator). | + +
Value | +The value-type of the value-type of the base iterator. That is, the
+type of object that is accessed by dereferences in the base iterator twice. +Default: +std::iterator_traits<std::iterator_traits<BaseIterator>::value_type>::value_type + |
+
+
Reference | +The corresponding reference type for the Value. +Default: Value& |
+
+
+
Pointer | +The corresponding pointer type for the Value. +Default: Value* |
+
+
+
ConstReference | +The corresponding const reference type for the Value. +Default: const Value& |
+
+
+
ConstPointer | +The corresponding const pointer type for the Value. +Default: const Value* |
+
+
+
+indirect_iterator_pair_generator::iterator(const BaseIterator& it) ++ +
+indirect_iterator_pair_generator::const_iterator(const BaseIterator& it) +
+ template <class BaseIterator> + typename indirect_iterator_generator<BaseIterator>::type + make_indirect_iterator(BaseIterator base) ++ + +
+ // continuing from the last example... + + std::copy(boost::make_indirect_iterator(pointers_to_chars), + boost::make_indirect_iterator(pointers_to_chars + N), + std::ostream_iterator+The output is: +(std::cout, ",")); + std::cout << std::endl; + + return 0; +} +
+a,b,c,d,e,f,g, +
Revised 10 Feb 2001
@@ -197,3 +351,9 @@ any purpose.