Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: David Brown Newsgroups: comp.lang.c,comp.lang.c++ Subject: Re: Can you please verify that the analysis of these C functions is correct? Date: Sun, 23 Jun 2024 14:38:06 +0200 Organization: A noiseless patient Spider Lines: 28 Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 23 Jun 2024 14:38:06 +0200 (CEST) Injection-Info: dont-email.me; posting-host="5355e1e2ebba64f698c289003534b1d6"; logging-data="371432"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19PG6M20T+lUPdUh9NQ9hkc5eMadwKWDNM=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:FdAFs3gSThmatv4y/uuxCMSrb8M= Content-Language: en-GB In-Reply-To: Bytes: 2589 On 23/06/2024 08:52, 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. Both the left part and the right part need to be evaluated before the operator between them can be evaluated - but the two parts can be evaluated in either order (or even interleaved in their evaluation). Associativity is irrelevant. Before C++17 (which added the rules for sequencing for shifts, and made a few other changes), if you had: foo() << bar() then the compiler could evaluate bar() then foo(), or foo() then bar(). It can still happily arrange them as it wants for "foo() + bar()".