File tree Expand file tree Collapse file tree 1 file changed +27
-4
lines changed Expand file tree Collapse file tree 1 file changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -646,12 +646,35 @@ writeln(__traits(identifier, var)); // "var"
646
646
647
647
$(H2 $(GNAME getAliasThis))
648
648
649
- $(P Takes one argument, a symbol of aggregate type.
650
- If the given aggregate type has $(D alias this), returns a list of
651
- $(D alias this) names, by a tuple of $(D string)s.
652
- Otherwise returns an empty tuple.
649
+ $(P Takes one argument, a type. If the type has `alias this` declarations,
650
+ returns a sequence of the names (as `string`s) of the members used in
651
+ those declarations. Otherwise returns an empty sequence.
653
652
)
654
653
654
+ $(SPEC_RUNNABLE_EXAMPLE_COMPILE
655
+ ---
656
+ alias AliasSeq(T...) = T;
657
+
658
+ struct S1
659
+ {
660
+ string var;
661
+ alias var this;
662
+ }
663
+ static assert(__traits(getAliasThis, S1) == AliasSeq!("var"));
664
+ static assert(__traits(getAliasThis, int).length == 0);
665
+
666
+ pragma(msg, __traits(getAliasThis, S1));
667
+ pragma(msg, __traits(getAliasThis, int));
668
+ ---
669
+ )
670
+
671
+ Prints:
672
+
673
+ $(CONSOLE
674
+ tuple("var")
675
+ tuple()
676
+ )
677
+
655
678
$(SECTION2 $(GNAME getAttributes),
656
679
$(P
657
680
Takes one argument, a symbol. Returns a tuple of all attached user-defined attributes.
You can’t perform that action at this time.
0 commit comments