Skip to content

Commit 66c6883

Browse files
committed
Fix .tupleof spec for class, struct
Don't use *Tuple names. Add links to explain expression sequences. Struct .tupleof is not a type sequence & it operates on a struct *instance*.
1 parent ffdeb02 commit 66c6883

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

spec/class.dd

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,19 @@ void test(Foo foo)
167167

168168
$(H2 $(LNAME2 class_properties, Class Properties))
169169

170-
$(P The $(D .tupleof) property returns an $(I ExpressionTuple)
171-
of all the fields
172-
in the class, excluding the hidden fields and the fields in the
173-
base class.
170+
$(P The $(D .tupleof) property is an
171+
$(DDSUBLINK spec/template, variadic-templates, expression sequence)
172+
of all the fields in the class, excluding the hidden fields and
173+
the fields in the base class.
174174
)
175175
---
176176
class Foo { int x; long y; }
177+
177178
void test(Foo foo)
178179
{
180+
import std.stdio;
181+
static assert(typeof(foo.tupleof).stringof == `(int, long)`);
182+
179183
foo.tupleof[0] = 1; // set foo.x to 1
180184
foo.tupleof[1] = 2; // set foo.y to 2
181185
foreach (x; foo.tupleof)

spec/struct.dd

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,13 +267,23 @@ $(TABLE2 Struct Properties,
267267
$(THEAD Name, Description)
268268
$(TROW $(D .sizeof), Size in bytes of struct)
269269
$(TROW $(D .alignof), Size boundary struct needs to be aligned on)
270-
$(TROW $(D .tupleof), Gets type tuple of fields))
270+
)
271+
272+
$(H2 $(LNAME2 struct_instance_properties, Struct Instance Properties))
273+
274+
$(TABLE2 Struct Instance Properties,
275+
$(THEAD Name, Description)
276+
$(TROW $(D .tupleof), An $(DDSUBLINK spec/template, variadic-templates, expression sequence)
277+
of all struct fields - see
278+
$(DDSUBLINK spec/class, class_properties, Class Properties) for a class-based example.)
279+
)
271280

272281
$(H2 $(LNAME2 struct_field_properties, Struct Field Properties))
273282

274283
$(TABLE2 Struct Field Properties,
275284
$(THEAD Name, Description)
276-
$(TROW $(D .offsetof), Offset in bytes of field from beginning of struct))
285+
$(TROW $(D .offsetof), Offset in bytes of field from beginning of struct)
286+
)
277287

278288
$(H2 $(LEGACY_LNAME2 ConstStruct, const-struct, Const, Immutable and Shared Structs))
279289

0 commit comments

Comments
 (0)