Visual C++ 2010 accepts:
std::vector<int> v;
v.push_back(1);
v.push_back(2);
v.push_back(3);
for each (auto i in v)
std::cout << i << std::endl;
Is this a C++11 feature or a Microsoft extension? According to Wikipedia, the syntax of C++11's for-each loop different:
int myint[] = {1,2,3,4,5};
for (int& i: myint)
{
std::cout << i;
}
The current standard draft does not include the for each ( auto i in v )
syntax, only the for ( auto i : myints )
, so yes, it is just an extension.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With