Skip to content

[stmt.expand] begin(E)/end(E) should perform overload resolution #803

@Sirraide

Description

@Sirraide

Full name of submitter (unless configured in github; will be published with the issue): Ambrose T.

Reference (section label): [stmt.expand]

Link to reflector thread (if any): N/A

Issue description:

[stmt.expand]p3 reads:

An expression is expansion-iterable, if [...]

  • argument-dependent lookups for begin(E) and for end(E) each find at least one function or function template.

This wording seems to imply that if any function or function template with the name begin/end (at least one each) is found via ADL, then E is expansion-iterable. This seems much too broad as it doesn’t take into consideration whether begin(E) or end(E) would even be well-formed.

E.g. if E is of type std::tuple<...>, then ADL for begin/end in namespace std will find quite a few functions (or function templates), but none of them accept a parameter of type std::tuple<...>, and the intent is surely that expansion over a std::tuple<...> be destructuring rather than iterating.

Suggested resolution:

Change the requirement from name lookup succeeding to overload resolution succeeding (notably, if overload resolution succeeds but there is no usable candidate, the program should be ill-formed).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions