Why D const is annoying

Trass3r un at known.com
Sat Dec 10 03:58:25 PST 2011


Am 10.12.2011, 12:27 Uhr, schrieb Walter Bright  
<newshound2 at digitalmars.com>:

> On 12/10/2011 3:17 AM, Mehrdad wrote:
>> Yup, I started using it as soon as Timon mentioned it (thanks for the  
>> suggestion!).
>> But I was referring to the bug, not to the workaround. :)
>
> It isn't a bug, it is designed to work that way. The type of the  
> instantiation is based on the argument types, not the parameter types.  
> (Note that "2" is the argument and "N" is the parameter.)
>
> Hence the message:
>
> Error: cannot implicitly convert expression (m) of type Matrix!(int,2)  
> to Matrix!(int,N)

That error message is crap and struck me as well some time ago.
It hides the real cause: int != size_t

1 is implicitly convertible to size_t so what's the problem with using  
this conversion if no explicit template specialization with int exists?


More information about the Digitalmars-d mailing list