NVIDIA / NVIDIA/cccl

[FEA]: statically assert that iterators passed into cub satisfy random access iterator feautres

Open
#6,064 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
2.5k
Forks
486
Avg merge
2d 6h
Merged PRs (30d)
295

Description

### Is this a duplicate?

- [x] I confirmed there appear to be no [duplicate issues](https://github.com/NVIDIA/cccl/issues) for this request and that I agree to the [Code of Conduct](CODE_OF_CONDUCT.md)

### Area

CUB

### Is your feature request related to a problem? Please describe.

CUB relies on many features that are part of what the standard calls `random access iterator`, for example we rely on `operator[]` and `operator+` for cub algorithms

If a user provides a non random access iterator to a CUB algorithms they will get a cryptic compile error deep down in the bowels of cub.

We should rather statically assert at the entry points that the passed iterators satisfy the requirements we have.

Unfortunately, we cannot simply rely on C++20 `random_access_iterator` as that does not work for some of thrusts fancy iterators, so we need to find a different solution, potentially relying on the newly added `__has_random_access_traversal`

### Describe the solution you'd like

statically assert at the API entrypoints

### Describe alternatives you've considered

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.