I have a vector of integers:
std::vector<int> values = {1,2,3,4,5,6,7,8,9,10};
I simply want to convert the adjacent elements into a pair, like this:
std::vector<std::pair<int,int>> values = { {1,2}, {3,4} , {5,6}, {7,8} ,{9,10} };
i.e.the two adjacent elements are joined into a pair.
What STL algorithm I can use to easily achieve this?
I don't know what STL algorithm to use. And I only want to achieve this through some standard algorithms.
Aucun commentaire:
Enregistrer un commentaire