A Practical Introduction to C++20's Modules
summary
Practical walk-through of C++20 modules using Visual Studio 16.8/16.9 shows how to write .ixx module interface units, separate implementation units, and import the standard library via header units (standard library guaranteed); demo compiles and runs, and fmt worked as a header unit in the demo. Highlights: macros become module-local, non-exported symbols get module linkage, and name collisions in the global namespace can make the program ill-formed, no diagnostic required; MSBuild support is good, GCC/Clang are partial and CMake lacks official support.
AI-written summary · about
chapters (15)
- 0:00VIRTUAL EVENT A Practical Introduction to C++20's Modules
- 3:41Modular Programming Modules separate a program into independent and interchangeable units • Modules hide the actual implementation and possibly data and • A module is not a package
- 29:48Module Names A number of identifiers joined by does
- 31:31Modules and Namespaces
- 34:34Module Partitions
- 36:44Private Module Fragment • Keep interface and implementation separate without having multiple files • modification of the private module fragment cannot trigger recompilation of importers of the module • Possibly faster incremental buids
- 40:23Global Module Everything must be attached to a module declared in a module
- 41:12What Can Be Exported? variables classes, structs, functions, namespaces, template function classes, concepts
- 43:47Implicit Exports
- 47:39include and modules including a header in the module purview is not a good idea
- 49:05Global Module Fragment . Only preprocessor directives allowed • Declarations not used in the named module are discarded and not • Use for headers which rely preprocessor state from the includer
- 50:21Header Units
- 52:11Advice for Headers Your own header. Try to convert it into a module including in the global module fragment
- 53:10Advantages encapsulation and information hiding
- 55:24Advice Visual Studio users: Use and leam modules with small hobby side projects all others: Wait for compiler and build system support
related talks
34mPractical C++20 Modules and the future of tooling around C++ Modules
58mKnockin' on Header's Door: An Overview of C++ Modules
36mC++ Modules: Year 2021
01h 10m“C++ Modules: The State of The Union"
01h 00mSo, you want to use C++ Modules ... cross-platform?
01h 01mPractical C++ Modules
32mVisibility, Reachability, Linkage – The Three Secret Spices of C++ Modules
01h 30mC++ Modules and Large-Scale Development
