the code pick up from v8-0.2.5
/**
* Checks whether two handles are the same.
* Returns true if both are empty, or if the objects
* to which they refer are identical.
* The handles' references are not checked.
*/
template <class S> bool operator==(Handle<S> that) {
void** a = reinterpret_cast<void**>(**this);
void** b = reinterpret_cast<void**>(*that);
if (a == 0) return b == 0;
if (b == 0) return false;
return *a == *b;
}
Handle
Overload operator* so that **this
and *that
return type T*
.
So it seems
void* a = reinterpret_cast<void*>(**this);
void* b = reinterpret_cast<void*>(*that);
return a == b;
will also work well?
If
a
andb
had typevoid*
, then you couldn't dereference them (without casting them to something else first), so*a == *b
wouldn't work.