A Pragmatic Journey into C++ Modules

A Pragmatic Journey into C++ Modules

Rudyard Merriam
Buy on Leanpub

Table of Contents

A Pragmatic Journey into C++ Modules

  • Preface
    • Why Modules?
    • Who This Book Is For
    • Use of AI
    • Conventions Used in This Book
    • Naming Examples by Cat Breed
  • Notes to Early Readers
  • Into the Future with Modules
    • Working With Larger Programs
    • Inclusion and Separate Compilation
    • Encapsulation
    • Comparing Modules and Headers
  • Module Basics
    • Module Units
    • Module Interface Unit
    • Module Implementation Unit
  • A Module Interface Unit (Abyssinian)
    • Module Interface Unit: Abyssinian.cppm
    • Module statement
    • Global Module Fragment (GMF)
    • Module Purview
    • User Code: main.cpp
  • A Module Implementation Unit (Aegean)
    • Module Interface Unit: Aegean.cppm
    • Module Implementation Unit: aegean.cpp
    • User Code: main.cpp
  • Building Aegean
    • Built Module Interface
    • Building with Command Lines
    • Building With GCC
    • GCC Command Lines
    • Building With Clang
    • Clang Command Lines
    • Command Line Summary
    • Building with CMake
    • Scanning for Modules
    • Parent Directory CMakelist.txt
    • Subdirectory CMakelist.txt
  • Module Deep Dive
    • Using a Module in Code
    • Module Segments and Fragements
    • Module Naming
    • module; Starts the Global Module Fragment
    • Declarations (export) module name(:partition);
    • Declarations (export) import (module.name)(:partition)
    • export… or How Can I Export Thee? Let Me Count the Ways
    • What Cannot Be Exported?
    • Exportable Entities in C++ Modules
    • Declaration module :private
    • Module Linkage
    • Pre-Module Linkage
    • C++20 Module Linkage
  • Comparison of Header and Module Builds (WIP)
  • Partitions and Submodules (WIP)
    • Comparison of Partitions and Submodules
  • A Module Implementation Partition (Chartreux)
    • Implementation Partition: Chartreux-Detail.cppm
    • Module Interface Unit: Chartreux.cppm
    • Module Implementation Unit: chartreux.cpp
    • User Code: main.cpp
    • Building With CMake
    • Interface Partitions vs. Implementation Partitions
  • User and System Header Units (Donskoy)
    • Module Interface Unit: Donskoy.cppm
    • Module Implementation Unit: donskoy.cpp
    • User Code: main.cpp
    • Building With Command Lines
    • With GCC
    • With Clang
    • Building With CMake
    • The Problem
    • The Workaround
  • A Partitioned Module (Javanese) (WIP)
    • Module Interface Unit: Javanese
    • Module Implementation Unit: Javanese
    • Partition Module Interface Unit: Balinese
    • Partition Module Implementation Unit: Balinese
    • User Code: main
    • Building Javanese Partition Module
    • Building Javanese with GCC
    • Building Javanese with Clang
    • Building with CMake
  • Module Linkage (Korat)
    • Module Korat
    • Module KoratEcho
    • User Code: main.cpp
    • Why This Works
    • Building With CMake
  • Importing the Standard Library
    • Enabling import std; in CMake
    • Project-Wide: CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
    • Per-Target: CXX_MODULE_STD
    • The Dialect Tag That Follows You Everywhere
    • Building With Raw Compiler Commands
    • With GCC
    • With Clang
  • POSIX Is Not import std (Manx)
  • Macros and the Module Boundary (Norwegian Forest)
    • Module NorwegianForest
    • User Code: main.cpp
  • Macros Are Not Exported by import std (Russian Blue)
  • A Compile-Flag Dialect Tag That Propagates (Scottish Fold)
    • The Module
    • What Goes Wrong
    • The Fix, and Why It Has to Be Applied Twice
    • Building With Raw Compiler Commands
  • No Global Namespace Leakage (Siamese)
  • The Plain Case (Siberian)
  • Private Module Fragment (Sphynx)
    • A First Attempt (and Why It Fails)
    • What Actually Works
    • User Code: main.cpp
    • Building With CMake
  • Re-exporting Modules (Turkish Van)
    • Module TurkishAngora
    • Module TurkishVan
    • User Code: main.cpp
    • Building With CMake
  • Resources
  • About the Author
A Pragmatic Journey into C++ Modules/overview

A Pragmatic Journey into C++ Modules

course_overview

Modules in C++20 are a change that impacts every C++ developer. At a minimum, the third-party libraries you need will use them. Larger development teams will need them to increase productivity. This book pragmatically explains their use with examples built with the command line and CMake.

count_chapters
begin_reading
download
p_implied_book_part_name

A Pragmatic Journey into C++ Modules25 chapters

Begin ›
  1. Preface

  2. Notes to Early Readers

  3. Into the Future with Modules

  4. Module Basics

  5. A Module Interface Unit (Abyssinian)

  6. A Module Implementation Unit (Aegean)

  7. Building Aegean

  8. Module Deep Dive

  9. Comparison of Header and Module Builds (WIP)

  10. Partitions and Submodules (WIP)

  11. A Module Implementation Partition (Chartreux)

  12. User and System Header Units (Donskoy)

  13. A Partitioned Module (Javanese) (WIP)

  14. Module Linkage (Korat)

  15. Importing the Standard Library

  16. POSIX Is Not import std (Manx)

  17. Macros and the Module Boundary (Norwegian Forest)

  18. Macros Are Not Exported by import std (Russian Blue)

  19. A Compile-Flag Dialect Tag That Propagates (Scottish Fold)

  20. No Global Namespace Leakage (Siamese)

  21. The Plain Case (Siberian)

  22. Private Module Fragment (Sphynx)

  23. Re-exporting Modules (Turkish Van)

  24. Resources

  25. About the Author