C++ at the end of 2020

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.

READ MORE...

Runtime Polymorphism with std::variant and std::visit

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).

READ MORE...

Increased Complexity of C++20 Range Algorithms Declarations - Is It Worth?

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?

READ MORE...

Lambda Week: Tricks

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:

READ MORE...

Lambda Week: Going Generic

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!

READ MORE...

Lambda Week: Capturing Things

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:

READ MORE...

Lambda Week: Syntax changes, C++11 to C++20

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:

READ MORE...