Edit

Share via


InterfaceTraits Structure

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

Syntax

template<typename I0>
struct __declspec(novtable) InterfaceTraits;

template<typename CloakedType>
struct __declspec(novtable) InterfaceTraits<
    CloakedIid<CloakedType>
>;

template<>
struct __declspec(novtable) InterfaceTraits<Nil>;

Parameters

I0
The name of an interface.

CloakedType
For RuntimeClass, Implements and ChainInterfaces, an interface that won't be in the list of supported interface IDs.

Remarks

Implements common characteristics of an interface.

The second template is a specialization for cloaked interfaces. The third template is a specialization for Nil parameters.

Members

Public Typedefs

Name Description
Base A synonym for the I0 template parameter.

Public Methods

Name Description
InterfaceTraits::CanCastTo Indicates whether the specified pointer can be cast to a pointer to Base.
InterfaceTraits::CastToBase Casts the specified pointer to a pointer to Base.
InterfaceTraits::CastToUnknown Casts the specified pointer to a pointer to IUnknown.
InterfaceTraits::FillArrayWithIid Assigns the interface ID of Base to the array element specified by the index argument.
InterfaceTraits::Verify Verifies that Base is properly derived.

Public Constants

Name Description
InterfaceTraits::IidCount Holds the number of interface IDs associated with the current InterfaceTraits object.

Inheritance Hierarchy

InterfaceTraits

Requirements

Header: implements.h

Namespace: Microsoft::WRL::Details

InterfaceTraits::CanCastTo

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

template<typename T>
static __forceinline bool CanCastTo(
   _In_ T* ptr,
   REFIID riid,
   _Deref_out_ void **ppv
);

Parameters

ptr
The name of a pointer to a type.

riid
The interface ID of Base.

ppv
If this operation is successful, ppv points to the interface specified by Base. Otherwise, ppv is set to nullptr.

Return Value

true if this operation is successful and ptr is cast to a pointer to Base; otherwise, false.

Remarks

Indicates whether the specified pointer can be cast to a pointer to Base.

For more information about Base, see the Public Typedefs section.

InterfaceTraits::CastToBase

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

template<typename T>
static __forceinline Base* CastToBase(
   _In_ T* ptr
);

Parameters

T
The type of parameter ptr.

ptr
Pointer to a type T.

Return Value

A pointer to Base.

Remarks

Casts the specified pointer to a pointer to Base.

For more information about Base, see the Public Typedefs section.

InterfaceTraits::CastToUnknown

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

template<typename T>
static __forceinline IUnknown* CastToUnknown(
   _In_ T* ptr
);

Parameters

T
The type of parameter ptr.

ptr
Pointer to type T.

Return Value

Pointer to the IUnknown from which Base is derived.

Remarks

Casts the specified pointer to a pointer to IUnknown.

For more information about Base, see the Public Typedefs section.

InterfaceTraits::FillArrayWithIid

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

__forceinline static void FillArrayWithIid(
   _Inout_ unsigned long &index,
   _In_ IID* iids
);

Parameters

index
Pointer to a field that contains a zero-based index value.

iids
An array of interface IDs.

Remarks

Assigns the interface ID of Base to the array element specified by the index argument.

Contrary to the name of this API, only one array element is modified; not the entire array.

For more information about Base, see the Public Typedefs section.

InterfaceTraits::IidCount

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

static const unsigned long IidCount = 1;

Remarks

Holds the number of interface IDs associated with the current InterfaceTraits object.

InterfaceTraits::Verify

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

__forceinline static void Verify();

Remarks

Verifies that Base is properly derived.

For more information about Base, see the Public Typedefs section.