@@ -919,7 +919,7 @@ $(H4 $(LNAME2 homogeneous_sequences, Homogeneous Sequences))
919
919
---
920
920
)
921
921
922
- $(P A *TypeSeq* can be used to declare parameters for a function:)
922
+ $(P A *TypeSeq* can be used to declare a parameter sequence for a function:)
923
923
924
924
$(SPEC_RUNNABLE_EXAMPLE_RUN
925
925
---
@@ -940,22 +940,24 @@ $(H4 $(LNAME2 homogeneous_sequences, Homogeneous Sequences))
940
940
---
941
941
)
942
942
943
- $(NOTE A value sequence cannot be returned from a function - instead, return a
944
- $(REF Tuple, std,typecons).)
943
+ $(P A value sequence:)
944
+ * Can be copied
945
+ * Cannot have its address taken
946
+ * Cannot be returned from a function - instead, return a
947
+ $(REF Tuple, std,typecons)
945
948
946
949
$(H4 $(LNAME2 lvalue-sequences, Lvalue Sequences))
947
950
948
951
$(P A *TypeSeq* can similarly be used to
949
952
$(DDSUBLINK articles/ctarguments, type-seq-instantiation, declare variables).
950
- Parameters or variables whose type is a *TypeSeq* are called an
953
+ A variable whose type is a *TypeSeq* is called an
951
954
*lvalue sequence*.)
955
+ $(P An lvalue sequence can be initialized from, assigned to, and compared with
956
+ a value sequence of a compatible type.)
952
957
953
- $(SPEC_RUNNABLE_EXAMPLE_COMPILE
954
- ---
955
- void main()
956
- {
958
+ $(SPEC_RUNNABLE_EXAMPLE_RUN
959
+ ---
957
960
import std.meta: AliasSeq;
958
-
959
961
// use a type alias just for convenience
960
962
alias TS = AliasSeq!(string, int);
961
963
TS tup; // lvalue sequence
@@ -972,8 +974,7 @@ $(H4 $(LNAME2 lvalue-sequences, Lvalue Sequences))
972
974
// lvalue sequence elements can be modified
973
975
tup = tup2;
974
976
assert(tup == hi5);
975
- }
976
- ---
977
+ ---
977
978
)
978
979
979
980
$(UL
@@ -983,6 +984,21 @@ $(H4 $(LNAME2 lvalue-sequences, Lvalue Sequences))
983
984
instance to obtain an lvalue sequence of its elements.)
984
985
)
985
986
987
+ $(P An lvalue sequence can be initialized from a single expression.
988
+ Each element is initialized from the given expression.)
989
+
990
+ $(SPEC_RUNNABLE_EXAMPLE_RUN
991
+ ---
992
+ import std.meta: AliasSeq;
993
+ AliasSeq!(int, int, int) vs = 4;
994
+ assert(vs == AliasSeq!(4, 4, 4));
995
+
996
+ int[3] sa = [1, 2, 3];
997
+ vs = sa.tupleof;
998
+ assert(vs == AliasSeq!(1, 2, 3));
999
+ ---
1000
+ )
1001
+
986
1002
$(H4 $(LNAME2 seq-ops, Sequence Operations))
987
1003
988
1004
$(UL
0 commit comments