Visual Studio supports a pre-C++11 non-standard for each in their support for C++17 and earlier. I receive such code from users working with Visual Studio, and would like to replace it with standard C++:
#include <vector>
int main(int argc, char *argv[])
{
std::vector<int> v{};
for each(auto i in v){ }
return 0;
}
What would be a suitable replacement for the for each? I'm thinking it should be for (auto i : v), for (auto& i : v), or for (const auto& i : v).
From the doc: for each, in
For native C++, for each(auto i in v)
i is a copy of the vector element