Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-01-13 11:55:49


Roland Richter <roland_at_[hidden]> writes:

> Hi,
>
> as mentioned in the docs, it is necessary to tell MS VC++
> all template parameters of an iterator_adaptor *explicitly*.

No, not usually. If the docs say that, they should be fixed.

> Unfortunately, it seems one cannot do that for a permutation_iterator,
> since permutation_iterator_generator just takes ElementIterator
> and IndexIterator as its template parameters.
>
> I propose extending the code like this:
>
> template< typename ElementIterator, typename IndexIterator,
> // Reasonable default, but can be passed explicitly for MSVC:
> typename ValueType = boost::detail::iterator_traits<ElementIterator>::value_type
> // etc.
> >
> struct permutation_iterator_generator
> {
> typedef boost::iterator_adaptor
> < ElementIterator,
> permutation_iterator_policies< IndexIterator >,
> ValueType
> // etc.
> > type;
> };
>
> in order to write something like
>
> typedef permutation_iterator_generator<
> element_range_type::iterator,
> index_type::iterator,
> element_range_type::value_type // tells MSVC++ the value_type
> >::type
>
>
> to keep MSVC quiet.
>
> I'm not sure, but I think I saw the same trick for some other
> iterator adaptors. Comments?

IIRC, it doesn't work if ElementIterator happens to be a pointer,
because the default expression is evaluated even if you supply that
argument. On the other hand, the new strategy for pointer iterators
is to ask the user to specialize boost::detail::iterator_traits
manually. We supply boost::detail::ptr_iterator_traits to help with
that.

We are working on a redesign of the library, currently in
$BOOST_SANDBOX/boost/iterator/iterator_adaptors.hpp. We don't have a
permutation iterator in there yet.

HTH,

-- 
                       David Abrahams
   dave_at_[hidden] * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk