contiguous ranges

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Thu Feb 19 17:25:33 PST 2015


On Monday, 16 February 2015 at 06:06:19 UTC, Vlad Levenfeld wrote:
> Since C++17, there's a new iterator category: the contiguous 
> iterator. Check it out: 
> http://en.cppreference.com/w/cpp/iterator
>
> So, by extension, I think a ContiguousRange would be any 
> RandomAccessRange which has a member called ptr which supports 
> a dereferencing operator * that yields an ElementType!R. This 
> notion is useful for functions which might otherwise perform an 
> element-by-element transfer to an OutputRange via put, instead 
> perform an optimized batch transfer directly to a 
> ContiguousRange via ptr. (Not that Contiguous implies Output; 
> this example assumes the ContigiousRange has enough length to 
> accomodate the transfer or otherwise has mutable length, e.g. 
> builtin arrays.)
>
> I've been using the idea implicitly in my code with static if 
> (is (typeof(*R.init.ptr) == ElementType!R)), but seeing that 
> table made me realize it could be formally abstracted out to a 
> range concept.

Isn't it what a slice is already ?


More information about the Digitalmars-d mailing list