[Issue 2499] New: Template alias default value cannot be template instantiation

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Dec 8 13:44:01 PST 2008


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

           Summary: Template alias default value cannot be template
                    instantiation
           Product: D
           Version: 2.019
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: schveiguy at yahoo.com


Simple case:

void foo(T)()
{
}

struct f(alias func=foo!(int))
{
}

void main()
{
  f!() myf;
}

Error in 1.036:
Error: foo!(int) is not a symbol

Error in 2.019:
testtemplatealias.d(5): Error: foo!(int) is used as a type
testtemplatealias.d(11): template instance f!() does not match template
declaration f(alias func = foo!(int))
testtemplatealias.d(11): Error: f!() is used as a type
testtemplatealias.d(11): variable testtemplatealias.main.myf voids have no
value


Workaround is to alias the default parameter before using as the default
parameter:

alias foo!(int) defaultFoo;

struct f(alias func=defaultFoo)
{
}


-- 



More information about the Digitalmars-d-bugs mailing list