Articles & Books

Conditionally Trivial Special Member Functions--Sy Brand

c++ magic.

Conditionally Trivial Special Member Functions

by Sy Brand

From the article:

The C++ standards committee is currently focusing on adding features to the language which can simplify code. One small example of this in C++20 is conditionally trivial special member functions, which we added support for in Visual Studio 2019 version 16.8. Its benefit isn’t immediately obvious unless you’ve been deep down the rabbit hole of high-performance library authoring, so I’ve written this post to show you how it can make certain generic types more efficient without requiring huge amounts of template magic...

How to Share Code with Const and Non-Const Functions in C++--Bartlomiej Filipek

How do you do it?

How to Share Code with Const and Non-Const Functions in C++

by Bartlomiej Filipek

From the article:

During the development of a container-like type, I run into the problem of how to share code between a const and non-const member functions. In this article, I’d like to explain what are the issues and possible solutions. We can even go on a bleeding edge and apply some C++20 features. Which technique is most friendly?

Overload 159 is now available

ACCU’s Overload journal of October 2020 is out. It contains the following C++ related articles.

Overload 159 is now available

From the journal:

Virtual/Reality
By Frances Buontempo
Do we know what reality is? Frances Buontempo is no longer sure and now wonders if she’s a fictional character.

poly::vector – A Vector for Polymorphic Objects
By Ferenc Nándor Janky
Heterogeneous vectors can be slow. Janky Ferenc introduces a sequential container for storing polymorphic objects in C++.

Kafka Acks Explained
By Slanislav Kozlovski
Kafka’s configuration can be confusing. Slanislav Kozlovski helps us visualise this most misunderstood configuration setting.

Concurrency Design Patterns
By Lucian Tadu Teodorescu
Orchestrating concurrent tasks using mutexes is seldom efficient. Lucian Tadu Teodorescu investigates design patterns that help unlock concurrent performance.

C++ Modules: A Brief Tour
By Nathan Sidwell
C++20’s long awaited module system has arrived. Nathan Sidwell presents a tourist’s guide.

The Edge of C++
By Ferenc Deák
Everything has limits. Deák Ferenc explores the bounds of various C++ constructs.

Afterwood
By Chris Oldwood
Assume failure by default. Chris Oldwood considers various fail cases.

Quick Q: Why do I have to access template base class members through the this pointer?

Quick: in order to make x a dependent name, so that lookup is deferred until the template parameter is known

Recently on SO:

Why do I have to access template base class members through the this pointer?

If the classes below were not templates I could simply have x in the derived class. However, with the code below, I have to use this->x. Why?

template <typename T>
class base {

protected:
    int x;
};

template <typename T>
class derived : public base<T> {

public:
    int f() { return this->x; }
};

int main() {
    derived<int> d;
    d.f();
    return 0;
}

Programming with C++20's Concepts [In Spanish] -- Daniel G Vergel

C++20 concepts dgvergel.blogspot.com

This post revisits the well-known Insertion Sort algorithm as a way to learn and practice several new C++20 features such as concepts, ranges, and projections.

Programming with C++20's Concepts

by Daniel G Vergel

About the article

The article, written in Spanish, follows very closely the way I introduce these topics to my Computer Engineering students at the European University (Madrid, Spain). As previous posts, it tries to mitigate the lack of educational materials on modern C++ currently available in my native language. Code examples are nevertheless self-explanatory and may be of interest to non-Spanish readers as well.