Playing with ranges and ufcs
bearophile
bearophileHUGS at lycos.com
Wed Feb 27 15:43:48 PST 2013
> auto opSlice(size_t i, size_t j)
> in {
> assert(i <= j, "some message here");
> } body {
> auto retval = this.save;
> retval._index += i;
> return takeExactly(retval, j - i);
> }
This is the bug opened by Andrea Fontana for this thread:
http://d.puremagic.com/issues/show_bug.cgi?id=9612
At its start I show this code, that contains a but that the D
compiler is able to catch at compile-time:
void main() {
auto a = [0,1,2,3,4,5,6,7,8,9][5 .. 2];
}
To do the same with user-defined structures time ago I have
suggested this, that is currently closed waiting for a better
solution:
http://d.puremagic.com/issues/show_bug.cgi?id=5906
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list