From Jason Turner

[module]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpoy2jv00_/{from.md → to.md} +91 -32
tmp/tmpoy2jv00_/{from.md → to.md} RENAMED
@@ -122,11 +122,13 @@ is *attached* to a module as follows:
122
  or *template-id* or that nominates a class other than with an
123
  *elaborated-type-specifier* with neither a *nested-name-specifier* nor
124
  a *simple-template-id*, it is attached to the module to which the
125
  friend is attached [[basic.link]].
126
  - Otherwise, if the declaration
127
- - is a *namespace-definition* with external linkage or
 
 
128
  - appears within a *linkage-specification* [[dcl.link]]
129
 
130
  it is attached to the global module.
131
  - Otherwise, the declaration is attached to the module in whose purview
132
  it appears.
@@ -235,13 +237,13 @@ export using namespace N; // OK
235
  ```
236
 
237
  — *end example*]
238
 
239
  If an exported declaration is a *using-declaration* [[namespace.udecl]]
240
- and is not within a header unit, all entities to which all of the
241
- *using-declarator*s ultimately refer (if any) shall have been introduced
242
- with a name having external linkage.
243
 
244
  [*Example 2*:
245
 
246
  Source file \`"b.h"\`
247
 
@@ -282,12 +284,12 @@ export using N::h; // error: #1 has internal linkage
282
 
283
  — *end example*]
284
 
285
  [*Note 2*:
286
 
287
- These constraints do not apply to type names introduced by `typedef`
288
- declarations and *alias-declaration*s.
289
 
290
  [*Example 3*:
291
 
292
  ``` cpp
293
  export module M;
@@ -299,20 +301,26 @@ export using T = S; // OK, exports name T denoting type S
299
 
300
  — *end note*]
301
 
302
  A redeclaration of an entity X is implicitly exported if X was
303
  introduced by an exported declaration; otherwise it shall not be
304
- exported.
305
 
306
  [*Example 4*:
307
 
308
  ``` cpp
309
  export module M;
310
  struct S { int n; };
311
  typedef S S;
312
- export typedef S S; // OK, does not redeclare an entity
313
  export struct S; // error: exported declaration follows non-exported declaration
 
 
 
 
 
 
314
  ```
315
 
316
  — *end example*]
317
 
