contiguous ranges
John Colvin via Digitalmars-d
digitalmars-d at puremagic.com
Fri Feb 20 00:22:37 PST 2015
On Friday, 20 February 2015 at 01:25:34 UTC, deadalnix wrote:
> 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 ?
Yeah...
Maybe I'm missing something, but I don't see anything here that
isn't already covered by built-in slices, opSlice, opSliceAssign
and put.
More information about the Digitalmars-d
mailing list