Templates problem

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Sep 7 02:03:34 PDT 2016


On Wednesday, 7 September 2016 at 08:30:51 UTC, Russel Winder 
wrote:
> On Tue, 2016-09-06 at 14:53 +0000, ketmar via 
> Digitalmars-d-learn wrote:
>> 
> […]
>> exactly. static arrays doesn't have `popFront`, hence 
>> `isInputRange` fails. yet there is no way to tell that to 
>> user, so one should just learn what those cryptic error 
>> messages really means.
>
> I shall assume a ;-) at the end of that.

alas, no jokes here. within the current D sytnax there is simply 
no way to make that error less cryptic. :-(

even pointing at the failed constraint is fairly hard with 
current DMDFE code (that's why nobody did it yet), and show 
custom error for that is nearly impossible. we can't write "catch 
all" template with static assert, 'cause it catches everything, 
which is not desirable.

i myself didn't found even acceptable solution for this mess. 
sure, at least pointing to failed constraint is something we 
should have, but in your case it is of little help, actually.

probably adding `map` overload which accepts static arrays and 
does `static assert(0, "please use slice for static arrays");` 
may help in this case.


More information about the Digitalmars-d-learn mailing list