Ranges and Library and toir.c internal error
Ellery Newcomer
ellery-newcomer at utulsa.edu
Wed Oct 31 18:31:44 PDT 2012
On 10/31/2012 04:35 PM, StupidIsAsStupidDoes wrote:
>
> The char call doesn't compile and I get a toir.c internal error.
>
On a recent dmd build from github, I don't get any ICE, so it may have
been fixed. I do get some disconcerting type deduction failures, though...
> I'm still trying to get my head around Ranges. Is a int array a valid
> range but a character array not?
All arrays are valid ranges, but char[], wchar[], and const variations
thereof are special. They are treated as ranges of dchar so that you are
guaranteed to get complete unicode characters out of them.
your code, modified:
import std.traits;
size_t countBetween(Range)(Range arr, ElementType!Range low,
ElementType!Range high) {
return count!( (x){return ((x >= low) && (x <= high)); })(arr);
}
ought to handle both int[] and char[] properly.
More information about the Digitalmars-d-learn
mailing list