HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
scoped_buffer.hpp
1// Copyright Take Vos 2021.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5
6#pragma once
7
8#include <memory_resource>
9#include <array>
10
11namespace hi::inline v1::pmr {
12
15template<std::size_t Size, typename T = std::byte>
17public:
18 using value_type = T;
19 using allocator_type = std::pmr::polymorphic_allocator<value_type>;
20
21 constexpr scoped_buffer() noexcept : _buffer(), _mbr(_buffer.data(), _buffer.size()), _pa(&_mbr) {}
22
23 constexpr allocator_type &allocator() noexcept
24 {
25 return _pa;
26 }
27
28private:
30 std::pmr::monotonic_buffer_resource _mbr;
31 allocator_type _pa;
32};
33
34} // namespace hi::inline v1::pmr
DOXYGEN BUG.
Definition algorithm.hpp:15
A buffer with an attached memory allocator.
Definition scoped_buffer.hpp:16