Requirements for Slicing Ranges

Paul Backus snarwin at gmail.com
Mon Sep 2 12:04:08 UTC 2024


On Monday, 2 September 2024 at 02:47:16 UTC, Jonathan M Davis 
wrote:
> 1. Are there any realistic situations where a range could be a 
> forward or bidirectional range _and_ implement slicing in O(1), 
> but it _can't_ actually be implemented as a random-access 
> range? So, it would need to be possible to take slices of 
> elements of such a range by index in O(1) and yet somehow not 
> be possible to access individual elements by index in O(1).

Infinite forward ranges can implement slicing, but can't be 
random-access ranges because they don't support `r.back`.


More information about the Digitalmars-d mailing list