for (Something something : setOfSomething)
for (Something const& something : setOfSomething)
for (Something& something : setOfSomething)
error: invalid initialization of reference of type 'Something&'
from expression of type 'const Something'
Since when does the iterator return const Something? It must return either Something&or Something const&. And since the range-based "for" loop is interpreted as which , I have no plausible explanation of what is happening.
Edit: I'm talking about unordered_set, not set, sorry for this confusion.
source
share