Boost logo

Boost Users :

Subject: Re: [Boost-users] identity function
From: Krzysztof Czainski (1czajnik_at_[hidden])
Date: 2011-10-01 11:01:05


W dniu 1 pa¼dziernika 2011 14:57 u¿ytkownik Krzysztof ¯elechowski <
giecrilj_at_[hidden]> napisa³:

> I use the following function on a regular basis:
>
> template < class P_T > P_T const &same (P_T const &p) { return p; }
>
> I use it for two purposes:
>
> 1. to pass an identity function to an API that expects a unary function,
> 2. to help the compiler identify the right chain of type conversions.
>
> The standard uses static_cast for (2), which could be used but it disables
> some compile-time verification so I would rather not use static_cast when
> not absolutely necessary.
>
> I have been unable to find a corresponding feature in Boost (although the
> value factory comes close). Do you think adding such a function to Boost
> utilities would be worthwhile?
>
> Chris
>

I'm looking for somthing like this too.

Kris



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