HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
scoped_buffer.hpp
1
2
3#pragma once
4
5#include <memory_resource>
6#include <array>
7
8namespace hi::inline v1::pmr {
9
12template<std::size_t Size, typename T = std::byte>
14public:
15 using value_type = T;
16 using allocator_type = std::pmr::polymorphic_allocator<value_type>;
17
18 constexpr scoped_buffer() noexcept : _buffer(), _mbr(_buffer.data(), _buffer.size()), _pa(&_mbr) {}
19
20 constexpr allocator_type &allocator() noexcept
21 {
22 return _pa;
23 }
24
25private:
27 std::pmr::monotonic_buffer_resource _mbr;
28 allocator_type _pa;
29};
30
31} // namespace hi::inline v1::pmr
A buffer with an attached memory allocator.
Definition scoped_buffer.hpp:13