[Issue 10180] New: offsetof doesn't work through function call alias this

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun May 26 22:22:12 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10180

           Summary: offsetof doesn't work through function call alias this
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: k.hara.pg at gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2013-05-26 22:22:11 PDT ---
template TypeTuple(TL...) { alias TypeTuple = TL; }

template Identity(alias T) { alias Identity = T; }

struct Tuple(Specs...)
{
    static if (is(Specs))
    {
        alias Types = Specs;
        Types expand;
        alias expand this;
    }
    else
    {
        alias Types = TypeTuple!(Specs[0]);
        Types expand;
        mixin("alias Identity!(expand[0]) "~Specs[1]~";");

        @property
        ref Tuple!(Specs[0]) _Tuple_super()
        {
            return *cast(typeof(return)*) (&expand[0]);
        }
        alias _Tuple_super this;
    }
}
void main()
{
    Tuple!(int, "a") x;
    auto o1 = x.a.offsetof;     // OK
    auto o2 = x[0].offsetof;    // NG: no property 'offsetof' for type 'int'
    auto o3 = x._Tuple_super[0].offsetof;   // same as above
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list