KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a vector of integers and I want to convert it to a vector of pairs (pair consists of a bool and a int). My current code is simple like this: std::vector<int> a; std::vector<std::pair<bool,int> > b; a.push_back(1); a.push_back(2); a.push_back(3); for(int i = 0; i < a.size(); ++i) { b.push_back(std::make_pair(false, a[i])); } Is there any way to do this without writing the loop myself? Probably using some algorithms?
Tags (comma-separated)
Save Edits
Cancel