Hacker News new | ask | show | jobs
by int_19h 3219 days ago
In C++, == pretty much always uses value semantics regardless, because reference semantics are pretty much always explicit (dereference with star etc).
1 comments

I think you mean reference with & (e.g. &x == &y)
No, I mean dereference if what you have are reference types (i.e. pointers in C; I'm using Java terminology here, since that's the baseline for comparison) to begin with, which is equivalent to the situation in Java. E.g. to copy the referenced object, you need to do x = y, while x = y copies the reference (pointer) itself. Similarly, when you compare, x == y compares the referenced objects, while x == y compares the references (pointers). And even for member access, you have to do (*x).foo, or the equivalent syntactic sugar x->foo.