September 2020

The last vestiges of object oriented programming -- Geoffrey Viola

A history, some negative examples, and some positive examples of using object oriented programming in C++.

The Last Vestiges of Object Orientated Programming

by Geoffrey Viola

From the article:

Object oriented programming is not as popular as it was. As with any programming language feature it can be abused. Multiple inheritance, long inheritance chains, and needless inheritance can add unnecessary complexity. There are few cases where it works well in C++: building product types, enforcing an invariant, and dynamic polymorphism. Generally, classes should follow one of these deliberately to follow the single responsibility principle, but there are exceptions.

Introduction to modern CMake for beginners

A look at one of the most popular build systems for C and C++.

Introduction to modern CMake for beginners

Internal Pointers

From the article:

CMake is a collection of open-source and cross-platform tools used to build and distribute software. In recent years it has become a de-facto standard for C and C++ applications, so the time has come for a lightweight introductory article on the subject.

Quick Q: Is std::unique_ptr required to know the full definition of T?

Quick A: For certain members only.

Recently on SO:

Is std::unique_ptr<T> required to know the full definition of T?

Most templates in the C++ standard library require that they be instantiated with complete types. However shared_ptr and unique_ptr are partial exceptions. Some, but not all of their members can be instantiated with incomplete types. The motivation for this is to support idioms such as pimpl using smart pointers, and without risking undefined behavior...

What std::exchange does, and how to remember it--Jonathan Boccara

If you had troubles.

What std::exchange does, and how to remember it

by Jonathan Boccara

From the article:

std::exchange was introduced in the C++ standard library in C++14 under the header <utility>.

Its name suggests that it’s a general-purpose and useful function, and its template prototype working with any type confirms this impression.

I don’t know about you, but I always had a problem with std::exchange: I couldn’t remember what it was doing. I learnt several times the operations that std::exchange performs, but each time I forgot them soon after.

Then at some point it clicked: std::exchange is a setter returning the old value. Ignoring the name “exchange” but thinking of it as a “setter” helped me make it stick to my mind.

It might just be me having a hard time with std::exchange for some reason. But just in case you also have issues remembering the operations of std::exchange, let’s see why std::exchange has this meaning, and why this meaning is not obvious from its name.

This should help you remember it once and for all...

C++ Coroutines in Visual Studio 2019 Version 16.8--Jonathan Emmett

c++20 is coming.

C++ Coroutines in Visual Studio 2019 Version 16.8

by Jonathan Emmett

From the article:

It’s been a long journey for coroutines in C++ and in MSVC. We announced an early preview of resumable functions in 2013, followed up by the /await switch and initial C++ standardization proposals in 2014, to proposal revisions in 2015, and have continued tracking the Coroutines TS (Technical Specification) progress through Visual Studio 2017 and 2019. With the adoption of coroutines into the C++ standard in 2019, we are now pleased to announce feature completion of C++20 coroutines in Visual Studio 2019 version 16.8...

Standard C++20 Modules support with MSVC in Visual Studio 2019 version 16.8--Cameron DaCamara

Tools are getting to 20.

Standard C++20 Modules support with MSVC in Visual Studio 2019 version 16.8

by Cameron DaCamara

From the article:

It has been some time since our last update regarding C++ Modules conformance. The toolset, project system, and IDE teams have been hard at work to create a first class C++ Modules experience in Visual Studio 2019. There is a lot to share, so let’s get right into it...

Concept archetypes — update--Andrzej Krzemieński

Not so easy, but still useful.

Concept archetypes — update

by Andrzej Krzemieński

From the article:

An observant reader indicated that in the previous post where I was trying to implement a concept archetype — a type with minimal interface that models a given concept — I actually failed. This deserves a closer examination...