Is it possible to iterate over all of the values in a std::map using just a "foreach"?
std::map
This is my current code:
Since C++20 you can add the range adaptor std::views::values from the Ranges library to your range-based for loop. This way you can implement a similar solution to the one in Xeo's answer, but without using Boost:
std::views::values
#include #include std::map foo; for (auto const &i : foo | std::views::values) i->bar();
Code on Wandbox