myv*_*ang 9 c++ v8 reinterpret-cast
代码从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;
}
Run Code Online (Sandbox Code Playgroud)
Handle超载运算符*,这样**this和*that返回类型T*.
所以它看起来
void* a = reinterpret_cast<void*>(**this);
void* b = reinterpret_cast<void*>(*that);
return a == b;
Run Code Online (Sandbox Code Playgroud)
也会运作良好?
如果a和b具有 type void*,那么您无法取消引用它们(不先将它们强制转换为其他内容),所以*a == *b不起作用。
| 归档时间: |
|
| 查看次数: |
624 次 |
| 最近记录: |