Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-07-10 06:21:13


Marshall Clow <marshall_at_[hidden]> writes:

> I recently had a need for a functor to return a component of a
> std::pair, and I was
> surprised to see that they didn't exist either in the standard library
> or in boost.
>
> So, here they are. Are they useful to anyone else? Is there some reason that
> they don't already exist? Did I miss them somewhere?
>
> template <class T1, class T2>
> struct first: std::unary_function< std::pair <T1, T2>, T1>
> {
> T1 operator()(const std::pair <T1, T2> & x) const { return x.first;}
> };
>
> template <class T1, class T2>
> struct first: std::unary_function< std::pair <T1, T2>, T2>
> {
> T2 operator()(const std::pair <T1, T2> & x) const { return x.second;}
> };
>

The second one appears to be misnamed.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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