[Issue 4886] New: Template (alias) tuple parameters cannot take .length property in compiletime

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Sep 18 00:54:39 PDT 2010


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

           Summary: Template (alias) tuple parameters cannot take .length
                    property in compiletime
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: zan77137 at nifty.com


--- Comment #0 from SHOO <zan77137 at nifty.com> 2010-09-18 00:54:05 PDT ---
This code doesn't work!
----
auto test(ARGS...)()
{
    int[ARGS.length] x;
    return x;
}

void main(string[] args)
{
    void func(){  }
    auto t = test!(func)();
}
----


Results:
prog.d(3): Error: identifier 'length' of 'ARGS.length' is not defined
prog.d(3): Error: index is not a type or an expression
prog.d(10): Error: template instance prog.main.test!(func) error instantiating


Workaround is this:
----
size_t lengthof(ARGS...)()
{
    return ARGS.length;
}

auto test(ARGS...)()
{
    int[lengthof!(ARGS)()] x;
    return x;
}

void main(string[] args)
{
    void func(){  }
    auto t = test!(func)();
}
----

-- 
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