|
Boost : |
From: David Abrahams (abrahams_at_[hidden])
Date: 2001-05-24 07:21:31
----- Original Message -----
From: "Vesa Karvonen" <vesa.karvonen_at_[hidden]>
> It should also be noted that the Named Template Parameters technique
suffers
> from the fact that in standard C++, you need to insert the keyword
> "template" when you refer to a member template of a type that depends on
the
> template arguments in template code (hmn... there must be a better/more
> accurate way of saying this). When that happens, the code becomes quite
> involved:
>
> template<class T>
> struct // ...
> {
> // ...
> iterator_traits_generator
> ::reference<T>
> ::template category<std::input_iterator_tag>
> ::template ...
> // ...
> };
If you reread it, you'll see that I made note of that problem in my original
message.
> > > Alternatively, it would be possible to let the generator take multiple
> > > parameters, and then make the list inside the generator:
> > >
> > > iterator_traits_generator
> > > < iterator_traits_reference<foo>
> > > , iterator_traits_category<std::input_iterator_tag>
> > > >::RET
> >
> > I think that would be better, though IMO it would be best if the
> parameters
> > were passed directly to boost::iterator_adaptor<> instead.
>
> That should be doable.
It has implications (as does the current technique) for iterator_adaptor
interoperability (see
http://www.boost.org/libs/utility/iterator_adaptors.htm#iterator_interaction
s) that ought to be worked out. I think perhaps allowing any two
iterator_adaptor<>s with the same Policies to interact at the interface
level, and using a BOOST_STATIC_ASSERT() or some such to enforce that
iterator_category and difference_type match would be fine.
> Assuming that both "class Base" and "template<class T> class
> std::iterator_traits" are accessible from the current scope, then in
> standard C++ the expression "std::iterator_traits<Base>" can not cause
> compilation errors.
It's true. The problem is that the expression for the default argument is
e.g. std::iterator_traits<Base>::value_type. If Base == int you have big
trouble.
-Dave
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk