Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
tlb
on Jan 18, 2021
|
parent
|
context
|
favorite
| on:
That XOR Trick (2020)
Not if they have just the same value, but if they're the same memory location. So check the pointers:
void swap(T &x, T &y) { if (&x == &y) return; x ^= y; y ^= x; x ^= y; }
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: