const ref template vs non-template

Dan dbdavidson at yahoo.com
Tue Nov 6 09:18:46 PST 2012


Why does g(cs) compile but not G(cs)?

Thanks,
Dan

struct S{}

void g(ref S i) {}
void g(const ref S i) {}
void G(T)(ref T i) {}
void G(T)(const ref T i) {}

void main() {
   S s;
   const(S) cs;
   g(s);
   g(cs);
   G(s);
   // Error: template p.G matches more than one template 
declaration, /p.d(5):G(T) and /p.d(6):G(T)
   // G(cs);
}



More information about the Digitalmars-d-learn mailing list