Edit

Share via


ComPtrRef Class

Supports the WRL infrastructure and is not intended to be used directly from your code.

Syntax

template <typename T>
class ComPtrRef : public ComPtrRefBase<T>;

Parameters

T
A ComPtr<T> type or a type derived from it, not merely the interface represented by the ComPtr.

Remarks

Represents a reference to an object of type ComPtr<T>.

Members

Public Constructors

Name Description
ComPtrRef::ComPtrRef Initializes a new instance of the ComPtrRef class from the specified pointer to another ComPtrRef object.

Public Methods

Name Description
ComPtrRef::GetAddressOf Retrieves the address of a pointer to the interface represented by the current ComPtrRef object.
ComPtrRef::ReleaseAndGetAddressOf Deletes the current ComPtrRef object and returns a pointer-to-a-pointer to the interface that was represented by the ComPtrRef object.

Public Operators

Name Description
ComPtrRef::operator InterfaceType** Deletes the current ComPtrRef object and returns a pointer-to-a-pointer to the interface that was represented by the ComPtrRef object.
ComPtrRef::operator T* Returns the value of the ptr_ data member of the current ComPtrRef object.
ComPtrRef::operator void** Deletes the current ComPtrRef object, casts the pointer to the interface that was represented by the ComPtrRef object as a pointer-to-pointer-to void, and then returns the cast pointer.
ComPtrRef::operator* Retrieves the pointer to the interface represented by the current ComPtrRef object.
ComPtrRef::operator== Indicates whether two ComPtrRef objects are equal.
ComPtrRef::operator!= Indicates whether two ComPtrRef objects are not equal.

Inheritance Hierarchy

ComPtrRefBase

ComPtrRef

Requirements

Header: client.h

Namespace: Microsoft::WRL::Details

ComPtrRef::ComPtrRef

Supports the WRL infrastructure and is not intended to be used directly from your code.

ComPtrRef(
   _In_opt_ T* ptr
);

Parameters

ptr
The underlying value of another ComPtrRef object.

Remarks

Initializes a new instance of the ComPtrRef class from the specified pointer to another ComPtrRef object.

ComPtrRef::GetAddressOf

Supports the WRL infrastructure and is not intended to be used directly from your code.

InterfaceType* const * GetAddressOf() const;

Return Value

Address of a pointer to the interface represented by the current ComPtrRef object.

Remarks

Retrieves the address of a pointer to the interface represented by the current ComPtrRef object.

ComPtrRef::operator==

Supports the WRL infrastructure and is not intended to be used directly from your code.

bool operator==(
   const Details::ComPtrRef<ComPtr<T>>& a,
   const Details::ComPtrRef<ComPtr<U>>& b
);

bool operator==(
   const Details::ComPtrRef<ComPtr<T>>& a,
   decltype(__nullptr)
);

bool operator==(
   decltype(__nullptr),
   const Details::ComPtrRef<ComPtr<T>>& a
);

bool operator==(
   const Details::ComPtrRef<ComPtr<T>>& a,
   void* b
);

bool operator==(
   void* b,
   const Details::ComPtrRef<ComPtr<T>>& a
);

Parameters

a
A reference to a ComPtrRef object.

b
A reference to another ComPtrRef object, or a pointer to an anonymous type (void*).

Return Value

The first operator yields true if object a is equal to object b; otherwise, false.

The second and third operators yield true if object a is equal to nullptr; otherwise, false.

The fourth and fifth operators yield true if object a is equal to object b; otherwise, false.

Remarks

Indicates whether two ComPtrRef objects are equal.

ComPtrRef::operator!=

Supports the WRL infrastructure and is not intended to be used directly from your code.

bool operator!=(
   const Details::ComPtrRef<ComPtr<T>>& a,
   const Details::ComPtrRef<ComPtr<U>>& b
);

bool operator!=(
   const Details::ComPtrRef<ComPtr<T>>& a,
   decltype(__nullptr)
);

bool operator!=(
   decltype(__nullptr),
   const Details::ComPtrRef<ComPtr<T>>& a
);

bool operator!=(
   const Details::ComPtrRef<ComPtr<T>>& a,
   void* b
);

bool operator!=(
   void* b,
   const Details::ComPtrRef<ComPtr<T>>& a
);

Parameters

a
A reference to a ComPtrRef object.

b
A reference to another ComPtrRef object, or a pointer to an anonymous object (void*).

Return Value

The first operator yields true if object a is not equal to object b; otherwise, false.

The second and third operators yield true if object a is not equal to nullptr; otherwise, false.

The fourth and fifth operators yield true if object a is not equal to object b; otherwise, false.

Remarks

Indicates whether two ComPtrRef objects are not equal.

ComPtrRef::operator InterfaceType**

Supports the WRL infrastructure and is not intended to be used directly from your code.

operator InterfaceType**();

Remarks

Deletes the current ComPtrRef object and returns a pointer-to-a-pointer to the interface that was represented by the ComPtrRef object.

ComPtrRef::operator*

Supports the WRL infrastructure and is not intended to be used directly from your code.

InterfaceType* operator *();

Return Value

Pointer to the interface represented by the current ComPtrRef object.

Remarks

Retrieves the pointer to the interface represented by the current ComPtrRef object.

ComPtrRef::operator T*

Supports the WRL infrastructure and is not intended to be used directly from your code.

operator T*();

Remarks

Returns the value of the ptr_ data member of the current ComPtrRef object.

ComPtrRef::operator void**

Supports the WRL infrastructure and is not intended to be used directly from your code.

operator void**() const;

Remarks

Deletes the current ComPtrRef object, casts the pointer to the interface that was represented by the ComPtrRef object as a pointer-to-pointer-to void, and then returns the cast pointer.

ComPtrRef::ReleaseAndGetAddressOf

Supports the WRL infrastructure and is not intended to be used directly from your code.

InterfaceType** ReleaseAndGetAddressOf();

Return Value

Pointer to the interface that was represented by the deleted ComPtrRef object.

Remarks

Deletes the current ComPtrRef object and returns a pointer-to-a-pointer to the interface that was represented by the ComPtrRef object.