NVIDIA / NVIDIA/cccl

thrust::distance does not work with std::ranges::iota_view

Open
#787 2 comments 0 reactions 1 assignee Claimed by @elstehle View on GitHub
thrust
Dominant language
C++
Stars
2.5k
Forks
487
Avg merge
2d 7h
Merged PRs (30d)
296

Description

Is it unreasonable for me to expect this to work?

### error
```sh
$ nvc++ -stdpar=multicore --c++20 -c thrust-ranges.cc
"thrust-ranges.cc", line 15: error: no instance of function template "thrust::distance" matches the argument list
argument types are: (std::ranges::iota_view::_Iterator, std::ranges::iota_view::_Iterator)
auto d = thrust::distance(begin,end);
^

1 error detected in the compilation of "thrust-ranges.cc".
```

### thrust-ranges.cc
```c++
#include
#include

typedef std::ptrdiff_t Index_type;

void foo(void)
{
const Index_type ibegin = 0;
const Index_type iend = 100;

auto range = std::views::iota(ibegin, iend);
auto begin = std::begin(range);
auto end = std::end(range);

auto d = thrust::distance(begin,end);
}
```

Note that the type of `Index_type` doesn't matter. The same error occurs if I `#define` it to `int`.

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.