C++ Logo

std-discussion

Advanced search

Re: Does the statement "The postfix expression before the dot or arrow is evaluated; 63 the result of that evaluation..." applies to overloaded operators also

From: Edward Catmur <ecatmur_at_[hidden]>
Date: Wed, 10 May 2023 05:56:38 -0500
On Wed, May 10, 2023, 03:05 Sean Mayard via Std-Discussion <
std-discussion_at_[hidden]> wrote:

> I came to know that [expr.compound] mainly applies to built in operators.
> But, in terms of syntax and evaluation order, [expr.compound] also applies
> to overloaded operators.
>
> Then I read expr.ref#1
> <https://timsong-cpp.github.io/cppwp/n4868/expr.compound#expr.ref-1>
> which states:
>
> *The postfix expression before the dot or arrow is evaluated;63 the result
>> of that evaluation, together with the id-expression, determines the result
>> of the entire postfix expression.*
>>
>
> As you can see the above quoted statement talks about "evaluation". So my
> question is does the above quoted statement from [expr.ref#1] apply to
> overloaded operators?
>

No. Evaluation is not the same thing as evaluation order.

Of course, the left operand of the arrow is evaluated in an overloaded
operator call, anyway.
https://timsong-cpp.github.io/cppwp/n4868/over.oper#over.ref-1

Why do you ask? Under what circumstances do you think the left operand
might not be evaluated?

Received on 2023-05-10 10:56:51