Need for (C++20) Contiguous Range

Steven Schveighoffer schveiguy at gmail.com
Fri Oct 9 16:57:52 UTC 2020


On 10/9/20 12:05 PM, Ola Fosheim Grøstad wrote:
> On Friday, 9 October 2020 at 15:44:27 UTC, Steven Schveighoffer wrote:
>> What can you do when defining something that isn't an array as 
>> contiguous memory? What are the primitives that you use, for what 
>> purpose?
> 
> Ok, so here is another example. Priority queue. Traversing it in order 
> would jump over the place and be slow. A sequential scan has major 
> cache-prefetch benefits.
> 
> All you need is a new filter "unordered", when that is applied to a 
> container that provides an unordered contiguous memory interface it can 
> do a sequential scan.
> 
> So you would get:
> 
> "container.somerangefunction" is in order, but slow.
> 
> "container.unordered.somerangefunction" may not be in order, but is fast.
> 
> 

It's fast because the unordered accessor gets a slice, and 
somerangefunction sees its a slice and does something magic because it's 
contiguous memory.

The question is, would there be any purpose to returning something OTHER 
than a slice for unordered? And I don't mean, you happen to get benefits 
because it's sequential, it has to be something that the algorithm will 
do differently because it sees it's a special type.

-Steve


More information about the Digitalmars-d mailing list