`<ranges>`: iterator and sentinel of `iota_view` should be ADL-proof
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 11.1k
- Forks
- 1.7k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 22
Description
Describe the bug
[range.iota] describes the iterator and sentinel types of iota_view as nested classes, but MSVC STL doesn't follow the wording. Difference from the standard wording is observable via ADL (Godbolt link).
#include <ranges>
constexpr int foo(auto) noexcept { return 42; } // selected by libc++ & libstdc++
namespace fvs {
constexpr int foo(std::input_iterator auto) noexcept { return 0; } // selected by MSVC STL
struct bar {};
}
using ioit = std::ranges::iterator_t<std::ranges::iota_view<fvs::bar*, fvs::bar*>>;
static_assert(foo(ioit{}) == 42);
I think we should make them non-template classes nested in class templates. IIUC the enclosing class is not nessarily iota_view, which allows SCARY implementation strategies.
See also
- WG21-P2538, and
- How
hana::type<T>“disables ADL”.
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 the implementation of iota_view's iterator and sentinel types and compare it with the [[range.iota]] wording. Use the provided Godbolt reproducer to check the ADL difference; done means the implementation's iterator and sentinel types have the intended ADL-proof behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100