give structs like this:

struct A
{
        int a = 10;
        string s = "haha";
}

struct B
{
        A aDetails;
}

I'd like to do this and store that symbol name as string (my goal is store the member name);

string memberName = magic(B.aDetails.s);
writeln(memberName); // otuput "aDetails.s"

how can I do that?

closet I got was:

template nameof(alias S) {
        import std.array : split, join;
        import std.traits;
        pragma(msg, fullyQualifiedName!S);
        pragma(msg, "stringof = " ~ S.stringof);
        enum parts = fullyQualifiedName!S.split(".");
        enum nameof = parts[1 .. $].join(".");
}


but neither fullyQualifiedName nor stringof give the symbol in the way I need.

Reply via email to