libcaramel
caramel::global_resource Class Reference

Simple allocator for global allocations. More...

#include <global_resource.hpp>

Inheritance diagram for caramel::global_resource:
caramel::memory_resource

Public Types

using pointer = typename memory_resource::pointer
 
using const_pointer = typename memory_resource::const_pointer
 
- Public Types inherited from caramel::memory_resource
using pointer = void *
 alias for ease of naming
 
using const_pointer = const void *
 alias for ease of naming
 

Public Member Functions

auto allocate (count_t bytes, align_t alignment) noexcept -> pointer override
 Pure virtual function for a common allocation interface. More...
 
void deallocate (gsl::not_null< pointer > ptr, count_t bytes, align_t alignment) noexcept override
 Pure virtual function for a common deallocation interface. More...
 
auto is_equal (const memory_resource &other) const noexcept -> bool override
 Pure virtual function for a common comparison interface. More...
 
- Public Member Functions inherited from caramel::memory_resource
 memory_resource (const memory_resource &) noexcept=default
 
 memory_resource (memory_resource &&) noexcept=default
 
auto operator= (const memory_resource &) noexcept -> memory_resource &=default
 
auto operator= (memory_resource &&) noexcept -> memory_resource &=default
 
auto operator== (const memory_resource &rhs) const -> bool
 Check if two memory_resources are equal. More...
 

Detailed Description

Simple allocator for global allocations.

Member Function Documentation

◆ allocate()

auto caramel::global_resource::allocate ( count_t  bytes,
align_t  alignment 
) -> pointer
overridevirtualnoexcept

Pure virtual function for a common allocation interface.

Precondition
bytes >= 0, otherwise UB
alignment >= 0, otherwise UB
Parameters
[in]bytesThe size of the allocation in bytes
[in]alignmentThe alignment of the allocation in bytes
Returns
A valid pointer to a memory chunk or nullptr if the allocation failed

Implements caramel::memory_resource.

◆ deallocate()

void caramel::global_resource::deallocate ( gsl::not_null< pointer >  ptr,
count_t  bytes,
align_t  alignment 
)
overridevirtualnoexcept

Pure virtual function for a common deallocation interface.

Precondition
bytes >= 0, otherwise UB
alignment >= 0, otherwise UB
Parameters
[in]ptrThe starting location of the memory chunk
[in]bytesThe size of the allocation in bytes
[in]alignmentThe alignment of the allocation in bytes

Implements caramel::memory_resource.

◆ is_equal()

auto caramel::global_resource::is_equal ( const memory_resource other) const -> bool
overridevirtualnoexcept

Pure virtual function for a common comparison interface.

Parameters
[in]otherThe memory_resource to compare with.
Returns
True if both memory_resources are considered equal, otherwise false

Implements caramel::memory_resource.


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