`<ranges>`: `take_view`/`drop_view`/`slide_view`'s `range_difference_t<const V>` issue
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 11.1k
- Forks
- 1.7k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 22
Description
Since range_difference_t<V> is not guaranteed to be the same as range_difference_t<const V>, we'd better do type casting before calling std::min. The standard has no such problem because it always calls ranges::next(ranges::begin(base_), count_, ranges::end(base_)), and range_difference_t<const V> is guaranteed to be implicitly converted to range_difference_t<V> because they are both signed.
#include <ranges>
auto s = std::views::single(0ULL);
auto o = std::views::iota(0ULL, 1ULL);
struct R {
auto begin() { return s.begin(); }
auto end() { return s.end(); }
auto begin() const { return o.begin(); }
auto end() const { return o.end(); }
};
int main() {
const auto d = R{} | std::views::drop(1);
auto b = d.begin();
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at stl/inc/ranges around lines 2831-2836 and reproduce the reported const and non-const range difference types with the supplied example or Godbolt link. Check the affected take_view, drop_view, and slide_view paths, then add or update coverage so the example compiles without the reported type mismatch.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100