When I iterate over a std::unordered_map
with the range based for loop twice, is the order guaranteed to be equal?
std::unordered_map<std::string, std::string> map;
std::string query = "INSERT INTO table (";
bool first = true;
for(auto i : map)
{
if(first) first = false;
else query += ", ";
query += i.first;
}
query += ") ";
query += "VALUES (";
first = true;
for(auto i : map)
{
if(first) first = false;
else query += ", ";
query += i.second;
}
query += ");"
In the example above, the resulting string should be in that form. Therefore, it is important that both times, the order of iteration is the same.
INSERT INTO table (key1, key2, key3) VALUES (value1, value2, value3);
Is this guaranteed in C++?