mirror of
https://github.com/LNH-team/pico-launcher.git
synced 2026-06-02 09:06:54 +02:00
43 lines
826 B
C++
43 lines
826 B
C++
#pragma once
|
|
#include "SharedPtr.h"
|
|
#include "WeakPtr.h"
|
|
|
|
class EnableSharedFromThisBase
|
|
{
|
|
template <class Y>
|
|
friend class SharedPtr;
|
|
|
|
template <class Y>
|
|
friend class EnableSharedFromThis;
|
|
|
|
private:
|
|
EnableSharedFromThisBase() = default;
|
|
};
|
|
|
|
template <class T>
|
|
class EnableSharedFromThis : public EnableSharedFromThisBase
|
|
{
|
|
template <class Y>
|
|
friend class SharedPtr;
|
|
|
|
public:
|
|
SharedPtr<T> SharedFromThis()
|
|
{
|
|
return __sharedFromThisWeakPtr.Lock();
|
|
}
|
|
|
|
WeakPtr<T> WeakFromThis()
|
|
{
|
|
return __sharedFromThisWeakPtr;
|
|
}
|
|
|
|
private:
|
|
WeakPtr<T> __sharedFromThisWeakPtr;
|
|
|
|
template <class Y>
|
|
void __SetSharedFromThisWeakPtr(const SharedPtr<Y>& sharedPtr)
|
|
{
|
|
__sharedFromThisWeakPtr = WeakPtr<Y>(sharedPtr.GetPointer(), sharedPtr._refCount);
|
|
}
|
|
};
|