Boost logo

Boost :

From: Hartmut Kaiser (hartmutkaiser_at_[hidden])
Date: 2003-03-26 10:07:27

David Abrahams wrote:

> >> I have a problem while using the iterator_adaptor templates
> >> in conjunction with a istreambuf_iterator<char> (an
> >> input_iterator type). The problem shows up, because the
> >> istreambuf_iterator<char>::operator*()
> >> implementation of the STL I'm using returns a value_type
> >> (char), but the dereference policy member expects to return
> >> it a reference.
> >>
> >> It seems, that there should be a similar return type deduction for
> >> the
> >> iterator_adaptor<>::operator*() function as already
> >> implemented for the
> >> iterator_adaptor<>::operator->() function.
> >
> > Regards Hartmut
> Which template are you having problems with? Can you post
> some code which reproduces the problem? Did you try
> explicitly specifying the iterator's reference type?

I've attached a minimal (braindead) sample, which reproduces the problem
(it does not compile).

The input_iterator used as the Base iterator of the adaptor returns a
value_type from its operator*(), but the iterator_adaptor template
expects a reference here. Surely I could solve it by adding a member of
type value_type to my policy class, using it as a buffer and the
reference to it may be returned, but isn't it better to resolve it in
the adaptor? Even more because a congruent problem, which happens often
with the operator->() is already solved through a proxy class. I believe
that the operator*() problem may be solved in a similar fashion.

Regards Hartmut

Boost list run by bdawes at, gregod at, cpdaniel at, john at