atilaneves / cerealed

Powerful binary serialisation library for D
BSD 3-Clause "New" or "Revised" License
92 stars 3 forks source link

Alias this issue #15

Open togrue opened 8 years ago

togrue commented 8 years ago

This broken down testcase doesn't compile, as long there is a alias this.

    struct TestStruct {
        char[] txt;
        alias txt this;
    }

    auto decerealiser = Decerealiser([0, 2, 0x90, 0x91]);
    auto ts = decerealiser.value!TestStruct;
    assert(ts.txt == ['\x90', '\x91']);
    assert(ts.txt.length == 2);
atilaneves commented 8 years ago

This is tricky. The problem here is that the alias this makes TestStruct an InputRange and those are treated differently from "regular" aggregates. I'm not sure how to support ranges and have the example code work.