318
  [*Note 3*: Names introduced by exported declarations have either
@@ -431,13 +439,14 @@ A *module-import-declaration* that specifies a *header-name* `H` imports
431
  a synthesized *header unit*, which is a translation unit formed by
432
  applying phases 1 to 7 of translation [[lex.phases]] to the source file
433
  or header nominated by `H`, which shall not contain a
434
  *module-declaration*.
435
 
436
- [*Note 2*: All declarations within a header unit are implicitly
437
- exported [[module.interface]], and are attached to the global module
438
- [[module.unit]]. *end note*]
 
439
 
440
  An *importable header* is a member of an *implementation-defined* set of
441
  headers that includes all importable C++ library headers [[headers]].
442
  `H` shall identify an importable header. Given two such
443
  *module-import-declaration*s:
@@ -561,11 +570,11 @@ A *global-module-fragment* specifies the contents of the *global module
561
  fragment* for a module unit. The global module fragment can be used to
562
  provide declarations that are attached to the global module and usable
563
  within the module unit.
564
 
565
  A declaration D is *decl-reachable* from a declaration S in the same
566
- translation unit if:
567
 
568
  - D does not declare a function or function template and S contains an
569
  *id-expression*, *namespace-name*, *type-name*, *template-name*, or
570
  *concept-name* naming D, or
571
  - D declares a function or function template that is named by an
@@ -583,23 +592,24 @@ translation unit if:
583
  [[over.over]] that contains D and for which the target type is
584
  dependent, or
585
  - there exists a declaration M that is not a *namespace-definition* for
586
  which M is decl-reachable from S and either
587
  - D is decl-reachable from M, or
588
- - D redeclares the entity declared by M or M redeclares the entity
589
- declared by D, and D neither is a friend declaration nor inhabits a
590
- block scope, or
591
  - D declares a namespace N and M is a member of N, or
592
- - one of M and D declares a class or class template C and the other
593
  declares a member or friend of C, or
594
  - one of D and M declares an enumeration E and the other declares an
595
  enumerator of E, or
596
  - D declares a function or variable and M is declared in D,[^2] or
597
- - one of M and D declares a template and the other declares a partial
598
  or explicit specialization or an implicit or explicit instantiation
599
  of that template, or
600
- - one of M and D declares a class or enumeration type and the other
 
 
601
  introduces a typedef name for linkage purposes for that type.
602
 
603
  In this determination, it is unspecified
604
 
605
  - whether a reference to an *alias-declaration*, `typedef` declaration,
@@ -607,13 +617,18 @@ In this determination, it is unspecified
607
  the declarations they name prior to this determination,
608
  - whether a *simple-template-id* that does not denote a dependent type
609
  and whose *template-name* names an alias template is replaced by its
610
  denoted type prior to this determination,
611
  - whether a *decltype-specifier* that does not denote a dependent type
612
- is replaced by its denoted type prior to this determination, and
613
  - whether a non-value-dependent constant expression is replaced by the
614
- result of constant evaluation prior to this determination.
 
 
 
 
 
615
 
616
  A declaration `D` in a global module fragment of a module unit is
617
  *discarded* if `D` is not decl-reachable from any *declaration* in the
618
  *declaration-seq* of the *translation-unit*.
619
 
@@ -768,35 +783,49 @@ The *instantiation context* is a set of points within the program that
768
  determines which declarations are found by argument-dependent name
769
  lookup [[basic.lookup.argdep]] and which are reachable [[module.reach]]
770
  in the context of a particular declaration or template instantiation.
771
 
772
  During the implicit definition of a defaulted function
773
- [[special]], [[class.compare.default]], the instantiation context is the
774
- union of the instantiation context from the definition of the class and
775
- the instantiation context of the program construct that resulted in the
776
- implicit definition of the defaulted function.
 
777
 
778
  During the implicit instantiation of a template whose point of
779
  instantiation is specified as that of an enclosing specialization
780
- [[temp.point]], the instantiation context is the union of the
781
  instantiation context of the enclosing specialization and, if the
782
  template is defined in a module interface unit of a module M and the
783
  point of instantiation is not in a module interface unit of M, the point
784
  at the end of the *declaration-seq* of the primary module interface unit
785
  of M (prior to the *private-module-fragment*, if any).
786
 
787
  During the implicit instantiation of a template that is implicitly
788
  instantiated because it is referenced from within the implicit
789
- definition of a defaulted function, the instantiation context is the
790
- instantiation context of the defaulted function.
791
 
792
  During the instantiation of any other template specialization, the
793
- instantiation context comprises the point of instantiation of the
794
  template.
795
 
 
 
 
 
 
 
 
 
 
 
 
796
  In any other case, the instantiation context at a point within the
797
- program comprises that point.
 
 
798
 
799
  [*Example 1*:
800
 
801
  Translation unit #1
802
 
@@ -883,14 +912,40 @@ unspecified which are and under what circumstances.[^3]
883
  any additional translation units in programs intending to be
884
  portable. — *end note*]
885
 
886
  A declaration D is *reachable from* a point P if
887
 
 
888
  - D appears prior to P in the same translation unit, or
889
  - D is not discarded [[module.global.frag]], appears in a translation
890
  unit that is reachable from P, and does not appear within a
891
- *private-module-fragment*.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
892
 
893
  A declaration is *reachable* if it is reachable from any point in the
894
  instantiation context [[module.context]].
895
 
896
  [*Note 3*: Whether a declaration is exported has no bearing on whether
@@ -906,11 +961,11 @@ These reachable semantic properties include type completeness, type
906
  definitions, initializers, default arguments of functions or template
907
  declarations, attributes, names bound, etc. Since default arguments are
908
  evaluated in the context of the call expression, the reachable semantic
909
  properties of the corresponding parameter types apply in that context.
910
 
911
- [*Example 1*:
912
 
913
  Translation unit #1
914
 
915
  ``` cpp
916
  export module M:A;
@@ -957,11 +1012,11 @@ void g() { f(); } // error: no reachable definition of struct B
957
  — *end note*]
958
 
959
  [*Note 5*: Declarations of an entity can be reachable even where they
960
  cannot be found by name lookup. — *end note*]
961
 
962
- [*Example 2*:
963
 
964
  Translation unit #1
965
 
966
  ``` cpp
967
  export module A;
@@ -989,13 +1044,17 @@ X x; // error: X not visible to unqualified lookup
989
  [cpp.include]: cpp.md#cpp.include
990
  [cpp.pre]: cpp.md#cpp.pre
991
  [dcl.inline]: dcl.md#dcl.inline
992
  [dcl.link]: dcl.md#dcl.link
993
  [dcl.spec.auto]: dcl.md#dcl.spec.auto
 
994
  [headers]: library.md#headers
995
  [lex.name]: lex.md#lex.name
996
  [lex.phases]: lex.md#lex.phases
 
 
 
997
  [module]: #module
998
  [module.context]: #module.context
999
  [module.global.frag]: #module.global.frag
1000
  [module.import]: #module.import
1001
  [module.interface]: #module.interface
 
122
  or *template-id* or that nominates a class other than with an
123
  *elaborated-type-specifier* with neither a *nested-name-specifier* nor
124
  a *simple-template-id*, it is attached to the module to which the
125
  friend is attached [[basic.link]].
126
  - Otherwise, if the declaration
127
+ - declares a namespace whose name has external linkage,
128
+ - declares a type alias,
129
+ - declares a namespace alias, or
130
  - appears within a *linkage-specification* [[dcl.link]]
131
 
132
  it is attached to the global module.
133
  - Otherwise, the declaration is attached to the module in whose purview
134
  it appears.
 
237
  ```
238
 
239
  — *end example*]
240
 
241
  If an exported declaration is a *using-declaration* [[namespace.udecl]]
242
+ and is not within a header unit, all entities named by the
243
+ *using-declarator*s (if any) shall either be a type alias or have been
244
+ introduced with a name having external linkage.
245
 
246
  [*Example 2*:
247
 
248
  Source file \`"b.h"\`
249
 
 
284
 
285
  — *end example*]
286
 
287
  [*Note 2*:
288
 
289
+ The underlying entity of an exported type alias need not have a name
290
+ with external linkage.
291
 
292
  [*Example 3*:
293
 
294
  ``` cpp
295
  export module M;
 
301
 
302
  — *end note*]
303
 
304
  A redeclaration of an entity X is implicitly exported if X was
305
  introduced by an exported declaration; otherwise it shall not be
306
+ exported unless it is a type alias, a namespace, or a namespace alias.
307
 
308
  [*Example 4*:
309
 
310
  ``` cpp
311
  export module M;
312
  struct S { int n; };
313
  typedef S S;
314
+ export typedef S S; // OK
315
  export struct S; // error: exported declaration follows non-exported declaration
316
+ namespace N { // external linkage, attached to global module, not exported
317
+ void f();
318
+ }
319
+ namespace N { // OK, exported namespace redeclaring non-exported namespace
320
+ export void g();
321
+ }
322
  ```
323
 
324
  — *end example*]
325
 
326
  [*Note 3*: Names introduced by exported declarations have either
 
439
  a synthesized *header unit*, which is a translation unit formed by
440
  applying phases 1 to 7 of translation [[lex.phases]] to the source file
441
  or header nominated by `H`, which shall not contain a
442
  *module-declaration*.
443
 
444
+ [*Note 2*: A header unit is a separate translation unit with an
445
+ independent set of defined macros. All declarations within a header unit
446
+ are implicitly exported [[module.interface]], and are attached to the
447
+ global module [[module.unit]]. — *end note*]
448
 
449
  An *importable header* is a member of an *implementation-defined* set of
450
  headers that includes all importable C++ library headers [[headers]].
451
  `H` shall identify an importable header. Given two such
452
  *module-import-declaration*s:
 
570
  fragment* for a module unit. The global module fragment can be used to
571
  provide declarations that are attached to the global module and usable
572
  within the module unit.
573
 
574
  A declaration D is *decl-reachable* from a declaration S in the same
575
+ translation unit if
576
 
577
  - D does not declare a function or function template and S contains an
578
  *id-expression*, *namespace-name*, *type-name*, *template-name*, or
579
  *concept-name* naming D, or
580
  - D declares a function or function template that is named by an
 
592
  [[over.over]] that contains D and for which the target type is
593
  dependent, or
594
  - there exists a declaration M that is not a *namespace-definition* for
595
  which M is decl-reachable from S and either
596
  - D is decl-reachable from M, or
597
+ - D and M declare the same entity, and D neither is a friend
598
+ declaration nor inhabits a block scope, or
 
599
  - D declares a namespace N and M is a member of N, or
600
+ - one of D and M declares a class or class template C and the other
601
  declares a member or friend of C, or
602
  - one of D and M declares an enumeration E and the other declares an
603
  enumerator of E, or
604
  - D declares a function or variable and M is declared in D,[^2] or
605
+ - one of D and M declares a template and the other declares a partial
606
  or explicit specialization or an implicit or explicit instantiation
607
  of that template, or
608
+ - M declares a class template and D is a deduction guide for that
609
+ template, or
610
+ - one of D and M declares a class or enumeration type and the other
611
  introduces a typedef name for linkage purposes for that type.
612
 
613
  In this determination, it is unspecified
614
 
615
  - whether a reference to an *alias-declaration*, `typedef` declaration,
 
617
  the declarations they name prior to this determination,
618
  - whether a *simple-template-id* that does not denote a dependent type
619
  and whose *template-name* names an alias template is replaced by its
620
  denoted type prior to this determination,
621
  - whether a *decltype-specifier* that does not denote a dependent type
622
+ is replaced by its denoted type prior to this determination,
623
  - whether a non-value-dependent constant expression is replaced by the
624
+ result of constant evaluation prior to this determination, and
625
+ - whether a *splice-expression*, a *splice-type-specifier*, a
626
+ *splice-scope-specifier*, or any *splice-specifier* or
627
+ *splice-specialization-specifier* outside of the preceding is replaced
628
+ in any non-dependent context by the construct that it designates prior
629
+ to this determination.
630
 
631
  A declaration `D` in a global module fragment of a module unit is
632
  *discarded* if `D` is not decl-reachable from any *declaration* in the
633
  *declaration-seq* of the *translation-unit*.
634
 
 
783
  determines which declarations are found by argument-dependent name
784
  lookup [[basic.lookup.argdep]] and which are reachable [[module.reach]]
785
  in the context of a particular declaration or template instantiation.
786
 
787
  During the implicit definition of a defaulted function
788
+ [[special]], [[class.compare.default]], the instantiation context
789
+ contains each point in the instantiation context from the definition of
790
+ the class and each point in the instantiation context of the program
791
+ construct that resulted in the implicit definition of the defaulted
792
+ function.
793
 
794
  During the implicit instantiation of a template whose point of
795
  instantiation is specified as that of an enclosing specialization
796
+ [[temp.point]], the instantiation context contains each point in the
797
  instantiation context of the enclosing specialization and, if the
798
  template is defined in a module interface unit of a module M and the
799
  point of instantiation is not in a module interface unit of M, the point
800
  at the end of the *declaration-seq* of the primary module interface unit
801
  of M (prior to the *private-module-fragment*, if any).
802
 
803
  During the implicit instantiation of a template that is implicitly
804
  instantiated because it is referenced from within the implicit
805
+ definition of a defaulted function, the instantiation context contains
806
+ each point in the instantiation context of the defaulted function.
807
 
808
  During the instantiation of any other template specialization, the
809
+ instantiation context contains the point of instantiation of the
810
  template.
811
 
812
+ During the implicit instantiation of any construct that resulted from
813
+ the evaluation of an expression as a core constant expression, the
814
+ instantiation context contains each point in the evaluation context
815
+ [[expr.const]].
816
+
817
+ [*Note 1*: Implicit instantiations can result from invocations of
818
+ library functions [[meta.reflection]]. The evaluation context can
819
+ include synthesized points associated with injected declarations
820
+ produced by `std::meta::define_aggregate`
821
+ [[meta.reflection.define.aggregate]]. — *end note*]
822
+
823
  In any other case, the instantiation context at a point within the
824
+ program contains that point.
825
+
826
+ The instantiation context contains only the points specified above.
827
 
828
  [*Example 1*:
829
 
830
  Translation unit #1
831
 
 
912
  any additional translation units in programs intending to be
913
  portable. — *end note*]
914
 
915
  A declaration D is *reachable from* a point P if
916
 
917
+ - P is a non-synthesized point and
918
  - D appears prior to P in the same translation unit, or
919
  - D is not discarded [[module.global.frag]], appears in a translation
920
  unit that is reachable from P, and does not appear within a
921
+ *private-module-fragment*; or
922
+ - D is the injected declaration for which P is the corresponding
923
+ synthesized point.
924
+
925
+ [*Example 1*:
926
+
927
+ ``` cpp
928
+ class Incomplete;
929
+
930
+ consteval {
931
+ int n = nonstatic_data_members_of(
932
+ define_aggregate(^^Incomplete, {data_member_spec(^^int, {.name="x"})}),
933
+ std::meta::access_context::current()
934
+ ).size();
935
+
936
+ Incomplete y; // error: type of y is incomplete
937
+ }
938
+ /* P */
939
+ ```
940
+
941
+ The value of `n` is 1. The member `Incomplete::x` members-of-precedes
942
+ [[meta.reflection.member.queries]] the synthesized point P associated
943
+ with the injected declaration produced by the call to
944
+ `define_aggregate`.
945
+
946
+ — *end example*]
947
 
948
  A declaration is *reachable* if it is reachable from any point in the
949
  instantiation context [[module.context]].
950
 
951
  [*Note 3*: Whether a declaration is exported has no bearing on whether
 
961
  definitions, initializers, default arguments of functions or template
962
  declarations, attributes, names bound, etc. Since default arguments are
963
  evaluated in the context of the call expression, the reachable semantic
964
  properties of the corresponding parameter types apply in that context.
965
 
966
+ [*Example 2*:
967
 
968
  Translation unit #1
969
 
970
  ``` cpp
971
  export module M:A;
 
1012
  — *end note*]
1013
 
1014
  [*Note 5*: Declarations of an entity can be reachable even where they
1015
  cannot be found by name lookup. — *end note*]
1016
 
1017
+ [*Example 3*:
1018
 
1019
  Translation unit #1
1020
 
1021
  ``` cpp
1022
  export module A;
 
1044
  [cpp.include]: cpp.md#cpp.include
1045
  [cpp.pre]: cpp.md#cpp.pre
1046
  [dcl.inline]: dcl.md#dcl.inline
1047
  [dcl.link]: dcl.md#dcl.link
1048
  [dcl.spec.auto]: dcl.md#dcl.spec.auto
1049
+ [expr.const]: expr.md#expr.const
1050
  [headers]: library.md#headers
1051
  [lex.name]: lex.md#lex.name
1052
  [lex.phases]: lex.md#lex.phases
1053
+ [meta.reflection]: meta.md#meta.reflection
1054
+ [meta.reflection.define.aggregate]: meta.md#meta.reflection.define.aggregate
1055
+ [meta.reflection.member.queries]: meta.md#meta.reflection.member.queries
1056
  [module]: #module
1057
  [module.context]: #module.context
1058
  [module.global.frag]: #module.global.frag
1059
  [module.import]: #module.import
1060
  [module.interface]: #module.interface