Is there a way to construct a map with two ranges in C++? That is, instead of calling a default constructor and consequently inserting elements to a map:
for (size_t i = 0; i < Vector_1.size() && i < Vector_2.size(); i++) {
mymap[Vector_1[i]] = Vector_2[i];
}
I'd like to build a map in place by calling some sort of a constructor which would take two ranges as arguments, something like this:
std::map<t1, t2> mymap(Vector_1.begin(), Vector_1.end(), Vector_2.begin(), Vector_2.end());
Or:
mymap.insert(Vector_1.begin(), Vector_1.end(), Vector_2.begin(), Vector_2.end());
I haven't found any, but maybe there is still a way to do it. Is there a shortcut to initialize a map from two ranges, or at least insert two ranges into a map?