C++ still doesn't have good loop syntax
Walter Bright
newshound2 at digitalmars.com
Wed Jul 15 01:43:56 UTC 2026
```d
import std.stdio;
string[9] vec = [
"the", "quick", "brown", "fox",
"jumped", "over", "the", "lazy", "dog"
];
void main()
{
foreach (i, s; vec)
writeln(i, ": ", s);
}
```
https://news.ycombinator.com/item?id=48915184
```C++
vector<string> vec = {
"the", "quick", "brown", "fox",
"jumped", "over", "the", "lazy", "dog"
};
for (int i=0; auto&& it: vec)
cout << (++i) << ": " << it << endl;
```
https://lzon.ca/posts/tips/cpp-for-range-init/
More information about the Digitalmars-d
mailing list