Re:A Tour of C++, 3rd edition (covering C++20 plus a few lik...
by alexeiz on Sunday October 30, 2022 @12:32PM
(#33395877)
> Can safely implement scope guards
Can you elaborate on this?
Re:A Tour of C++, 3rd edition (covering C++20 plus a few lik...
by einpoklum on Sunday October 30, 2022 @02:22PM
(#33397132)
A count of the number of exceptions in-flight was added, replacing the boolean indication of whether an exception is in-flight. This allows the scope guard construct proposed by Andrei Alexandrescu to distinguish between a scope being left on success and on an exception being thrown.
YouTube video about scope guard: https://www.youtube.com/watch?v=WjTrfoiB0MQ
Description of the change to the standard: https://isocpp.org/files/papers/N4152.pdf
For C++20:
* Ranges! With may range operations and views
* Expansion of ability of compile-time computation, including a lot of standard library code.
* Concepts - constrained templates
* 3-way comparisons with spaceship operator + automatic comparisons generation.
* You can write your own modules (Java-esque import rather than textual inclusion)
* Support (albeit ugly) for co-routines
* Spans: https://stackoverflow.com/q/45723819/1593077
* Parallelism primitives
* Asynchronous network operations in the standard library (Boost-ASIO-based IIANM)
* Can safely implement scope guards
For C++23:
* Standard library via modules
* Stack traces (e.g. in exceptions)
* Many range views/algroithms/adapters
* Expected: https://stackoverflow.com/q/68368581/1593077
* Monadic semantics for std::optional
* etc.
> Are there really new features promised that today's programmer simply can't live without
Well, people can live with a lot. Many people write C, after all... so you could ask that about any language undergoing long term development.