Submodules and Module Partitions
Explore the use of submodules and module partitions in C++20 to divide large modules into manageable parts. Understand how submodules and partitions help structure code, enable fine-grained imports, and improve compilation efficiency while maintaining consistent client usage.
We'll cover the following...
When your module becomes bigger, you want to divide its functionality into manageable components. C++20 modules offer two approaches: submodules and partitions.
Submodules
A module can import modules and then re-export them.
In the following example, module math imports the submodules math.math1 and math.math2.
The expression export import math.math1 imports module math.math1 and re-exports it as part of the module math.
For completeness, here are the modules math.math1 and math.math2. I used a period to separate the module math from its submodules. This period is not necessary.
If you look carefully, you recognize a small difference in the export statements in the modules math. While ...