Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2001-10-05 17:01:48


On Thu, 4 Oct 2001, David Abrahams wrote:
david.>
david.> Is the result_type of an AdaptableUnaryFunction returning a reference
david.> supposed to be a reference type? I would think so. Our documentation seems
david.> to suggest making the result_type a value instead. Jeremy?

The projection_iterator assumes that the result_type is not a reference.
Hmm, now to decide whether this was a good assumption or not...
I'm looking at the definition of

http://www.sgi.com/tech/stl/AdaptableUnaryFunction.html
and some models of it like
http://www.sgi.com/tech/stl/identity.html

template <class T>
struct identity {
  typedef T result_type;
  const T& operator()(const T& x) const { return x; }
};

the way identity is defined suggests that result_type is expected
to not be a reference...
Also, looking at plus, minus, etc. same thing.

Then looking at ptr_fun... I wonder if the designer anticipated
it being used with function that return a reference type. The example
there, fabs returns by value. I think the problem is really with
the use of ptr_fun with functions returning references, not with
projection_iterator.

Cheers,
Jeremy

----------------------------------------------------------------------
 Jeremy Siek http://php.indiana.edu/~jsiek/
 Ph.D. Student, Indiana Univ. B'ton email: jsiek_at_[hidden]
 C++ Booster (http://www.boost.org) office phone: (812) 855-3608
----------------------------------------------------------------------


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