While 2020 was a crazy and hard year we were fortunate - C++20 was accepted and published, and the work on new features continues.
As usually every year, here’s my overview of the year: the standardization process, features, implementation, compilers, tools, books and more.
Previous reports:
2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012.
Runtime polymorphism usually connects with v-tables and virtual functions. However, in this blog post, I’ll show you a modern C++ technique that leverages std::variant and std::visit. This C++17 technique might offer not only better performance and value semantics but also interesting design patterns.
Last Update: 2nd Nov 2020 (Passing arguments, Build time benchmark, fixes).
With the addition of Ranges and Concepts in C++20, our good old algorithm interfaces got super long “rangified” versions. For example, copy is now 4 lines long… and it’s just the declaration!
template <ranges::input_range R, std::weakly_incrementable O> requires std::indirectly_copyable<ranges::iterator_t<R>, O> constexpr ranges::copy_result<ranges::borrowed_iterator_t<R>, O> copy(R&& r, O result); How to decipher such a long declaration?
In my previous article on polymorphic allocators, we discussed some basic ideas. For example, you’ve seen a pmr::vector that holds pmr::string using a monotonic resource. How about using a custom type in such a container? How to enable it? Let’s see.
The Goal In the previous article there was similar code:
Up to (and including) C++17 if you wanted to check the start or the end in a string you have to use custom solutions, boost or other third-party libraries. Fortunately, this changes with C++20.
See the article where I’ll show you the new functionalities and discuss a couple of examples.
We’re on the last day of the lambda week. We have all the essential knowledge, and now we can learn some tricks!
The Series This blog post is a part of the series on lambdas:
The syntax changes (Tuesday 4th August) Capturing things (Wednesday 5th August) Going generic (Thursday 6th August) Tricks (Friday 5th August)(this post) +[]() Have a closer look:
We’re in the third day of the lambda week. So far, you’ve learned basic syntax and how to capture things. Another important aspect is that lambdas can also be used in the “generic” scenarios. This is especially possible since C++14 where we got generic lambdas (auto arguments), and then in C++20, you can even specify a template lambda!
We’re in the second day of the lambda week. Today you’ll learn about the options you have when you want to capture things from the external scope. Local variables, global, static, variadic packs, this pointer… what’s possible and what’s not?
The Series This blog post is a part of the series on lambdas:
Let’s start the week with Lambda Expressions. The plan is to have a set of concise articles presenting core elements of lambda expressions. Today you can see how the syntax has evolved starting since C++11 and what are the latest changes in C++20.
The Series This blog post is a part of the series on lambdas:
The concept of a polymorphic allocator from C++17 is an enhancement to standard allocators from the Standard Library.
It’s much easier to use than a regular allocator and allows containers to have the same type while having a different allocator, or even a possibility to change allocators at runtime.
In articles about lambda expression (like this one from last week on my page), it’s easy to show examples where the lambda runs on the same thread as the caller. But how about asynchronous cases? What if your lambda is called on a separate thread? What problems you might encounter there.
[](){}
The mixture of brackets in the preceding line become one of the most noticeable indications of Modern C++. Yep. Lambda Expressions! It might sound like I’m trying to create a new blog post about something that everyone knows. Is that true? Do you know all the details of this modern C++ technique?