This code compiles and works, with an 'unused variable i' warning:
for(auto [camera, i]: landmark->getObservations())
camerasToCounts[camera]++;
I want to ignore i, so I replaced it with std::ignore
. The following code doesn't compile:
...
#include <tuple>
...
for(auto [camera, std::ignore]: landmark->getObservations())
camerasToCounts[camera]++;
with this error:
error: expected ‘]’ before ‘::’ token
and this warning:
warning: unused variable ‘std’ [-Wunused-variable]
Because it is not recognizing std::ignore.
Some context:
- I'm using C++17 with gcc 7.4.0, and Eclipse CDT.
- Syntax checker shows the same error the compiler does. This is coherent.
- Same problem in other for range in many cpp files of the same project. It is a general problem, not a particularly bounded to that specific line.
Just to test, this line compiles fine:
std::ignore = 0;
so gcc recognizes std::ignore, it only fails to do so in for range.
Already read this good question and answer about ignoring in structured bindings.
Is there someone with a similar problem?
Thank you!