4#ifndef _Stroika_Foundation_Memory_BlockAllocated_h_
5#define _Stroika_Foundation_Memory_BlockAllocated_h_ 1
7#include "Stroika/Foundation/StroikaPreComp.h"
39#ifndef qStroika_Foundation_Memory_PreferBlockAllocation
40#define qStroika_Foundation_Memory_PreferBlockAllocation 1
43namespace Stroika::Foundation::Memory {
70 static void*
operator new (
size_t n);
71 static void*
operator new (
size_t n, int,
const char*, int);
72 static void operator delete (
void* p);
73 static void operator delete (
void* p, int,
const char*, int);
79 constexpr bool UsesBlockAllocation ();
86 template <
typename T,
typename... ARGS_TYPE>
94 static void*
operator new (
size_t n);
95 static void*
operator new (
size_t n, int,
const char*, int);
96 static void operator delete (
void* p);
97 static void operator delete (
void* p, int,
const char*, int);
129 template <
typename T,
bool andTrueCheck = true>
131 conditional_t<qStroika_Foundation_Memory_PreferBlockAllocation and andTrueCheck, BlockAllocationUseHelper<T>,
Common::Empty>;
147 template <
typename DERIVED,
typename BASE_REP,
bool andTrueCheck = true>
149 template <
typename... ARGS>
151 : BASE_REP{forward<ARGS> (args)...}
154 static void*
operator new (
size_t n)
156 if constexpr (andTrueCheck) {
160 return BASE_REP::operator
new (n);
163 static void*
operator new (
size_t n,
int a,
const char* b,
int c)
165 if constexpr (andTrueCheck) {
169 return BASE_REP::operator
new (n, a, b, c);
172 static void operator delete (
void* p)
174 if constexpr (andTrueCheck) {
178 return BASE_REP::operator
delete (p);
181 static void operator delete (
void* p,
int a,
const char* b,
int c)
183 if constexpr (andTrueCheck) {
187 return BASE_REP::operator
delete (p, a, b, c);
197 template <
typename T,
bool andTrueCheck = true>
199 conditional_t<qStroika_Foundation_Memory_PreferBlockAllocation and andTrueCheck, BlockAllocator<T>, std::allocator<T>>;
211 template <
typename T>
216 template <
typename... ARGS>
217 static T* New (ARGS&&... args);
222 static void Delete (T* p)
noexcept;
232#include "BlockAllocated.inl"
auto MakeSharedPtr(ARGS_TYPE &&... args) -> shared_ptr< T >
same as make_shared, but if type T has block allocation, then use block allocation for the 'shared pa...
conditional_t< qStroika_Foundation_Memory_PreferBlockAllocation and andTrueCheck, BlockAllocator< T >, std::allocator< T > > BlockAllocatorOrStdAllocatorAsAppropriate
for type T, either use BlockAllocator<T>, or std::allocator
conditional_t< qStroika_Foundation_Memory_PreferBlockAllocation and andTrueCheck, BlockAllocationUseHelper< T >, Common::Empty > UseBlockAllocationIfAppropriate
Use this to enable block allocation for a particular class. Beware of subclassing.
ManuallyBlockAllocated<T> is a simple wrapper on BlockAllocator<T>. If qStroika_Foundation_Memory_Pre...