A Practical Introduction to C++'s Modules

By Hendrik Niemeyer

Modularity is a long known principle for creating maintainable, changeable and durable software. In contrast to other programming languages, C++ did not have its own module system and used header files to structure code. But this has changed with C++20 which introduced modules as one of its bigger new features.

In this talk I will discuss the theoretical side of modules and their advantages over header files (e.g. faster compile times, invisibility of macros, preprocessor directives and non-exported entities, fewer name collisions and more) but the main focus will be the practical usage of modules today.

I will demonstrate how modules can be used today with the three major compilers and how to restructure your projects using modules. Also the support of build systems for modules will be discussed.