Articles & Books

Synchronization with Atomics in C++20--Rainer Grimm

Are you familiar with it?

Synchronization with Atomics in C++20

by Rainer Grimm

From the article:

Sender/receiver workflows are quite common for threads. In such a workflow, the receiver is waiting for the sender's notification before it continues to work. There are various ways to implement these workflows. With C++11, you can use condition variables or promise/future pairs; with C++20, you can use atomics...

Writing a custom iterator in modern C++ -- Internal Pointers

An experimental Forward Iterator written from scratch to boost up hand-made containers.

Writing a custom iterator in modern C++

by Internal Pointers

From the article:

Iterators are one of the building blocks of the Standard Library containers, but they are also useful when you want to provide the ability to iterate over elements of a custom container that you wrote yourself. Adding iterators to your containers will make them compatible with the range-based for loops and the C++ Algorithms library: a collection of functions for searching, sorting, counting and manipulating containers, based on iterators.

 

std::any - comparison with void* and motivating examples -- Hitesh Kumar

An introduction to std::any and comparison with void*.

std::any - comparison with void* and motivating examples

by Hitesh Kumar

From the article:

std::any is often compared with void* because the latter has been the de-facto choice for storing or passing the arbitrary objects in C++ since the outset. std::any is not a replacement of void*, but it is a safer substitute for the boilerplate patterns built around void*. Nevertheless, a comparison between the two is required for a better understanding of std::any.

Feature Testing with C++20--Rainer Grimm

Use all that you can.

Feature Testing with C++20

by Rainer Grimm

From the article:

When your program's compilation broke with a brand-new C++20 feature, you often end with a few questions: Did I something wrong? Did I found a compiler bug? Does my compiler not yet support this feature? Thanks to the feature testing in C++20, the last question is easy to answer...

Under the Covers of C++ Lambdas: Captures, Captures, Captures--Andreas Fertig

Lambdas.

Under the Covers of C++ Lambdas: Captures, Captures, Captures

by Andreas Fertig

From the article:

Lambda Capturing syntax allows us to quickly “wrap” a variable from the outside scope and then use it in the lambda body. We also know that under the hood the compiler translates lambda into a closure type… but what happens to those captured variables? Are they translated to public data members or private? See the newest guest post from Andreas to understand this tricky problem...