C++17 brought us a nicer way to iterate through map
using the Structured binding, as shown in this example .
I am bound to use C++14 but have a lot of repeating code that iterates over maps.
In C++14 it looks like this:
for (auto const& item : myMap)
{
std::string key = x.first;
int value = x.second;
//Code...
}
Is there a way to create either a template / define
/ using
/ anything else that will allow me the convenience of iterating in this manner but still compile as a C++14 application?
for( auto const& [key, value] : myMap)
{
//Code...
}