WinStd
Additional templates and function helpers for Microsoft Windows using Standard C++ classes
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
winstd::heap_allocator< _Ty > Class Template Reference

HeapAlloc allocator. More...

#include <WinStd/Win.h>

Classes

struct  rebind
 A structure that enables an allocator for objects of one type to allocate storage for objects of another type. More...
 

Public Types

typedef _Ty value_type
 A type that is managed by the allocator.
 
typedef _Ty * pointer
 A type that provides a pointer to the type of object managed by the allocator.
 
typedef _Ty & reference
 A type that provides a reference to the type of object managed by the allocator.
 
typedef const _Ty * const_pointer
 A type that provides a constant pointer to the type of object managed by the allocator.
 
typedef const _Ty & const_reference
 A type that provides a constant reference to type of object managed by the allocator.
 
typedef SIZE_T size_type
 An unsigned integral type that can represent the length of any sequence that an object of template class heap_allocator can allocate.
 
typedef ptrdiff_t difference_type
 A signed integral type that can represent the difference between values of pointers to the type of object managed by the allocator.
 

Public Member Functions

 heap_allocator (1 HANDLE heap)
 Constructs allocator. More...
 
template<class _Other >
 heap_allocator (1 const heap_allocator< _Other > &other)
 Constructs allocator from another type. More...
 
pointer allocate (1 size_type count)
 Allocates a new memory block. More...
 
void deallocate (1 pointer ptr, 1 size_type size)
 Frees memory block. More...
 
void construct (1 pointer ptr, 1 const _Ty &val)
 Calls copying constructor for the element. More...
 
void construct (1 pointer ptr, 1 _Ty &&val)
 Calls moving constructor for the element. More...
 
void destroy (1 pointer ptr)
 Calls destructor for the element. More...
 
size_type max_size () const
 Returns maximum memory block size.
 

Public Attributes

HANDLE m_heap
 Heap handle.
 

Detailed Description

template<class _Ty>
class winstd::heap_allocator< _Ty >

HeapAlloc allocator.

Constructor & Destructor Documentation

◆ heap_allocator() [1/2]

template<class _Ty >
winstd::heap_allocator< _Ty >::heap_allocator ( 1 HANDLE  heap)
inline

Constructs allocator.

Parameters
[in]heapHandle to existing heap

◆ heap_allocator() [2/2]

template<class _Ty >
template<class _Other >
winstd::heap_allocator< _Ty >::heap_allocator ( 1 const heap_allocator< _Other > &  other)
inline

Constructs allocator from another type.

Parameters
[in]otherAnother allocator of the heap_allocator kind

Member Function Documentation

◆ allocate()

template<class _Ty >
pointer winstd::heap_allocator< _Ty >::allocate ( 1 size_type  count)
inline

Allocates a new memory block.

Parameters
[in]countNumber of elements
Returns
Pointer to new memory block

◆ construct() [1/2]

template<class _Ty >
void winstd::heap_allocator< _Ty >::construct ( 1 pointer  ptr,
1 _Ty &&  val 
)
inline

Calls moving constructor for the element.

Parameters
[in]ptrPointer to memory block
[in]valSource element

◆ construct() [2/2]

template<class _Ty >
void winstd::heap_allocator< _Ty >::construct ( 1 pointer  ptr,
1 const _Ty &  val 
)
inline

Calls copying constructor for the element.

Parameters
[in]ptrPointer to memory block
[in]valSource element

◆ deallocate()

template<class _Ty >
void winstd::heap_allocator< _Ty >::deallocate ( 1 pointer  ptr,
1 size_type  size 
)
inline

Frees memory block.

Parameters
[in]ptrPointer to memory block
[in]sizeSize of memory block (in bytes)

◆ destroy()

template<class _Ty >
void winstd::heap_allocator< _Ty >::destroy ( 1 pointer  ptr)
inline

Calls destructor for the element.

Parameters
[in]ptrPointer to memory block

The documentation for this class was generated from the following file: