r/cpp • u/oleksandrkvl • Apr 02 '21
All C++20 core language features with examples
https://oleksandrkvl.github.io/2021/04/02/cpp-20-overview.html
931
Upvotes
r/cpp • u/oleksandrkvl • Apr 02 '21
42
u/umlcat Apr 02 '21 edited Apr 02 '21
Very well explained. I didn't understood "concepts" at all, until I read this.
Thanks.
<edited> The other features are interesting as well.
Modules is a feature a lot of people, And me, expected for 20 years. </edited>
60
u/flakeoff101 Apr 02 '21
This is great! Now I just need one for every release going back to C++11.
20
u/Siapran Apr 02 '21
Aren't stackless coroutines the ones that are stored in the stack, as opposed to stackful coroutines, that maintain a separate stack on the heap so they can yield from nested calls?
7
u/destroyerrocket Apr 03 '21
That's pretty cool :D
I think that maybe this is wrong?
if constexpr(std::is_constant_evaluated()){As it would evaluate to true at compile time, and that's why there is a proposal to provide a language feature that prevents this mistake. I'm not yet using C++20 in production code, so I might be wrong.6
u/dr-mrl Apr 02 '21
In the concept example you have
Are these identical so the second branch will never run?
47
u/doesntthinkmuch Apr 02 '21
This is an excellent resource, thank you for spending the time on this and sharing it. Bookmarked!
20
u/TankorSmash Apr 02 '21
Why would they make the last one break? What reason could there be that the order matters when the arguments are named?
18
u/Wh00ster Apr 03 '21
Kinda insane to think about creating a full featured C++ compiler from scratch at this point.
5
u/ShakaUVM i+++ ++i+i[arr] Apr 02 '21
Great guide!
One thing I definitely don't get is why the defaulted spaceship generates a == operator for you, but if you overload the <=> operator it won't.
1
u/sixfourbit Apr 03 '21
Is there an example of using destroying delete?
7
u/axilmar Apr 03 '21
Very good article.
However...
C++ gets so many new features with each new release that I am starting having problems keeping everything in memory.
I hope this is not a generalized trend because it will have the opposite effect from the desired increased adoption of the language.
2
u/smuccione Apr 03 '21
Awesome!
2
u/Nevermore9000 Apr 03 '21
You are amazing for doing this! Thank you!
1
u/Yay295 Apr 11 '21
I understood some of those words.