contiguous ranges

Guillaume Chatelet via Digitalmars-d digitalmars-d at puremagic.com
Thu Feb 19 03:20:12 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.

 From this discussion I understand you mainly want to be able to 
BitBlt ranges
http://en.wikipedia.org/wiki/Bit_blit

BitBlt covers multi dimensional arrays as well (2D textures) and 
might convey the semantic you want better than Contiguous (too 
fine grained ?).

Also the blitting term is already used in D (post-blit 
constructor).


More information about the Digitalmars-d mailing list