Date: Mon, 22 Dec 2025 13:52:55 -0000
There is no standard conversion sequence that can convert `S` to `int`.
The conversion using `S::operator int()` is a user-defined conversion,
and it is applied to `s` as a result of overload resolution selecting
the built-in candidate `operator+(int, int)` for this expression. So
the expression (notionally) becomes
1 + s.operator int()
and only then is it interpreted as a use of the built-in `+` operator
according to the rules of [expr] (see [over.match.oper] paragraph 11).
Both operands in this expression are already prvalues. In C++23, their
values are used as-is, and no lvalue-to-rvalue conversion is ever
applied. In the current draft for C++26, [basic.lval] paragraph 7
introduces temporary objects to hold the values of the operands. This
does mean that the resulting xvalues must undergo lvalue-to-rvalue
conversion to become prvalues again ([basic.lval] paragraph 6), but
this conversion is applied to the `int` xvalue materialized from
`s.operator int()`, not the `s` expression itself.
The conversion using `S::operator int()` is a user-defined conversion,
and it is applied to `s` as a result of overload resolution selecting
the built-in candidate `operator+(int, int)` for this expression. So
the expression (notionally) becomes
1 + s.operator int()
and only then is it interpreted as a use of the built-in `+` operator
according to the rules of [expr] (see [over.match.oper] paragraph 11).
Both operands in this expression are already prvalues. In C++23, their
values are used as-is, and no lvalue-to-rvalue conversion is ever
applied. In the current draft for C++26, [basic.lval] paragraph 7
introduces temporary objects to hold the values of the operands. This
does mean that the resulting xvalues must undergo lvalue-to-rvalue
conversion to become prvalues again ([basic.lval] paragraph 6), but
this conversion is applied to the `int` xvalue materialized from
`s.operator int()`, not the `s` expression itself.
Received on 2025-12-22 13:53:08
