Need for (C++20) Contiguous Range

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Fri Oct 9 18:07:25 UTC 2020


On Friday, 9 October 2020 at 15:44:27 UTC, Steven Schveighoffer 
wrote:
> A stride is not contiguous, it skips data.

Anyway, I think the main benefit of having stride support is that 
you can write an algorithm that requires say double or a pair of 
doubles (like a coordinate) and optimize it and compile it to one 
precompiled library and then use it on any sequence of structs. 
All you need to provide is the initial offset and the stride 
offset.

So, if you have some complicated algorithm with maybe some asm in 
it to do cluster analysis of coordinates, then you can use it on 
any uniform struct memory layout. It can even be completely 
different structs as long as they all have the same offset.

Assuming that the stride is a runtime parameter.



More information about the Digitalmars-d mailing list