@@ -4,23 +4,19 @@ $(SPEC_S Structs and Unions,
4
4
5
5
$(HEADERNAV_TOC)
6
6
7
+ $(H2 $(LNAME2 intro, Introduction))
8
+
7
9
$(P Whereas classes are reference types, structs are value types.
8
10
Structs and unions are simple aggregations of data and their
9
11
associated operations on that data.
10
12
)
11
13
12
14
$(GRAMMAR
13
- $(GNAME AggregateDeclaration):
14
- $(GLINK2 class, ClassDeclaration)
15
- $(GLINK2 interface, InterfaceDeclaration)
16
- $(GLINK StructDeclaration)
17
- $(GLINK UnionDeclaration)
18
-
19
15
$(GNAME StructDeclaration):
20
16
$(D struct) $(GLINK_LEX Identifier) $(D ;)
21
17
$(D struct) $(GLINK_LEX Identifier) $(GLINK AggregateBody)
22
18
$(GLINK2 template, StructTemplateDeclaration)
23
- $(GLINK AnonStructDeclaration)
19
+ $(I AnonStructDeclaration)
24
20
25
21
$(GNAME AnonStructDeclaration):
26
22
$(D struct) $(GLINK AggregateBody)
@@ -29,7 +25,7 @@ $(GNAME UnionDeclaration):
29
25
$(D union) $(GLINK_LEX Identifier) $(D ;)
30
26
$(D union) $(GLINK_LEX Identifier) $(GLINK AggregateBody)
31
27
$(GLINK2 template, UnionTemplateDeclaration)
32
- $(GLINK AnonUnionDeclaration)
28
+ $(I AnonUnionDeclaration)
33
29
34
30
$(GNAME AnonUnionDeclaration):
35
31
$(D union) $(GLINK AggregateBody)
@@ -114,7 +110,7 @@ $(H2 $(LNAME2 POD, Plain Old Data))
114
110
115
111
$(H2 $(LNAME2 opaque_struct_unions, Opaque Structs and Unions))
116
112
117
- $(P Opaque struct and union declarations do not have a $(GLINK AggregateBody):)
113
+ $(P Opaque struct and union declarations do not have an $(GLINK AggregateBody):)
118
114
119
115
---
120
116
struct S;
@@ -323,7 +319,7 @@ S t = s; // sets t.a to 3, S.opCall(S) is not called
323
319
324
320
$(H2 $(LEGACY_LNAME2 StructLiteral, struct-literal, Struct Literals))
325
321
326
- $(P Struct literals consist of the name of the struct followed
322
+ $(P A struct literal consists of the name of the struct followed
327
323
by a parenthesized argument list:)
328
324
329
325
$(SPEC_RUNNABLE_EXAMPLE_RUN
@@ -360,7 +356,7 @@ $(TROW $(D .sizeof), Size in bytes of struct)
360
356
$(TROW $(D .alignof), Size boundary struct needs to be aligned on)
361
357
)
362
358
363
- $(H2 $(LNAME2 struct_instance_properties, Struct Instance Properties))
359
+ $(H3 $(LNAME2 struct_instance_properties, Struct Instance Properties))
364
360
365
361
$(TABLE2 Struct Instance Properties,
366
362
$(THEAD Name, Description)
@@ -369,7 +365,7 @@ $(TROW $(D .tupleof), An $(DDSUBLINK spec/template, variadic-templates, expressi
369
365
$(DDSUBLINK spec/class, class_properties, Class Properties) for a class-based example.)
370
366
)
371
367
372
- $(H2 $(LNAME2 struct_field_properties, Struct Field Properties))
368
+ $(H3 $(LNAME2 struct_field_properties, Struct Field Properties))
373
369
374
370
$(TABLE2 Struct Field Properties,
375
371
$(THEAD Name, Description)
@@ -407,8 +403,8 @@ $(H2 $(LEGACY_LNAME2 Struct-Constructor, struct-constructor, Struct Constructors
407
403
408
404
$(P Struct constructors are used to initialize an instance of a struct when a more
409
405
complex construction is needed than is allowed by
410
- $(LINK2 # static_struct_init, static initialization) or a
411
- $(LINK2 # struct-literal, struct literal).
406
+ $(RELATIVE_LINK2 static_struct_init, static initialization) or a
407
+ $(RELATIVE_LINK2 struct-literal, struct literal).
412
408
)
413
409
414
410
$(P Constructors are defined with a function name of `this` and have no return value.
@@ -728,7 +724,7 @@ $(H3 $(LNAME2 field-init, Field initialization inside a constructor))
728
724
---
729
725
)
730
726
731
- $(P If the field type has an $(LINK2 operatoroverloading.html# assignment, `opAssign`)
727
+ $(P If the field type has an $(DDSUBLINK spec/ operatoroverloading, assignment, `opAssign`)
732
728
method, it will not be used for initialization.)
733
729
734
730
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
@@ -1549,14 +1545,14 @@ $(GNAME Invariant):
1549
1545
$(P Struct $(I Invariant)s must hold
1550
1546
at the entry and exit of all public or exported non-static member functions.
1551
1547
The order of application of invariants is:
1548
+ )
1552
1549
$(OL
1553
1550
$(LI preconditions)
1554
1551
$(LI invariant)
1555
1552
$(LI function body)
1556
1553
$(LI invariant)
1557
1554
$(LI postconditions)
1558
1555
)
1559
- )
1560
1556
1561
1557
$(P The invariant need not hold if the struct instance is implicitly constructed using
1562
1558
the default $(D .init) value.)
@@ -1666,8 +1662,8 @@ $(H2 $(LEGACY_LNAME2 AssignOverload, assign-overload, Identity Assignment Overlo
1666
1662
these conditions hold:)
1667
1663
1668
1664
$(UL
1669
- $(LI it has a $(LINK2 # struct-destructor, destructor))
1670
- $(LI it has a $(LINK2 # struct-postblit, postblit))
1665
+ $(LI it has a $(RELATIVE_LINK2 struct-destructor, destructor))
1666
+ $(LI it has a $(RELATIVE_LINK2 struct-postblit, postblit))
1671
1667
$(LI it has a field with an identity assignment overload)
1672
1668
)
1673
1669
0 commit comments