C++20 Coroutines As An API Principle

Speaker: Marc Mutz

Audience level: Beginner | Intermediate | Advanced

Since the addition of view types to the C++ language (string_view in C++17 and span in C++20), APIs that follow the NOI (Non-Owning Interface) Idiom are a breeze to write, and fun to work with.

That is, as long as your storage within and without the class is contiguous, and there is backing storage. The latter is a problem if the result is calculated on the fly instead of being stored in some location. If either of these two isn't given, things get "interesting", meaning the use of NOI in these situations is not applicable outside very special circumstances.

In this talk, we'll answer the question whether C++20 coroutines can fix these two Achilles' Heels of the NOI idiom.

In order to do so, we will take a deep dive into coroutines behind ABI boundaries, virtual coroutines and how codegen is affected by an out-of-line coroutine.

Tying everything together, we will derive guidelines for use of C++20 coroutines for implementing non-contiguous and non-storage-backed NOI with a focus on ABI boundaries.

The presentation will use APIs from the Qt library as examples, but prior knowledge of Qt is not required.