Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
STLLocalAllocator< T, N > Class Template Reference

STL allocator that keeps N elements in a local buffer before falling back to regular allocations. More...

#include <STLLocalAllocator.h>

Inheritance diagram for STLLocalAllocator< T, N >:
STLAllocator< T >

Classes

struct  rebind
 Converting to allocator for other type. More...
 

Public Types

using value_type = T
 General properties.
 
using pointer = T *
 
using const_pointer = const T *
 
using reference = T &
 
using const_reference = const T &
 
using size_type = size_t
 
using difference_type = ptrdiff_t
 
using is_always_equal = std::false_type
 The allocator is not stateless (has local buffer)
 
using propagate_on_container_copy_assignment = std::false_type
 We cannot copy, move or swap allocators.
 
using propagate_on_container_move_assignment = std::false_type
 
using propagate_on_container_swap = std::false_type
 

Public Member Functions

 STLLocalAllocator ()=default
 Constructor.
 
 STLLocalAllocator (const STLLocalAllocator &)=delete
 
 STLLocalAllocator (STLLocalAllocator &&)=delete
 
STLLocalAllocatoroperator= (const STLLocalAllocator &)=delete
 
template<class T2 >
 STLLocalAllocator (const STLLocalAllocator< T2, N > &)
 
bool is_local (const_pointer inPointer) const
 Check if inPointer is in the local buffer.
 
pointer allocate (size_type inN)
 Allocate memory.
 
pointer reallocate (pointer inOldPointer, size_type inOldSize, size_type inNewSize)
 Reallocate memory.
 
void deallocate (pointer inPointer, size_type inN)
 Free memory.
 
bool operator== (const STLLocalAllocator< T, N > &inRHS) const
 Allocators are not-stateless, assume if allocator address matches that the allocators are the same.
 
bool operator!= (const STLLocalAllocator< T, N > &inRHS) const
 

Static Public Attributes

static constexpr bool has_reallocate = true
 Always implements a reallocate function as we can often reallocate in place.
 

Detailed Description

template<typename T, size_t N>
class STLLocalAllocator< T, N >

STL allocator that keeps N elements in a local buffer before falling back to regular allocations.

Member Typedef Documentation

◆ const_pointer

template<typename T , size_t N>
using STLLocalAllocator< T, N >::const_pointer = const T *

◆ const_reference

template<typename T , size_t N>
using STLLocalAllocator< T, N >::const_reference = const T &

◆ difference_type

template<typename T , size_t N>
using STLLocalAllocator< T, N >::difference_type = ptrdiff_t

◆ is_always_equal

template<typename T , size_t N>
using STLLocalAllocator< T, N >::is_always_equal = std::false_type

The allocator is not stateless (has local buffer)

◆ pointer

template<typename T , size_t N>
using STLLocalAllocator< T, N >::pointer = T *

◆ propagate_on_container_copy_assignment

template<typename T , size_t N>
using STLLocalAllocator< T, N >::propagate_on_container_copy_assignment = std::false_type

We cannot copy, move or swap allocators.

◆ propagate_on_container_move_assignment

template<typename T , size_t N>
using STLLocalAllocator< T, N >::propagate_on_container_move_assignment = std::false_type

◆ propagate_on_container_swap

template<typename T , size_t N>
using STLLocalAllocator< T, N >::propagate_on_container_swap = std::false_type

◆ reference

template<typename T , size_t N>
using STLLocalAllocator< T, N >::reference = T &

◆ size_type

template<typename T , size_t N>
using STLLocalAllocator< T, N >::size_type = size_t

◆ value_type

template<typename T , size_t N>
using STLLocalAllocator< T, N >::value_type = T

General properties.

Constructor & Destructor Documentation

◆ STLLocalAllocator() [1/4]

template<typename T , size_t N>
STLLocalAllocator< T, N >::STLLocalAllocator ( )
default

Constructor.

◆ STLLocalAllocator() [2/4]

template<typename T , size_t N>
STLLocalAllocator< T, N >::STLLocalAllocator ( const STLLocalAllocator< T, N > &  )
delete

◆ STLLocalAllocator() [3/4]

template<typename T , size_t N>
STLLocalAllocator< T, N >::STLLocalAllocator ( STLLocalAllocator< T, N > &&  )
delete

◆ STLLocalAllocator() [4/4]

template<typename T , size_t N>
template<class T2 >
STLLocalAllocator< T, N >::STLLocalAllocator ( const STLLocalAllocator< T2, N > &  )
inline

Constructor used when rebinding to another type. This expects the allocator to use the original memory pool from the first allocator, but in our case we cannot use the local buffer of the original allocator as it has different size and alignment rules. To solve this we make this allocator fall back to the heap immediately.

Member Function Documentation

◆ allocate()

template<typename T , size_t N>
pointer STLLocalAllocator< T, N >::allocate ( size_type  inN)
inline

Allocate memory.

◆ deallocate()

template<typename T , size_t N>
void STLLocalAllocator< T, N >::deallocate ( pointer  inPointer,
size_type  inN 
)
inline

Free memory.

◆ is_local()

template<typename T , size_t N>
bool STLLocalAllocator< T, N >::is_local ( const_pointer  inPointer) const
inline

Check if inPointer is in the local buffer.

◆ operator!=()

template<typename T , size_t N>
bool STLLocalAllocator< T, N >::operator!= ( const STLLocalAllocator< T, N > &  inRHS) const
inline

◆ operator=()

template<typename T , size_t N>
STLLocalAllocator & STLLocalAllocator< T, N >::operator= ( const STLLocalAllocator< T, N > &  )
delete

◆ operator==()

template<typename T , size_t N>
bool STLLocalAllocator< T, N >::operator== ( const STLLocalAllocator< T, N > &  inRHS) const
inline

Allocators are not-stateless, assume if allocator address matches that the allocators are the same.

◆ reallocate()

template<typename T , size_t N>
pointer STLLocalAllocator< T, N >::reallocate ( pointer  inOldPointer,
size_type  inOldSize,
size_type  inNewSize 
)
inline

Reallocate memory.

Member Data Documentation

◆ has_reallocate

template<typename T , size_t N>
constexpr bool STLLocalAllocator< T, N >::has_reallocate = true
staticconstexpr

Always implements a reallocate function as we can often reallocate in place.


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