Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::internal::AllocatorWithAlignment< T, alignment_bytes, misalignment_bytes > Struct Template Reference

#include <aligned_memory_internal.h>

Inheritance diagram for operations_research::internal::AllocatorWithAlignment< T, alignment_bytes, misalignment_bytes >:

Classes

struct  rebind
 

Public Member Functions

T * allocate (size_t num_items)
 
T * allocate (size_t n, const void *)
 A version of allocate() that takes a hint; we just ignore the hint.
 
void deallocate (T *p, size_t)
 Frees memory allocated by allocate().
 

Detailed Description

template<typename T, size_t alignment_bytes, size_t misalignment_bytes>
struct operations_research::internal::AllocatorWithAlignment< T, alignment_bytes, misalignment_bytes >

Definition at line 29 of file aligned_memory_internal.h.

Member Function Documentation

◆ allocate() [1/2]

template<typename T , size_t alignment_bytes, size_t misalignment_bytes>
T * operations_research::internal::AllocatorWithAlignment< T, alignment_bytes, misalignment_bytes >::allocate ( size_t n,
const void *  )
inline

A version of allocate() that takes a hint; we just ignore the hint.

Definition at line 57 of file aligned_memory_internal.h.

◆ allocate() [2/2]

template<typename T , size_t alignment_bytes, size_t misalignment_bytes>
T * operations_research::internal::AllocatorWithAlignment< T, alignment_bytes, misalignment_bytes >::allocate ( size_t num_items)
inline

Allocates memory for num_items items of type T. The memory must be freed using deallocate(); using it with free() or delete might cause unexpected behavior when misalignment is used.

Having misalignment_bytes >= alignment_bytes is useless, because all misalignments are equivalent modulo alignment_bytes. Disallowing it allows us to simplify the code below.

std::aligned_alloc(alignment, size) requires that size is a multiple of alignment, and might return a nullptr when this is not respected. To be safe, we round the number of bytes up to alignment.

Definition at line 33 of file aligned_memory_internal.h.

◆ deallocate()

template<typename T , size_t alignment_bytes, size_t misalignment_bytes>
void operations_research::internal::AllocatorWithAlignment< T, alignment_bytes, misalignment_bytes >::deallocate ( T * p,
size_t  )
inline

Frees memory allocated by allocate().

Definition at line 60 of file aligned_memory_internal.h.


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