Negative index range violation

Steven Schveighoffer schveiguy at yahoo.com
Thu Feb 22 02:41:30 UTC 2018


On 2/21/18 7:30 PM, SrMordred wrote:
>> But with a slice negative indexes are never allowed, even on a pointer.
> 
>> youd have to do
>> (c-1)[0 .. 1];
> 
> Nice!
> Thank you both!
> 
> In D Slice article it says "You can even use negative indexes!" so I 
> thought
> that the [-1..x] should work too :)
> 
> 

Hah! I never thought of doing a slice with negative indexes ;)

Note that the statement is about C pointers, so since C doesn't have 
slicing, it stands to reason that slicing with negative indexes isn't 
supported.

-Steve


More information about the Digitalmars-d-learn mailing list