contiguous ranges
Vlad Levenfeld via Digitalmars-d
digitalmars-d at puremagic.com
Sun Feb 15 22:06:18 PST 2015
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.
More information about the Digitalmars-d
mailing list