16#include "pw_allocator/allocator.h"
17#include "pw_allocator/config.h"
18#include "pw_status/status_with_size.h"
20#if __has_include(<memory_resource>)
21#include <memory_resource>
23namespace pmr = ::std::pmr;
26#elif __has_include(<experimental/memory_resource>)
27#include <experimental/memory_resource>
29namespace pmr = ::std::experimental::pmr;
33#error "<memory_resource> is required to use this header!"
36namespace pw::allocator {
53 Allocator& allocator() {
return *allocator_; }
56 friend class ::pw::allocator::PmrAllocator;
57 void set_allocator(
Allocator& allocator) { allocator_ = &allocator; }
59 void* do_allocate(
size_t bytes,
size_t alignment)
override;
60 void do_deallocate(
void* p,
size_t bytes,
size_t alignment)
override;
62 const pw::pmr::memory_resource& other)
const noexcept override;
76class PmrAllocator final :
public pw::pmr::polymorphic_allocator<std::byte> {
78 using Base = pw::pmr::polymorphic_allocator<std::byte>;
81 memory_resource_.set_allocator(allocator);
84 Allocator& allocator() {
return memory_resource_.allocator(); }
Definition: allocator.h:34
Definition: pmr_allocator.h:76
Definition: pmr_allocator.h:49
Provides basic helpers for reading and writing UTF-8 encoded strings.
Definition: alignment.h:27