Hello everyone,

I am trying to forward some member functions from a struct as a Catch-all function, so I did something like this:

    struct A {
        struct HeaderData {
          align(1):
          char [21] id;
          ubyte field1;
          ubyte field2;
        }

        Nullable!(HeaderData) headerData;


        auto opDispatch(string name)() {
          readHeader();
static foreach (member; __traits(allMembers, HeaderData)) {
             static if (name == member) {
                 return mixin("headerData." ~ name);
             }
          }
      }

The mixin line does not work. I want to generate the access to the field. How could I achieve that?

Reply via email to