This can’t be further from truth. C++ is essentially Frankenstein’s monster.
C++20 Improved the For-Loop Syntax
11–20 of 89 posts
Re: C++20 Improved the For-Loop Syntax
#12Just what C++ needs, more bloat lol.
C++ is probably the only language that needs a strong style guide, to define a subset you are allowed to use in the project. Linus Torwalds famously said that subset is zero. You're not allowed to use C++ in Linux, a wise move. Here's Google's: https://google.github.io/styleguide/cppguide.html Search for "do not use" and you'll find plenty of hits.
here you go: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
Re: C++20 Improved the For-Loop Syntax
#13Earlier quoted context omitted.
Python is 0-indexed. In OP's example, the start parameter makes i start at 1. Their C++17 example prints starting from 0. Probably a mistake. If you look at the linked page for C++20[0], other types can be put in the initializer statement, so it's unlikely the loop auto-increments. [0]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p06...
So, it's just a while loop in a for loop's clothing? That's not going to be confusing for people at all...
Re: C++20 Improved the For-Loop Syntax
#14Re: C++20 Improved the For-Loop Syntax
#15Re: C++20 Improved the For-Loop Syntax
#16 import std.stdio;
string[9] vec = [
"the", "quick", "brown", "fox",
"jumped", "over", "the", "lazy", "dog"
];
void main()
{
foreach (i, s; vec)
writeln(i, ": ", s);
}Re: C++20 Improved the For-Loop Syntax
#17C++20 also has an enumerate() generator, so if you like the python syntax you can just do: for (auto [i,v] : std::views::enumerate(vec)) std::cout FWIW C++23 also has a python-like print and println: std::println("{}: {}", i, v);
Re: C++20 Improved the For-Loop Syntax
#18 for (auto [i, v] : std::views::enumerate(vec)) {
std::cout
This is how you'd do it.Re: C++20 Improved the For-Loop Syntax
#19> It seems to me that the C++ Standards Committee is doing a decent job maintaining the language, and introducing useful features when it makes sense to do so. This can’t be further from truth. C++ is essentially Frankenstein’s monster.
If anything it is more of a Chimera
Re: C++20 Improved the For-Loop Syntax
#20> It seems to me that the C++ Standards Committee is doing a decent job maintaining the language, and introducing useful features when it makes sense to do so. This can’t be further from truth. C++ is essentially Frankenstein’s monster.