Chapter 10. Modules and Concepts
One of the most anticipated additions to C++20, modules, received a lot of fanfare at C++ conferences and in the blogosphere leading up to the release of the updated Standard. Modules offer potentially significant advantages over the currently employed header files with #include
preprocessor statements, as will be discussed in this chapter.
Some of us had hoped that before the time this book went to press, modules would have become a common fixture in newer development projects. Unfortunately, this has not been the case, although considering that this is a major change in the C++ language, it is somewhat understandable for updated compiler implementations, as well as adoption by developers, to take time. Visual Studio provided working support for modules by around mid-2021, but implementation delays in Clang and gcc continued into 2023.
Still, as mentioned in a CppCon 2021 talk presented by Gabriel Dos Reis and Cameron DaCamara, “C++ modules were designed to bring more safety to your programs, while dramatically reducing compile time, resulting in overall increased productivity.”1 Therefore, it is probably a good idea to start becoming familiar with how modules work.
Concepts were another eagerly awaited feature in C++20. They give programmers more control over template programming. Invalid function inputs can now be more readily pinpointed at compile time, rather than being buried within the avalanche of superfluous error messages associated with ...
Get Learning Modern C++ for Finance now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.