pisoir
pisoir

Reputation: 226

|= (or_eq) order of evaluation in C++

I was trying to find the answer to the following question, but was unsuccessful. I have the expression involving bit AND and bit OR (everything unsigned long):

A |= B & C

What is the order of evaluation in C++? Is it A = A | (B & C) or A = (A | B) & C? Or it depends on the compiler version? Thanks.

Upvotes: 0

Views: 142

Answers (1)

NathanOliver
NathanOliver

Reputation: 180500

With the compound assignment operators (op=), the expression E1 op= E2 becomes E1 = E1 op E21. That means for your code that E1 is A and E2 is B & C so the result would be

A = A | (B & C)

Upvotes: 2

Related Questions