microsoft / microsoft/STL

`<ranges>`: iterator and sentinel of `iota_view` should be ADL-proof

Open
#3,552 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug ranges vNext
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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.