Last active
November 4, 2020 19:30
-
-
Save ariel-avi/71511e3930b1933ab2eb40293aa6e44d to your computer and use it in GitHub Desktop.
ManagedObject.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
using namespace System; | |
namespace Interop | |
{ | |
template <class T> | |
public ref class ManagedObject | |
{ | |
protected: | |
T* m_Instance; | |
public: | |
explicit ManagedObject(T* instance) | |
: m_Instance(instance) { } | |
virtual ~ManagedObject() | |
{ | |
if (m_Instance != nullptr) { | |
delete m_Instance; | |
} | |
} | |
!ManagedObject() | |
{ | |
if (m_Instance != nullptr) { | |
delete m_Instance; | |
} | |
} | |
T* get_instance() | |
{ | |
return m_Instance; | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment