Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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



It 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.


That's what volatile reads are for - they indicate a side effect.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: