[module.private.frag]

# 10 Modules [[module]](./#module)

## 10.5 Private module fragment [module.private.frag]

[private-module-fragment:](#nt:private-module-fragment "10.5 Private module fragment [module.private.frag]")  
module-keyword : private ; [*declaration-seq*](dcl.pre#nt:declaration-seq "9.1 Preamble [dcl.pre]")opt

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/modules.tex#L814)

A [*private-module-fragment*](#nt:private-module-fragment "10.5 Private module fragment [module.private.frag]") shall appear only
in a primary module interface unit ([[module.unit]](module.unit "10.1 Module units and purviews"))[.](#1.sentence-1)

A module unit with a [*private-module-fragment*](#nt:private-module-fragment "10.5 Private module fragment [module.private.frag]") shall be the only module unit of its module;
no diagnostic is required[.](#1.sentence-2)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/modules.tex#L821)

[*Note [1](#note-1)*:

A [*private-module-fragment*](#nt:private-module-fragment "10.5 Private module fragment [module.private.frag]") ends
the portion of the module interface unit
that can affect the behavior of other translation units[.](#2.sentence-1)

A [*private-module-fragment*](#nt:private-module-fragment "10.5 Private module fragment [module.private.frag]") allows a module
to be represented as a single translation unit
without making all of the contents of the module reachable to importers[.](#2.sentence-2)

The presence of a [*private-module-fragment*](#nt:private-module-fragment "10.5 Private module fragment [module.private.frag]") affects:

- [(2.1)](#2.1)

the point by which the definition of
an inline function or variable
is required ([[dcl.inline]](dcl.inline "9.2.8 The inline specifier")),

- [(2.2)](#2.2)

the point by which the definition of
an exported function with a placeholder return type
is required ([[dcl.spec.auto]](dcl.spec.auto "9.2.9.7 Placeholder type specifiers")),

- [(2.3)](#2.3)

whether a declaration is required not to be an exposure ([[basic.link]](basic.link "6.7 Program and linkage")),

- [(2.4)](#2.4)

where definitions for inline functions and templates
must appear ([[basic.def.odr]](basic.def.odr "6.3 One-definition rule"), [[dcl.inline]](dcl.inline "9.2.8 The inline specifier"), [[temp.pre]](temp.pre "13.1 Preamble")),

- [(2.5)](#2.5)

the instantiation contexts of templates
instantiated before it ([[module.context]](module.context "10.6 Instantiation context")), and

- [(2.6)](#2.6)

the reachability of declarations within it ([[module.reach]](module.reach "10.7 Reachability"))[.](#2.sentence-3)

â *end note*]

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/modules.tex#L857)

[*Example [1](#example-1)*: export module A;export inline void fn_e(); // error: exported inline function fn_e not defined// before private module fragmentinline void fn_m(); // error: non-exported inline function fn_m not definedstatic void fn_s();export struct X;export void g(X *x) { fn_s(); // OK, call to static function in same translation unit}export X *factory(); // OKmodule :private;struct X {}; // definition not reachable from importers of A X *factory() {return new X ();}void fn_e() {}void fn_m() {}void fn_s() {} â *end example*]
