You can cast to/from any pointer to T to/from void* with a static_cast, why does Qt use reinterpret_cast?
int SOME_OBJECT::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QMainWindow::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
// Why reinterpret_cast here??
case 0: on_tabWidget_tabCloseRequested((*reinterpret_cast< int(*)>(_a[1]))); break;
default: ;
}
_id -= 1;
}
return _id;
}
Frankly, I’ve never been able to figure it out either. The
void **structure is created the same way, simply casts anint*tovoid*and then performs this weird cast on the other side. As far as I can tell, static_cast would not only be fine, it would be better.You’ll find that there’s a lot of questionable code in large projects like Qt. Sometimes stuff slips through review or just sticks around because nobody wants to go through the hassle of changing it.