C++ std::transform vector of pairs->first to new vector
问题 Sorry for a little bit beginner question. There are vector and vector of pairs typedef std::vector <int> TItems; typedef std::vector < std::pair <int, int> > TPairs; Is there any way to transform all first items in pair to another vector in one step int main () { TItems items; TPairs pairs; pairs.push_back (std::make_pair(1,3)); pairs.push_back (std::make_pair(5,7)); std::transform( items.begin(), items.end(), items.begin(), comp ( &pairs ) ); return 0; } How to design a functor? class comp {