Marshall Clow <[EMAIL PROTECTED]> writes:
> So, here they are. Are they useful to anyone else? Is there some reason thatthey 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.
Yeah. :-( Teach me to try to "boostify" them using an email client.
But other than that, what do people think?
I needed them because someone had a map<int, Foo*>, and I wanted to call a member function
(call it "Bar") on each Foo* in the map. Turns out, that with boost::compose and 'second', it
was simple:
std::for_each ( m.begin (), m.end (),
boost::compose_f_gx ( std::mem_fun ( Foo::Bar ), second <int, Foo *> ()));
-- -- Marshall
Marshall Clow Idio Software <mailto:[EMAIL PROTECTED]> Hey! Who messed with my anti-paranoia shot? _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost