Why are primitive type operations not sequenced and not indefinitely ordered?

If i is int , expressions such as ++i + ++i are undefined since there are 2 disjoint modifications of i . However, if i is some int -like class, ++i + ++i instead has indefinitely ordered modifications and therefore behavior is determined (with a deterministic result in this case). Is there a case when it would be better if operations with primitives were disjoint, and not vaguely ordered? If so, why does this case not apply to user types? If not, then why primitive operations do not matter?

+4
source share
1 answer

As a rule, there are as many β€œbiased” as possible.

It is not possible to perform two functions performing interleaving in C ++. Therefore, it is impossible to perform two interlaces of the operator++ implementation.

Therefore, for class types that implement operator++ , this is vaguely ordered.

+3
source

All Articles