2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 05:47:42 +00:00

MkCastTo: Make operator bool instances explicit

Prevents error prone implicit conversions.
This commit is contained in:
Lioncash
2020-04-17 13:29:20 -04:00
parent 8f5caca1e5
commit 2c3e5e205f
4 changed files with 15 additions and 11 deletions

View File

@@ -132,7 +132,8 @@ headerf.write('''
operator T*() const { return GetPtr(); }
T& operator*() const { return *GetPtr(); }
T* operator->() const { return GetPtr(); }
operator bool() const { return ptr != nullptr; }
bool IsValid() const { return ptr != nullptr; }
explicit operator bool() const { return IsValid(); }
};
template <class T>
@@ -147,7 +148,8 @@ public:
operator const T*() const { return GetPtr(); }
const T& operator*() const { return *GetPtr(); }
const T* operator->() const { return GetPtr(); }
operator bool() const { return TCastToPtr<T>::ptr != nullptr; }
bool IsValid() const { return TCastToPtr<T>::ptr != nullptr; }
explicit operator bool() const { return IsValid(); }
};
}