I am looking for a way to iterate through the keys of a map in C++ 17. The way that I have in mind right now is based on the answer of this question, the way is presented below.
for (auto const& [i, val] : myMap)
...
However, I do not need to use the value val
, I just need the value i
. Therefore, the piece of code ...
does not contain any call to the value val
. Consequently, whenever I compile the code, the following warning message appears:
warning: unused variable ‘val’ [-Wunused-variable]
for (auto const& [i, val] : myMap){
^
What I want is to find a way to iterate through (only) the keys of the map, ignoring the values. Does anyone have any idea how to do it?