@@ -429,6 +429,44 @@ a = 2; // sets `S.i` to `2`
429
429
b = 4; // sets `S.j` to `4`
430
430
-----------
431
431
432
+
433
+ $(H2 $(LNAME2 alias-reassignment, Alias Reassignment))
434
+
435
+ $(GRAMMAR
436
+ $(GNAME AliasReassignment):
437
+ $(GLINK_LEX Identifier) $(D =) $(GLINK StorageClasses)$(OPT) $(GLINK Type)
438
+ $(GLINK_LEX Identifier) $(D =) $(GLINK2 expression, FunctionLiteral)
439
+ $(GLINK_LEX Identifier) $(D =) $(GLINK StorageClasses)$(OPT) $(GLINK BasicType) $(GLINK2 function, Parameters) $(GLINK2 function, MemberFunctionAttributes)$(OPT)
440
+ )
441
+
442
+ $(P An alias declaration inside a template can be reassigned a new value.)
443
+
444
+ ---
445
+ template staticMap(alias F, T...)
446
+ {
447
+ alias A = AliasSeq!();
448
+ static foreach (t; T)
449
+ A = AliasSeq!(A, F!T); // alias reassignment
450
+ alias staticMap = A;
451
+ }
452
+ ---
453
+
454
+ $(P The $(I Identifier) must resolve to a lexically preceding $(GLINK AliasDeclaration).
455
+ Both must be members of the same $(GLINK2 template, TemplateDeclaration).
456
+ )
457
+
458
+ $(P The right hand side of the $(I AliasReassignment) replaces the right hand side of the
459
+ $(I AliasDeclaration).
460
+ )
461
+
462
+ $(P Once the $(I AliasDeclaration) has been referred to in any context other than the
463
+ right hand side of an $(I AliasReassignment) it can no longer be reassigned.
464
+ )
465
+
466
+ $(RATIONALE Alias reassignment can result in faster compile times and lowered memory consumption,
467
+ and requires significantly simpler code than the alternative recursive method.)
468
+
469
+
432
470
$(H2 $(LNAME2 extern, Extern Declarations))
433
471
434
472
$(P Variable declarations with the storage class $(D extern) are not allocated
0 commit comments