Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is "for each" Microsoft specific?

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;
}
like image 843
George Avatar asked Sep 11 '10 10:09

George


1 Answers

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.

like image 195
David Rodríguez - dribeas Avatar answered Oct 07 '22 01:10

David Rodríguez - dribeas