anotherim-desktop/plugins/windows-notification/api/include/ComPtr.hpp

18 lines
382 B
C++
Raw Normal View History

2021-03-26 11:22:55 +00:00
#pragma once
template<typename T>
struct ComPtr
{
T *p{};
~ComPtr() { if (p != nullptr) p->Release(); }
T &operator*() const { return *p; }
T **operator&() const { return &p; }
T **operator&() { return &p; }
T *operator->() const { return p; }
template<typename U>
HRESULT As( U **const pp ) const
{ return p->QueryInterface(pp); }
};