Negative index range violation

Nicholas Wilson iamthewilsonator at hotmail.com
Thu Feb 22 00:23:47 UTC 2018


On Thursday, 22 February 2018 at 00:13:43 UTC, SrMordred wrote:
> string x = "123";
> auto c = x.ptr;
> c++;
> writeln(c[-1]); // 1
> writeln(c[-1..0]); //BOOM Range violation
>
>
> Can I do this / Bug / some mistake ?

youd have to do
(c-1)[0 .. 1];


More information about the Digitalmars-d-learn mailing list