r/cpp_modules • u/tartaruga232 • Apr 05 '26
The current internal partition units are unneeded
Gaby just confirmed that an internal partition unit (form "A") like
module M:P;
struct MyType { ... };
as specified by the current C++ standard, is semantically 100% equivalent to (form "B")
export module M:P;
struct MyType { ... };
// more stuff not exported
The current wording in the C++ standard, which qualifies form "B" as "ill-formed, no diagnostic required", if :P is not imported in the primary module interface unit, makes no sense (Quote: "A required no-op helps nobody").
Which means: Form "B" is perfectly valid.
If form "B" is equivalent to form "A", it would be possible to exclusively use form "B", instead of form "A".
This means, the standard could remove form "A" and exclusively use form "B" instead.
Compilers could then apply the simple rule, that a BMI must only be produced for TU's having "export module".
View all comments
Show parent comment
1
u/tartaruga232 Apr 06 '26 edited Apr 06 '26
Both structs A and B are not exported. There is no difference.
The only difference is, that nothing can be exported from
whereas something could potentially be exported from
But actually, nothing is exported from
:P1.Imposing to import
:P1in the PMIU of M is futile, because that is a no-op.:P1can have module-private and public parts.:P2can only have private parts.The private parts from
:P1and the (private) parts from:P2have the same quality.