anotherim-desktop/plugins/windows-notification/api/include/ComPtr.hpp
2021-06-09 07:19:08 -03:00

18 lines
382 B
C++

#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); }
};