What about this...
BCS
BCS at pathlink.com
Tue Jan 15 10:14:12 PST 2008
Aarti_pl wrote:
> Any comments on this? Probably error, but maybe someone wants to add
> something...
>
> --------
>
> void pattern(T)(T v) {}
>
> T pattern(T)() {return T.init;}
>
> void main() {
> pattern!(int)(5);
> }
>
> ---------
>
> Above code results in compile time error:
>
> quicktest.d(6): template instance pattern!(int) matches more than one
> template declaration, pattern(T) and pattern(T)
> quicktest.d(6): Error: template instance 'pattern!(int)' is not a variable
> quicktest.d(6): Error: function expected before (), not pattern!(int) of
> type int
>
the issue is more noticeable in this form
template pattern(T) { void pattern(T v) {} }
template pattern(T) { T pattern() {return T.init;} }
void main() {
pattern!(int)(5);
}
DMD can't pick witch template to do. My thoughts on fixing this would be
to let this work:
template pattern(T)
{
void pattern(T v) {}
T pattern() {return T.init;}
}
More information about the Digitalmars-d-learn
mailing list