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 : 22. Jun 2024, 19:50:08
Autres entêtes
Organisation : i2pn2 (i2pn.org)
Message-ID : <v576d0$onl3$13@i2pn2.org>
References : 1 2 3 4 5 6 7 8 9
User-Agent : Mozilla Thunderbird
On 6/22/24 2:00 PM, Bonita Montero wrote:
Am 22.06.2024 um 19:20 schrieb Richard Damon:
C++ made a special rule for the << operator because the gain for its use as an output was high enough, and the cost as a normal shift operator was rarely high (and normally hidden by the "as if" rule) so it was done there.
I guess C++ doesn't make a statement on that and the ordered behaviour
depens in the cascaded return of the stream-object.
My understanding is that the Standard made that a requirement so the cascaded operands would be computed in the right order.
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.
That was considered useful enough, and where << is used as the shift operator, the restriction is unlikely to cause a large impact, so they did it for that special case.