[module.private.frag] (original) (raw)

10 Modules [module]

10.5 Private module fragment [module.private.frag]

A private-module-fragment shall appear only in a primary module interface unit ([module.unit]).

A module unit with a private-module-fragmentshall be the only module unit of its module; no diagnostic is required.

[Note 1:

A private-module-fragment ends the portion of the module interface unit that can affect the behavior of other translation units.

A private-module-fragment allows a module to be represented as a single translation unit without making all of the contents of the module reachable to importers.

The presence of a private-module-fragment affects:

— _end note_]

[Example 1: export module A;export inline void fn_e(); inline void fn_m(); static void fn_s();export struct X;export void g(X *x) { fn_s(); } export X *factory(); module :private;struct X {}; X *factory() { return new X ();} void fn_e() {} void fn_m() {} void fn_s() {} — _end example_]