Just passing by, but this did the job for me, so it can for somebody else (cut version):
template
struct first_of {
First& operator()(std::pair& v) const {
return v.first;
}
};
Use case given:
transform (v.begin (), v.end (),
ostream_iterator(cout, "\n"), first_of ());