Description
We have now switched to C++20; we should investigate modules to see if we can improve compilation times, and to get rid of the internal_file_name
namespaces designed to hide convenience using
s.
Overall, our current meow.hpp
+ meow_body.hpp
(+ meow.cpp
in some cases) should correspond to a module meow
.
One could have hoped that the _body
could be relegated to a module partition. Unfortunately, a look at N4868 shows that we cannot put those definitions that we had to put in headers in separate files; see below.
This means we will still have to resort to textual inclusion for the _body.hpp.
Prerequisites, which we should deal with prior to starting the great cosmic modularization:
- Since the
.ixx
files must be compiled, in order to stop the spread of the « cbrt.cpp in every project » mess, we will have to put them into shared items projects referenced by whatever needs them. Use shared items projects #3323. - For clarity (and also to avoid some of the « no diagnostic required » ill formedness cited below), everything exported by module
principia.cats.meow
should be in namespaceprincipia::cats::meow
. This entails restructuring our current namespace structure. Renamespacing #3321. - We should get rid of special include orders and forward-declarations to the extent possible. Where that is impossible, such tangles must exceptionally constitute a single module unit (via textual inclusion as needed). Get rid of special include orders and forward declarations #3322.
On the unusability of module partitions
6.3 [basic.def.odr]
- A definition domain is a private-module-fragment or the portion of a translation unit excluding its private-module-fragment (if any). A definition of an inline function or variable shall be reachable from the end of every definition domain in which it is odr-used outside of a discarded statement.
6.6 [basic.link]
- A program consists of one or more translation units (5.1) linked together. A translation unit consists of a sequence of declarations.
translation-unit: declaration-seqopt global-module-fragmentopt module-declaration declaration-seqopt private-module-fragmentopt9.2.8 [dcl.inline]
- […] If a function or variable with external or module linkage is declared inline in one definition domain, an inline declaration of it shall be reachable from the end of every definition domain in which it is declared; no diagnostic is required.
- If an inline function or variable that is attached to a named module is declared in a definition domain, it shall be defined in that domain.
[Note 4 : A constexpr function (9.2.6) is implicitly inline […]. — end note]
13.1 [temp.pre]
- A definition of a function template, member function of a class template, variable template, or static data member of a class template shall be reachable from the end of every definition domain (6.3) in which it is implicitly instantiated (13.9.2) unless the corresponding specialization is explicitly instantiated (13.9.3) in some translation unit; no diagnostic is required.