mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-18 05:11:15 +00:00
Use template specialization solution
This commit is contained in:
parent
c695834d66
commit
254ae2d3a8
@ -8,7 +8,7 @@ include(CheckCXXSourceCompiles)
|
|||||||
include(CMakeDependentOption)
|
include(CMakeDependentOption)
|
||||||
include(CMakePushCheckState)
|
include(CMakePushCheckState)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
|
|||||||
@ -15,6 +15,23 @@ class LegoROI;
|
|||||||
// VTABLE: LEGO1 0x100d9248
|
// VTABLE: LEGO1 0x100d9248
|
||||||
// class MxPtrList<LegoROI *>
|
// 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
|
// VTABLE: LEGO1 0x100d9260
|
||||||
// SIZE 0x18
|
// SIZE 0x18
|
||||||
class LegoROIMapList : public MxPtrList<LegoROI*> {
|
class LegoROIMapList : public MxPtrList<LegoROI*> {
|
||||||
|
|||||||
@ -5,8 +5,6 @@
|
|||||||
#include "mxcore.h"
|
#include "mxcore.h"
|
||||||
#include "mxtypes.h"
|
#include "mxtypes.h"
|
||||||
|
|
||||||
#include <type_traits>
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
class MxList;
|
class MxList;
|
||||||
template <class T>
|
template <class T>
|
||||||
@ -73,15 +71,7 @@ class MxPtrList : public MxList<T*> {
|
|||||||
public:
|
public:
|
||||||
MxPtrList(MxBool p_ownership) { SetOwnership(p_ownership); }
|
MxPtrList(MxBool p_ownership) { SetOwnership(p_ownership); }
|
||||||
|
|
||||||
static void Destroy(T* p_obj)
|
static void Destroy(T* p_obj) { delete p_obj; }
|
||||||
{
|
|
||||||
if constexpr (std::is_pointer<T>::value) {
|
|
||||||
delete[] p_obj;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
delete p_obj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetOwnership(MxBool p_ownership)
|
void SetOwnership(MxBool p_ownership)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user