Revert "Use template specialization solution" (#137)

This reverts commit 254ae2d3a8.
This commit is contained in:
Christian Semmler 2025-05-20 14:10:51 -07:00 committed by GitHub
parent bf22b8712c
commit 70b1ebea87
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 18 deletions

View File

@ -15,23 +15,6 @@ class LegoROI;
// VTABLE: LEGO1 0x100d9248
// class MxPtrList<LegoROI *>
// Specialize MxPtrList for LegoROI* in order to fix Destroy.
// TODO: Change to using constexpr in MxPtrList<T>::Destroy once C++17 standard works.
template <>
class MxPtrList<LegoROI*> : public MxList<LegoROI**> {
public:
MxPtrList(MxBool p_ownership) { SetOwnership(p_ownership); }
static void Destroy(LegoROI** p_obj) { delete[] p_obj; }
void SetOwnership(MxBool p_ownership)
{
MxCollection<LegoROI**>::SetDestroy(
p_ownership ? MxPtrList<LegoROI*>::Destroy : MxCollection<LegoROI**>::Destroy
);
}
};
// VTABLE: LEGO1 0x100d9260
// SIZE 0x18
class LegoROIMapList : public MxPtrList<LegoROI*> {

View File

@ -5,6 +5,8 @@
#include "mxcore.h"
#include "mxtypes.h"
#include <type_traits>
template <class T>
class MxList;
template <class T>
@ -71,7 +73,15 @@ class MxPtrList : public MxList<T*> {
public:
MxPtrList(MxBool p_ownership) { SetOwnership(p_ownership); }
static void Destroy(T* p_obj) { delete p_obj; }
static void Destroy(T* p_obj)
{
if constexpr (std::is_pointer<T>::value) {
delete[] p_obj;
}
else {
delete p_obj;
}
}
void SetOwnership(MxBool p_ownership)
{