`<ranges>`: `elements_view::iterator::iterator_category` invokes the `operator*() &&` of the underlying iterator
Open
Nobody has claimed this yet.
bug
ranges
- Dominant language
- C++
- Stars
- 11.1k
- Forks
- 1.7k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 22
Description
Should _STD declval<iterator_t<_Base>>() be _STD declval<const iterator_t<_Base>&>()?
#include <ranges>
struct I {
using difference_type = std::ptrdiff_t;
using value_type = std::pair<int, double>;
value_type& operator*() const &;
void operator*() && = delete;
I& operator++();
I operator++(int);
bool operator==(const I&) const;
};
int main() {
std::ranges::input_range auto r = std::ranges::subrange(I{}, std::unreachable_sentinel);
auto e = r | std::views::keys;
}
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 4982-4989 and reproduce the issue with the provided iterator and views::keys example on Compiler Explorer. Inspect how elements_view::iterator derives iterator_category, then verify the corrected behavior with the example and relevant ranges tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100