Articles & Books

My tutorial and take on C++20 coroutines--David Mazières

Detailed and interesting.

My tutorial and take on C++20 coroutines

by David Mazières

From the article:

Over the last 25 years, I’ve written a lot of event-driven code in C++. A typical example of event-driven code is registering a callback that gets invoked every time a socket has data to be read. Once you have read an entire message, possibly after many invocations, you parse the message and invoke another callback from a higher layer of abstraction, and so forth. This kind of code is painful to write because you have to break your code up into a bunch of different functions that, because they are different functions, don’t share local variables...

GotW #100 Solution: Preconditions, part 1 -- Herb Sutter

Solution just posted:

GotW #100 Solution: Preconditions, Part 1

by Herb Sutter

From the article:

We've seen how postconditions are directly related to assertions (see GotWs #97 and #99). So are preconditions, but that in one important way makes them fundamentally different. What is that? And why would having language support benefit us even more for writing preconditions more than for the other two?

A Recap on string_view--Jonathan Boccara

Back to the basics.

A Recap on string_view

by Jonathan Boccara

From the article:

The string capabilities of C++ have little evolved since C++98, until C++17 brought a major evolution: std::string_view.

Let’s look at what string_view is about and what it can bring to your code, by making it more expressive and making it run faster...

unique_ptr, shared_ptr, weak_ptr, or reference_wrapper for class relationships -- Hitesh Kumar

Expressing class relationships with unique_ptr, shared_ptr, weak_ptr, and reference_wrapper.

unique_ptr, shared_ptr, weak_ptr, or reference_wrapper for class relationships

by Hitesh Kumar

From the article:

Classes communicate with each other by having handles as members that refer to other classes. The choice of those referring-handles (e.g., pointers or references) is mostly driven by ownership or control-over-lifetime semantics.

Modern C++: Safety and Expressiveness with override and final

Back to basics.

Modern C++: Safety and Expressiveness with override and final

by Bartlomiej Filipek

From the article:

While C++11 is with us for a decade now, it’s good to go back and recall some of its best features. Today I’d like to consider override and final keywords which add a crucial safety when you build class hierarchies with lots of virtual member functions.

See how to prevent common bugs, and how to leverage tools to make your code safer...

An Improved Thread with C++20--Rainer Grimm

More about c++20.

An Improved Thread with C++20

by Rainer Grimm

From the article:

std::jthread stands for joining thread. In addition to std::thread (C++11), std::jthread automatically joins in its destructor and can cooperatively be interrupted. Read in this post to know why std::jthread should be your first choice...

Colony – A brief history of timing--Matt Bentley

A different container.

Colony – A brief history of timing

by Matt Bentley

From the article:

Back in 2014 I began designing a game engine. Experienced programmers and curmudgeonly lecturers will tell you that if you make a game engine, you’ll never make a game – which is true, but sort of irrelevant. You will learn so much from making a game engine, you probably won’t care about the game by the end of it. The main reason I wanted to develop a game engine was that I was tired of seeing very basic 2D games with incredibly bad performance even on fast computers. If we got 15 frames-per-second on Intel 386 processors in the 1990s, why was it so hard for modern 2D games to achieve the same speed on exponentially-better hardware?

Overload 161 is now available

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

Overload 161 is now available

From the journal:

In. Sub. Ordinate.
By Frances Buontempo
Mindless rebellion is mindless. Frances Buontempo encourages mindful consideration of when to refuse.

A Case Against Blind Use of C++ Parallel Algorithms
By Lucian Radu Teodorescu
C++17 introduced parallel algorithms. Lucian Radu Teodorescu reminds us we need to think when we use them.

C++ – an Invisible Foundation of Everything
By Bjarne Stroustrup
What is C++ and why do people still use it? Bjarne Stroustrup provides a short note answering these questions.

Test Precisely and Concretely
By Kevlin Henney
Tests can hit complete coverage but fail to communicate. Kevlin Henney reminds us that assertions should be necessary, sufficient, and comprehensible.

Afterwood
By Chris Oldwood
Think you’ve learnt it all? Chris Oldwood reminds us that unlearning then becomes our next problem.