vendredi 23 décembre 2016

Will C++17 support the simpler Range-based For Loop?

Since C++11, we can write:

vector<int> coll{1, 2, 3, 4};
for (auto x : coll)
{
    cout << x << endl;
}

According to Essentials of Modern C++ Style, the following code will soon be also legal in C++:

vector<int> coll{1, 2, 3, 4};
for (x : coll)
{
    cout << x << endl;
}

Will this feature be available in C++17 or C++20?

Aucun commentaire:

Enregistrer un commentaire