mirror of https://github.com/AxioDL/metaforce.git
MkCastTo: Use static_cast instead of reinterpret_cast
If the type is convertible to the other one, then a static_cast will be able to perform the conversion (assuming the type itself is constructible). If it isn't, then nullptr will just be converted to a null version of T*.
This commit is contained in:
parent
bf65456a2c
commit
91bdfa86f6
|
@ -184,7 +184,7 @@ for tp in CENTITY_TYPES:
|
|||
sourcef.write('''template <class T>
|
||||
void TCastToPtr<T>::Visit(%s* p) {
|
||||
static_assert(sizeof(T) > 0 && !std::is_void_v<T>, "TCastToPtr can not cast to incomplete type");
|
||||
ptr = reinterpret_cast<T*>(std::is_convertible_v<%s*, T*> ? p : nullptr);
|
||||
ptr = static_cast<T*>(std::is_convertible_v<%s*, T*> ? p : nullptr);
|
||||
}
|
||||
|
||||
''' % (qual, qual))
|
||||
|
|
Loading…
Reference in New Issue