@@ -949,26 +949,35 @@ $(H4 $(LNAME2 lvalue-sequences, Lvalue Sequences))
949
949
$(DDSUBLINK articles/ctarguments, type-seq-instantiation, declare variables).
950
950
A variable whose type is a *TypeSeq* is called an
951
951
*lvalue sequence*.)
952
- $(P An lvalue sequence can be initialized from, assigned to, and compared with
953
- a value sequence of a compatible type.)
952
+
953
+ - An element of an lvalue sequence may be modifiable.
954
+ - An lvalue sequence can be initialized from, assigned to, and compared with
955
+ a value sequence whose elements are compatible.)
954
956
955
957
$(SPEC_RUNNABLE_EXAMPLE_RUN
956
958
---
957
959
import std.meta: AliasSeq;
958
960
// use a type alias just for convenience
959
961
alias TS = AliasSeq!(string, int);
962
+
960
963
TS tup; // lvalue sequence
961
964
assert(tup == AliasSeq!("", 0)); // TS.init
965
+ // elements can be modified
966
+ tup[1]++;
967
+ assert(tup[1] == 1);
962
968
963
- int i = 5;
969
+ byte i = 5;
964
970
// initialize another lvalue sequence from a sequence of a value and a symbol
965
971
auto tup2 = AliasSeq!("hi", i); // value of i is copied
966
972
i++;
973
+ assert(tup2[1] == 5); // unchanged
974
+
967
975
enum hi5 = AliasSeq!("hi", 5); // rvalue sequence
968
976
static assert(is(typeof(hi5) == TS));
969
- assert(tup2 == hi5);
977
+ // compare elements
978
+ assert(tup2 == hi5); // OK, byte and int have a common type
970
979
971
- // lvalue sequence elements can be modified
980
+ // lvalue sequence can be assigned to a ValueSeq
972
981
tup = tup2;
973
982
assert(tup == hi5);
974
983
---
0 commit comments