|
Boost Users : |
Subject: Re: [Boost-users] Runtime identity
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2010-12-01 04:00:42
On Tue, Nov 30, 2010 at 3:20 PM, Steven Watanabe <watanabesj_at_[hidden]>wrote:
> AMDG
>
>
> On 11/30/2010 7:06 AM, Robert Jones wrote:
>
>> I'm not sure if this is a stupid question, but is there a runtime
>> equivalent
>> of boost.mpl's identity
>> metafunction?
>>
>> Something that just returns it's single argument, eg.,
>>
>> template<typename T> T identity( T t ) { return t; }
>>
>> I think it's trivially simple to write, but I wonder if it already exists
>> in
>> Boost or
>> indeed the STL?
>>
>> (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?)
>>
>
>
> boost::lambda::_1?
>
>
Thx Steven - as usual exactly the right answer to the question.
I however have realised I'm asking completely the wrong question. What I in
fact
want to do is to create on the fly a nullary function object which returns a
constant
value.
Possibly this is what lambda::constant does?
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