IceShard 1
A personal game engine project, with development focused on 2D/2.5D games.
Loading...
Searching...
No Matches
mem_allocator_proxy.hxx
Go to the documentation of this file.
1
3
4#pragma once
6
7namespace ice
8{
9
10 struct ProxyAllocator final : public ice::Allocator
11 {
12 inline ProxyAllocator(
14 std::source_location = std::source_location::current()
15 ) noexcept;
16
17 inline ProxyAllocator(
19 std::string_view name,
20 std::source_location = std::source_location::current()
21 ) noexcept;
22
23 inline auto backing_allocator() noexcept -> ice::Allocator&;
24
25 protected:
26 inline auto do_allocate(ice::AllocRequest request) noexcept -> ice::AllocResult override;
27 inline void do_deallocate(void* pointer) noexcept override;
28
29 private:
30 ice::Allocator& _backing_alloc;
31 };
32
35 std::source_location src_loc
36 ) noexcept
38 , _backing_alloc{ backing_allocator }
39 {
40 }
41
44 std::string_view name,
45 std::source_location src_loc
46 ) noexcept
47 : ice::Allocator{ src_loc, backing_allocator, name }
48 , _backing_alloc{ backing_allocator }
49 {
50 }
51
53 {
54 return _backing_alloc;
55 }
56
58 {
59 return _backing_alloc.allocate(request);
60 }
61
62 inline void ProxyAllocator::do_deallocate(void* pointer) noexcept
63 {
64 _backing_alloc.deallocate(pointer);
65 }
66
67} // namespace ice
SPDX-License-Identifier: MIT.
Definition array.hxx:12
ice::AllocatorBase< ice::build::is_debug||ice::build::is_develop > Allocator
Definition mem_types.hxx:25
Definition mem.hxx:16
Definition mem.hxx:44
auto do_allocate(ice::AllocRequest request) noexcept -> ice::AllocResult override
Definition mem_allocator_proxy.hxx:57
void do_deallocate(void *pointer) noexcept override
Definition mem_allocator_proxy.hxx:62
ProxyAllocator(ice::Allocator &backing_allocator, std::source_location=std::source_location::current()) noexcept
Definition mem_allocator_proxy.hxx:33
auto backing_allocator() noexcept -> ice::Allocator &
Definition mem_allocator_proxy.hxx:52