Cogs.Foundation
Loading...
Searching...
No Matches
StdAllocator.h
Go to the documentation of this file.
1#pragma once
2
3#include "Allocator.h"
4
5namespace Cogs
6{
7 namespace Memory
8 {
9 template<typename T>
11 {
12 public:
13 using value_type = T;
14 using pointer = T *;
15 using size_type = size_t;
16
17 StdAllocator() = default;
19
20 template<typename U>
22
24 {
25 return static_cast<pointer>(allocator->allocate(n * sizeof(T)));
26 }
27
29 {
30 allocator->deallocate(p, n * sizeof(T));
31 }
32
33 private:
35
36 template<typename U> friend class StdAllocator;
37 };
38 }
39}
Base allocator implementation.
Definition: Allocator.h:30
static Allocator * defaultAllocator()
Gets the system default allocator.
Definition: Allocator.cpp:17
virtual void deallocate(void *ptr, size_t size, MemBlockType type=MemBlockType::Block)
Deallocate the memory block at the given pointer, with the given size.
Definition: Allocator.cpp:58
virtual void * allocate(size_t size, size_t alignment=0, MemBlockType type=MemBlockType::Block)
Allocate raw memory.
Definition: Allocator.cpp:29
Definition: StdAllocator.h:11
Allocator * allocator
Definition: StdAllocator.h:34
void deallocate(pointer p, size_type n)
Definition: StdAllocator.h:28
pointer allocate(size_type n)
Definition: StdAllocator.h:23
T * pointer
Definition: StdAllocator.h:14
StdAllocator(const StdAllocator< U > &other)
Definition: StdAllocator.h:21
size_t size_type
Definition: StdAllocator.h:15
StdAllocator(Allocator *allocator)
Definition: StdAllocator.h:18
T value_type
Definition: StdAllocator.h:13
Main Cogs namespace.
Definition: MortonCode.h:5