Getting FieldNameTuple including all base-classes.
realhet
real_het at hotmail.com
Wed May 20 09:03:51 UTC 2020
On Wednesday, 20 May 2020 at 01:18:24 UTC, Paul Backus wrote:
> On Tuesday, 19 May 2020 at 23:15:45 UTC, realhet wrote:
> I think what you want is `std.meta.staticMap`. Something like
> this:
>
> alias FieldNameTuple2(T) = staticMap!(FieldNameTuple,
> BaseClassesTuple!T);
class A { int a, a1; }
class B : A { int b; }
class C : B { int c, c1; }
alias AllClasses(T) = Reverse!(AliasSeq!(T,
BaseClassesTuple!T[0..$-1]));
alias AllFieldNames(T) = staticMap!(FieldNameTuple, AllClasses!T);
void main(){
static foreach(T; "ABC")
mixin("AllFieldNames!"~T~".stringof.writeln;");
}
That statticMap unlike the normal map, it also joins the AliasSeq
at the end. Just what I needed.
Thank You!
More information about the Digitalmars-d-learn
mailing list