@@ -502,6 +502,44 @@ a = 2; // sets `S.i` to `2`
502
502
b = 4; // sets `S.j` to `4`
503
503
-----------
504
504
505
+
506
+ $(H2 $(LNAME2 alias-reassignment, Alias Reassignment))
507
+
508
+ $(GRAMMAR
509
+ $(GNAME AliasReassignment):
510
+ $(GLINK_LEX Identifier) $(D =) $(GLINK StorageClasses)$(OPT) $(GLINK Type)
511
+ $(GLINK_LEX Identifier) $(D =) $(GLINK2 expression, FunctionLiteral)
512
+ $(GLINK_LEX Identifier) $(D =) $(GLINK StorageClasses)$(OPT) $(GLINK BasicType) $(GLINK2 function, Parameters) $(GLINK2 function, MemberFunctionAttributes)$(OPT)
513
+ )
514
+
515
+ $(P An alias declaration inside a template can be reassigned a new value.)
516
+
517
+ ---
518
+ template staticMap(alias F, T...)
519
+ {
520
+ alias A = AliasSeq!();
521
+ static foreach (t; T)
522
+ A = AliasSeq!(A, F!T); // alias reassignment
523
+ alias staticMap = A;
524
+ }
525
+ ---
526
+
527
+ $(P The $(I Identifier) must resolve to a lexically preceding $(GLINK AliasDeclaration).
528
+ Both must be members of the same $(GLINK2 template, TemplateDeclaration).
529
+ )
530
+
531
+ $(P The right hand side of the $(I AliasReassignment) replaces the right hand side of the
532
+ $(I AliasDeclaration).
533
+ )
534
+
535
+ $(P Once the $(I AliasDeclaration) has been referred to in any context other than the
536
+ right hand side of an $(I AliasReassignment) it can no longer be reassigned.
537
+ )
538
+
539
+ $(RATIONALE Alias reassignment can result in faster compile times and lowered memory consumption,
540
+ and requires significantly simpler code than the alternative recursive method.)
541
+
542
+
505
543
$(H2 $(LNAME2 extern, Extern Declarations))
506
544
507
545
$(P Variable declarations with the storage class $(D extern) are not allocated
0 commit comments