What order are prefix operators evaluated versus members?

Let's take:

~myArray[myIndex].leadingZeroBitCount,

where the element type also supports prefix ~. Is the evaluation

(~myArray[myIndex]).leadingZeroBitCount or

~(myArray[myIndex].leadingZeroBitCount)?

Postfix productions bind tighter than prefix, as in C, so you should get ~(myArray[myIndex].leadingZeroBitCount).

2 Likes

So if I need the highest-order zero bit, I'd need the parentheses before the member:

(~myArray[myIndex]).leadingZeroBitCount

i.e. I want the element's leading-ONE-bit-count, not the bit shift of the count result.

Yes.