Entries by Rainer Grimm

std::format in C++20

Today, I’m happy to present Peter Gottschling’s guest post to the new formatting library in C++20: std::format.  Thanks to std::format, text formatting becomes in C++20 as easy as in Python.

And the Winners are:

Last week,  I launched a quiz. The price was it to win one of the five vouchers for the book “Modern C++ for Absolute Beginners” from Slobodan Dmitrović.

New Attributes with C++20

With C++20, we got new and improved attributes such as [[nodiscard(“reason”)]], [[likely]], [[unlikely]], and [[no_unique_address]]. In particular, [[nodiscard(“reason”)]] allows it to express the intention of your interface way clearer.

More Lambda Features with C++20

Lambdas in C++20 can be default-constructed and support copy-assignment when they have no state. Lambdas can be used in unevaluated contexts. Additionally, they detect when you implicitly copy the this pointer. This means a significant cause of undefined behavior with lambdas is gone.