Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://lesleylai.info/en/std-align
- struct Arena {
- void* ptr = 0;
- std::size_t size_remain = 0;
- [[nodiscard]]
- auto aligned_alloc(std::size_t alignment, std::size_t size) noexcept -> void*
- {
- void* res = std::align(alignment, size, ptr, size_remain);
- if (res) {
- ptr = static_cast<std::byte*>(res) + size;
- size_remain -= size;
- return res;
- }
- return nullptr;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement