Sujet : Re: Can you please verify that the analysis of these C functions is correct?
De : richard (at) *nospam* damon-family.org (Richard Damon)
Groupes : comp.lang.c comp.lang.c++Date : 23. Jun 2024, 12:38:41
Autres entêtes
Organisation : i2pn2 (i2pn.org)
Message-ID : <v591g1$rmf0$5@i2pn2.org>
References : 1 2 3 4 5 6 7 8 9 10 11
User-Agent : Mozilla Thunderbird
On 6/23/24 2:52 AM, Bonita Montero wrote:
Am 22.06.2024 um 20:50 schrieb Richard Damon:
Prior to that, it was allowed to compute the order of the terms being output in any order, as the call to operator <<(ostream& strm, T& value) was allowd to compute value before resolving stream (as the value from the previous operator <<, which caught enough people off guard.
With a left-associative operator the result of the left part has to be
calculated before it can be used with the right part.
But the right part can be calculated before the left part is.
so in the call sequence: statement a+b+c where a,b, and c are expressions of user defined types this becomes
operator+(operator+(a, b), c)
the expressions a, b and c can be evaluated in any order.
The change was that for operator<< the order of evalutation is DEFINED to be a, then b, then c. That order was NOT provided for +.
Yes, the outer call can't be done before the inner call returns, but unless there is a specific requirement in the Standard, no order of the sub-expressions is implied.