I want to iterate through an object in c++11, and like the new syntax. If I have the following code:
for (auto x : object) {
...
}
I have a case where I don't want to use 'x'. That will produce a warning, as expected. How do I best suppress this warning?
I suppose I can add a line (void)x; but maybe there is some better way?
If there is no better way, can I be sure that the void reference to 'x' generates no code?
There is of course the old way of using iterators, but it looks much better with the new way of doing it. Or tell the compiler to ignore these warnings, which I do not want to do.