Modules (C++20)
Modules replace the textual #include model: export module math; declares a module whose exported names import cleanly (import math;) without re-parsing headers, leaking macros, or depending on include order. Builds get dramatically faster on large codebases, and macro leakage across boundaries finally ends.
Adoption is still ramping — GCC 14+, Clang 16+, and MSVC support modules with growing CMake integration, but many libraries remain header-only in practice. New greenfield code on recent toolchains can start modular; existing projects migrate gradually, mixing #include and import during transition.
Export once, import fast
export module math; plus export-marked declarations form the interface — importers get compiled metadata, not re-parsed text.
No order dependence
Import order doesn't matter and macros don't leak across module boundaries — two historic header pains, gone.
Partitions organize
module math:core splits big modules into separately-authored partitions under one importable name.
Check toolchain maturity
Compiler plus build-system support is still uneven — verify your exact versions before committing a codebase.
// math.cppmexport module math;export int triple(int x) { return x * 3; }// ---- app.cpp ----// import math;// int main() { return triple(7); } // 21Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Practice what you learned
Re-implement each visualized algorithm in C++ yourself — building beats watching.