Skip to content

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

Open
@frederick-vs-ja

Description

@frederick-vs-ja

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingrangesC++20/23 rangesvNextBreaks binary compatibility

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions