Marshall Clow <[EMAIL PROTECTED]> 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 _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost