Skip to content

Instantly share code, notes, and snippets.

@ariel-avi
Last active November 4, 2020 19:30
Show Gist options
  • Save ariel-avi/71511e3930b1933ab2eb40293aa6e44d to your computer and use it in GitHub Desktop.
Save ariel-avi/71511e3930b1933ab2eb40293aa6e44d to your computer and use it in GitHub Desktop.
ManagedObject.h
#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