A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
Allocator.hh
1#pragma once
2
3#include "egg/core/Heap.hh"
4
5namespace Kinoko::EGG {
6
7template <typename T>
8struct Allocator {
9 using value_type = T;
10
11 Allocator() = default;
12 template <typename U>
13 constexpr Allocator(const Allocator<U> &) noexcept {}
14
15 [[nodiscard]] T *allocate(size_t n) {
16 return static_cast<T *>(egg_alloc(n * sizeof(T), static_cast<s32>(alignof(T))));
17 }
18
19 void deallocate(T *ptr, size_t) noexcept {
20 egg_free(ptr);
21 }
22};
23
24template <typename T, typename U>
25constexpr bool operator==(const Allocator<T> &, const Allocator<U> &) noexcept {
26 return true;
27}
28
29} // namespace Kinoko::EGG
EGG core library.
Definition Allocator.hh:5