Boost logo

Boost Users :

Subject: Re: [Boost-users] Runtime identity
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2010-12-01 03:55:48


On Tue, Nov 30, 2010 at 11:48 PM, John B. Turpish <jbturp_at_[hidden]> wrote:

> On Tue, Nov 30, 2010 at 10:06 AM, Robert Jones <robertgbjones_at_[hidden]>
> wrote:
> > Something that just returns it's single argument, eg.,
> >
> > template <typename T> T identity( T t ) { return t; }
> ...
> > (I need this because I need to pass a function object which simply
> returns
> > an
> > object I already have - maybe I've missed a more obvious method?)
>
> The way you wrote it, wouldn't that actually return a temporary that
> is a copy of the object you already have? (rather than a const T& or
> something)
>
>
It would, (it was off-the-cuff for illustration) but also because my T type
is in fact a pointer so copy semantics would be ok. Good point tho'.

I have also realised I'm actually asking completely the wrong question in
any
case, so it's all become a bit irrelevant!

Thx, Rob.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net