MakeAllocator Class

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

Syntax

template<
    typename T,
    bool hasWeakReferenceSupport =
          !__is_base_of(RuntimeClassFlags<InhibitWeakReference>,
                        T)
>
class MakeAllocator;

template<typename T>
class MakeAllocator<T, false>;

template<typename T>
class MakeAllocator<T, true>;

Parameters

T
A type name.

hasWeakReferenceSupport
true to allocate memory for an object that supports weak references; false to allocate memory for an object that doesn't support weak references.

Remarks

Allocates memory for an activatable class, with or without weak reference support.

Override the MakeAllocator class to implement a user-defined memory allocation model.

MakeAllocator is typically used to prevent memory leaks if an object throws during construction.

Members

Public Constructors

Name Description
MakeAllocator::MakeAllocator Initializes a new instance of the MakeAllocator class.
MakeAllocator::~MakeAllocator Deinitializes the current instance of the MakeAllocator class.

Public Methods

Name Description
MakeAllocator::Allocate Allocates memory and associates it with the current MakeAllocator object.
MakeAllocator::Detach Disassociates memory allocated by the Allocate method from the current MakeAllocator object.

Inheritance Hierarchy

MakeAllocator

Requirements

Header: implements.h

Namespace: Microsoft::WRL::Details

MakeAllocator::Allocate

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

__forceinline void* Allocate();

Return Value

If successful, a pointer to the allocated memory; otherwise, nullptr.

Remarks

Allocates memory and associates it with the current MakeAllocator object.

The size of the allocated memory is the size of the type specified by the current MakeAllocator template parameter.

A developer needs to override only the Allocate() method to implement a different memory allocation model.

MakeAllocator::Detach

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

__forceinline void Detach();

Remarks

Disassociates memory allocated by the Allocate method from the current MakeAllocator object.

If you call Detach(), you are responsible for deleting the memory provided by the Allocate method.

MakeAllocator::MakeAllocator

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

MakeAllocator();

Remarks

Initializes a new instance of the MakeAllocator class.

MakeAllocator::~MakeAllocator

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

~MakeAllocator();

Remarks

Deinitializes the current instance of the MakeAllocator class.

This destructor also deletes the underlying allocated memory if necessary.