This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 118f. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-11-17
(From submission #803.)
Subclause 8.7 [stmt.expand] paragraph 3 specifies:
For an expression E, let the expressions begin-expr and end-expr be determined as specified in 8.6.5 [stmt.ranged]. An expression is expansion-iterable if it does not have array type and either
- begin-expr and end-expr are of the form E.begin() and E.end(), or
- argument-dependent lookups for begin(E) and for end(E) each find at least one function or function template.
For the non-member case, this means any begin and end function will make an expression expansion-iterable. For example, a std::tuple is specified to be expansion-iterable, but it ought actually to be treated by destructuring.
Other appearances of "find at least one declaration" in the standard apply to member lookup only, e.g. in 7.6.2.4 [expr.await] bullet 3.2 or 9.7 [dcl.struct.bind] paragraph 7; the intent there is to "lock into" the member interpretation, giving a diagnostic if the begin or end member is not quite matching, e.g. due to missing const.
Suggested resolution:
Change in 8.7 [stmt.expand] paragraph 3 as follows:
For an expression E, let the expressions begin-expr and end-expr be determined as specified in 8.6.5 [stmt.ranged]. An expression is expansion-iterable if it does not have array type and either
- begin-expr and end-expr are of the form E.begin() and E.end(), or
- argument-dependent lookups for begin(E) and for end(E) each find at least one viable function or function template.