3 ms·
I'm not advocating writing any code like this, but you can have an overloaded == operator that _does_ have side effects, e.g. [0] [0] https://ideone.com/eJgiN9
by maccard 10y ago
I'm not advocating writing any code like this, but you can have an overloaded == operator that _does_ have side effects, e.g. [0]
[0] https://ideone.com/eJgiN9 https://ideone.com/eJgiN9
- Sanddancer 10y agoIt gets more fun when you're dealing with things like memory mapped I/O, where reading from a register is a destructive action, so even a non-overloaded == can cause side effects.
- WalterBright 10y agoThat's what volatile reads are for - they indicate a side effect.