3 ms·
C++23 example, import std; using namespace std; int main() { vector vec = { "the", "quick", "brown", "fox", "ju
by pjmlp 4mo ago
C++23 example,
import std;
using namespace std;
int main() {
vector vec = {
"the", "quick", "brown", "fox",
"jumped", "over", "the", "lazy", "dog"
};
for (auto&& [i, it] : vec | std::views::enumerate)
println ("{}:{}", ++i, it);
}
As I keep mentioning, the features being copied, slowly erode D's relevance.
- deleted 4mo ago[deleted]
- WalterBright 4mo agoIf you prefer writing: for (auto&& [i, it] : vec | std::views::enumerate) println ("{}:{}", ++i, it); instead of: foreach (i, s; vec) writeln(i, ": ", s); well, what can I say?
- acehreli 4mo agoWe may first need to go over what "elegant" means I guess. :)
- pjmlp 4mo agoThere is elegant when writing code by hand, and when reviewing code by AI agents.
- pjmlp 4mo agoI prefer to use the option with better market share. I am not counting characters, especially when AI completes typing for me.