Last active
January 6, 2020 10:54
-
-
Save StarJade-Park/939ba16c288e0e36a97ba902bca7cdc5 to your computer and use it in GitHub Desktop.
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
// Reference.h | |
#ifndef __REFERENCE_H__ | |
#define __REFERENCE_H__ | |
class Reference | |
{ | |
template<typename T> | |
friend class shared_ptr; | |
protected: | |
Reference() = default; | |
virtual ~Reference() = default; | |
void AddCount() | |
{ | |
++m_ReferenceCount; | |
} | |
void SubstractCount() | |
{ | |
--m_ReferenceCount; | |
if(0 >= m_ReferenceCount) | |
{ | |
m_ReferenceCount = 0; | |
delete this; | |
} | |
} | |
private: | |
unsigned int m_ReferenceCount = 0; | |
}; | |
#endif // !__REFERENCE_H__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment