The Alloc class provides a set of static functions for allocating templated memory via malloc() and associated functions.
More...
#include <Alloc.hpp>
|
| template<typename T > |
| static T * | uninitialized (size_t const num) |
| | Allocate a block of uninitialized memory that can be free'd with a call to Alloc::free(). If the amount of memory requested is 0, then nullptr will be returned. More...
|
| |
| template<typename T > |
| static T * | initialized (size_t const num, T const val=static_cast< T >(0)) |
| | Allocate and initialize a block of memory to a constant value. More...
|
| |
| template<typename T > |
| static T * | duplicate (T const *const ptr, size_t const num) |
| | Allocate and and fill a block of memory from another block. More...
|
| |
| template<typename T > |
| static void | resize (T **const ptr, size_t const num) |
| | Resize an allocation. More...
|
| |
| template<typename T > |
| static void | free (T *const ptr) noexcept |
| | Free a block of memory allocated with this class. More...
|
| |
The Alloc class provides a set of static functions for allocating templated memory via malloc() and associated functions.
◆ duplicate()
template<typename T >
| static T* sl::Alloc::duplicate |
( |
T const *const |
ptr, |
|
|
size_t const |
num |
|
) |
| |
|
inlinestatic |
Allocate and and fill a block of memory from another block.
- Template Parameters
-
| T | The type of memory to allocate. |
- Parameters
-
| ptr | The other bock of memory. |
| num | The size of the other block (in terms of elements). |
- Returns
- The memory.
- Exceptions
-
| std::bad_alloc | If the amount of memory fails to get allocated. |
◆ free()
template<typename T >
| static void sl::Alloc::free |
( |
T *const |
ptr | ) |
|
|
inlinestaticnoexcept |
Free a block of memory allocated with this class.
- Template Parameters
-
| T | The type of memory to free. |
- Parameters
-
| ptr | A pointer to the memory to free. |
◆ initialized()
template<typename T >
| static T* sl::Alloc::initialized |
( |
size_t const |
num, |
|
|
T const |
val = static_cast<T>(0) |
|
) |
| |
|
inlinestatic |
Allocate and initialize a block of memory to a constant value.
- Template Parameters
-
| T | The type of memory to allocate. |
- Parameters
-
| num | The number of elements. |
| val | The value to initialize elements to. |
- Returns
- The memory.
- Exceptions
-
| std::bad_alloc | If the amount of memory fails to get allocated. |
◆ resize()
template<typename T >
| static void sl::Alloc::resize |
( |
T **const |
ptr, |
|
|
size_t const |
num |
|
) |
| |
|
inlinestatic |
Resize an allocation.
- Template Parameters
-
- Parameters
-
| ptr | The pointer to resize. |
| num | The number of elements. |
- Exceptions
-
| std::bad_alloc | If the amount of memory fails to get allocated. |
◆ uninitialized()
template<typename T >
| static T* sl::Alloc::uninitialized |
( |
size_t const |
num | ) |
|
|
inlinestatic |
Allocate a block of uninitialized memory that can be free'd with a call to Alloc::free(). If the amount of memory requested is 0, then nullptr will be returned.
- Template Parameters
-
| T | The type of memory to allocate. |
- Parameters
-
| num | The number of elements. |
- Returns
- The memory.
- Exceptions
-
| std::bad_alloc | If the amount of memory fails to get allocated. |
The documentation for this class was generated from the following file: