Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2000-12-29 00:16:43


If you want to use a function returning a reference, use projection
iterator instead of transform.

Also, using IteratorTraits::pointer for the pointer type is not going to
work. Suppose the transform function converts int's to std::string's.
IteratorTraits::pointer is going to be int*, but doesn't it make more
sense to have std::string* as the pointer type?

Cheers,
Jeremy

On Thu, 28 Dec 2000, David Abrahams wrote:

abraha> Arun,
abraha>
abraha> The transform_iterator is Jeremy's class, so I'll have to leave definitive
abraha> answers to him, but:
abraha> It seems to me that you are right. At least for compilers which support
abraha> partial specialization we should be able to deduce an appropriate value_type
abraha> and pointer type.
abraha>
abraha> -Dave
abraha>
abraha> ----- Original Message -----
abraha> From: "arun " <aruns_at_[hidden]>
abraha>
abraha>
abraha> > Can Jeremy/Dave or someone explain why
abraha> > transform_iterator_traits have the type pointer defined as
abraha> >
abraha> > typedef value_type* pointer;
abraha> >
abraha> > This seeems to be making assumptions (needless?) about
abraha> > value_type.
abraha> >
abraha> > For example ,use of transform_iterator with a function
abraha> > that returns a const T& would be inviting trouble.
abraha> >
abraha> > And why cant one use the other alternative viz
abraha> >
abraha> > typedef IteratorTraits::pointer pointer;
abraha> >
abraha> > This puts us more in control of type pointer and avoids
abraha> > the error that we get when using functions returning
abraha> > references in transform_iterator.This also requires
abraha> > that the value_type be compatible with the pointer.(can the compiler
abraha> > be left to decide that?)
abraha> >
abraha> > -arun
abraha> >
abraha> >
abraha> >
abraha> >
abraha> >
abraha>
abraha>
abraha>
abraha>
abraha>

----------------------------------------------------------------------
 Jeremy Siek www: http://www.lsc.nd.edu/~jsiek/
 Ph.D. Candidate email: jsiek_at_[hidden]
 Univ. of Notre Dame work phone: (219) 631-3906
----------------------------------------------------------------------


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