Skip to content

Commit d3e26a2

Browse files
authored
spec/arrays: Improve static array .tupleof docs (#3271)
spec/arrays: Improve static array .tupleof docs Signed-off-by: Dennis <dkorpel@users.noreply.github.com> Merged-on-behalf-of: Dennis <dkorpel@users.noreply.github.com>
1 parent 121243b commit d3e26a2

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

spec/arrays.dd

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,21 @@ Returns an array literal with each element of the literal being the $(D .init) p
580580
$(TROW $(D .ptr), Returns a pointer to the first element of the array.)
581581
$(TROW $(D .dup), Create a dynamic array of the same size and copy the contents of the array into it. The copy will have any immutability or const stripped. If this conversion is invalid the call will not compile.)
582582
$(TROW $(D .idup), Create a dynamic array of the same size and copy the contents of the array into it. The copy is typed as being immutable. If this conversion is invalid the call will not compile.)
583-
$(TROW $(D .tupleof), $(ARGS Returns an $(DDSUBLINK spec/template, variadic-templates, expression sequence) of all elements of the array, as with $(D .tupleof) for structs and $(DDSUBLINK spec/class, class_properties, classes).))
583+
$(TROW $(D .tupleof), $(ARGS Returns an $(DDSUBLINK spec/template, homogeneous_sequences, lvalue sequence) of each element in the array:
584+
$(SPEC_RUNNABLE_EXAMPLE_RUN
585+
---
586+
void foo(int, int, int) { /* ... */ }
587+
588+
int[3] ia = [1, 2, 3];
589+
foo(ia.tupleof); // same as `foo(1, 2, 3);`
590+
591+
float[3] fa;
592+
//fa = ia; // error
593+
fa.tupleof = ia.tupleof;
594+
assert(fa == [1F, 2F, 3F]);
595+
---
596+
)
597+
))
584598
)
585599

586600
$(P Dynamic array properties are:)

spec/template.dd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -914,8 +914,8 @@ $(H4 $(LNAME2 homogeneous_sequences, Homogeneous Sequences))
914914
$(UL
915915
$(LI `.tupleof` can be $(DDSUBLINK spec/class, class_properties, used on a class)
916916
or struct instance to obtain an lvalue sequence of its fields.)
917-
$(LI `.tupleof` can be used on a static array instance to obtain an lvalue
918-
sequence of its elements.)
917+
$(LI `.tupleof` can be $(DDSUBLINK spec/arrays, array-properties, used on a static array)
918+
instance to obtain an lvalue sequence of its elements.)
919919
)
920920

921921
$(H4 $(LNAME2 seq-ops, Sequence Operations))

0 commit comments

Comments
 (0)