range-v3 icon indicating copy to clipboard operation
range-v3 copied to clipboard

[request] Binding range in ranges::at or ranges::index

Open beojan opened this issue 4 years ago • 0 comments

As a result of working with struct-of-arrays layout data, I often find I want to work with indices instead of the data itself (i.e. with argsort / argmax type functions).

Range-v3 already makes this quite easy since you simply have to use a projector of the form [&rng](std::size_t i){return rng[i];} or [&rng](std::size_t i){return rng.at(i);}. However, I think this could be improved by providing the ability to construct a ranges::at_fn or ranges::index_fn with the range bound, which could then be used to index into that range.

beojan avatar Feb 11 '21 10:02 beojan