#include <Containers/ComPtr.h>
template<class T>
ComPtr class
Wraps the interface pointer of the specified type and maintains a reference count.
Constructors, destructors, conversion operators
-
ComPtr(std::
nullptr_t = nullptr) constexpr noexcept - Default constructor.
- ComPtr(T* ptr) explicit noexcept
- Construct from the pointer.
-
template<class U, std::ComPtr(U* ptr) explicit noexcept
enable_if_t<!std:: is_same<::IUnknown*, U*>::value && !std:: is_base_of<T, U>::value, int> = 0> - Construct from the pointer of a related type.
- ComPtr(const ComPtr& other) noexcept
- Copy constructor.
-
template<typename U, std::ComPtr(const ComPtr<U>& other) noexcept
enable_if_t<std:: is_convertible<U*, T*>::value, int> = 0> - ComPtr(ComPtr&& other) noexcept
- Move constructor.
-
template<typename U, std::ComPtr(ComPtr<U>&& other) noexcept
enable_if_t<std:: is_convertible<U*, T*>::value, int> = 0> - ~ComPtr() noexcept
- Destructor.
- operator T*() const constexpr noexcept
- Returns the pointer.
- operator bool() const explicit noexcept
- Whether the pointer is assigned.
Public functions
- auto detach() -> T* noexcept
- Relinquishes ownership and returns the internal interface pointer.
- auto get() const -> T* constexpr noexcept
- Returns the pointer.
- void reset(T* ptr = nullptr) noexcept
- Releases the pointer and sets it to the specified value (or
nullptr
by default) -
auto operator=(std::
nullptr_t) -> ComPtr& noexcept nullptr
assignment- auto operator=(T* ptr) -> ComPtr& noexcept
- Pointer assignment.
- auto operator=(const ComPtr& other) -> ComPtr& noexcept
- Copy assignment.
-
template<typename U, std::auto operator=(const ComPtr<U>& other) -> ComPtr& noexcept
enable_if_t<std:: is_convertible<U*, T*>::value, int> = 0> - auto operator=(ComPtr&& other) -> ComPtr& noexcept
- Move assignment.
-
template<typename U, std::auto operator=(ComPtr<U>&& other) -> ComPtr& noexcept
enable_if_t<std:: is_convertible<U*, T*>::value, int> = 0> - auto operator*() const -> T& constexpr noexcept
- Dereferences the pointer.
- auto operator->() const -> T* constexpr noexcept
- Allows direct calls against the pointer.
- auto operator&() -> T** constexpr
- Returns the address of the internal pointer if the pointer is not initialized yet to be populated by external call.
-
template<class U>auto as(U** result) const -> HRESULT noexcept
- Tries to cast the instance to another type.
- auto as(REFIID riid, void** result) const -> HRESULT noexcept
Function documentation
template<class T>
template<class U, std:: enable_if_t<!std:: is_same<::IUnknown*, U*>::value && !std:: is_base_of<T, U>::value, int> = 0>
Death:: Containers:: ComPtr<T>:: ComPtr(U* ptr) explicit noexcept
Construct from the pointer of a related type.
template<class T>
template<typename U, std:: enable_if_t<std:: is_convertible<U*, T*>::value, int> = 0>
Death:: Containers:: ComPtr<T>:: ComPtr(const ComPtr<U>& other) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class T>
template<typename U, std:: enable_if_t<std:: is_convertible<U*, T*>::value, int> = 0>
Death:: Containers:: ComPtr<T>:: ComPtr(ComPtr<U>&& other) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class T>
template<typename U, std:: enable_if_t<std:: is_convertible<U*, T*>::value, int> = 0>
ComPtr& Death:: Containers:: ComPtr<T>:: operator=(const ComPtr<U>& other) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class T>
template<typename U, std:: enable_if_t<std:: is_convertible<U*, T*>::value, int> = 0>
ComPtr& Death:: Containers:: ComPtr<T>:: operator=(ComPtr<U>&& other) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class T>
template<class U>
HRESULT Death:: Containers:: ComPtr<T>:: as(U** result) const noexcept
Tries to cast the instance to another type.
template<class T>
HRESULT Death:: Containers:: ComPtr<T>:: as(REFIID riid,
void** result) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.