Suppose I have a vector<int> myVec;
and I want to convert it to a set, I can have a one liner-
set<int> mySet(myVec.begin(), myVec.end());
This is something that can be found easily.
Now I have vector<pair<int, int>>
, and I want to obtain the set of the second values in each of the pairs. How should I use a set constructor to achieve this? Is it possible?
Assuming I have C++11, C++14, C++17.
Also, I would appreciate if I can get some information about how to do similar tweaks in a general sense for different containers.