libobs: Support move for mismatched ComPtr

master
jpark37 2021-09-14 21:12:02 -07:00 committed by Jim
parent 1588357583
commit 23f43f46db
1 changed files with 12 additions and 0 deletions

View File

@ -58,6 +58,10 @@ public:
ptr->AddRef();
}
inline ComPtr(ComPtr<T> &&c) noexcept : ptr(c.ptr) { c.ptr = nullptr; }
template<class U>
inline ComPtr(ComPtr<U> &&c) noexcept : ptr(c.Detach())
{
}
inline ~ComPtr() { Kill(); }
inline void Clear()
@ -91,6 +95,14 @@ public:
return *this;
}
template<class U> inline ComPtr<T> &operator=(ComPtr<U> &&c) noexcept
{
Kill();
ptr = c.Detach();
return *this;
}
inline T *Detach()
{
T *out = ptr;