16#if __has_include(<memory_resource>)
17#include <memory_resource>
19namespace pmr = ::std::pmr;
22#elif __has_include(<experimental/memory_resource>)
23#include <experimental/memory_resource>
25namespace pmr = ::std::experimental::pmr;
29#error "<memory_resource> is required to use this header!"
32#include "pw_status/status_with_size.h"
56 Allocator& allocator() {
return *allocator_; }
59 friend class ::pw::allocator::AsPmrAllocator;
60 void set_allocator(
Allocator& allocator) { allocator_ = &allocator; }
62 void* do_allocate(
size_t bytes,
size_t alignment)
override;
63 void do_deallocate(
void* p,
size_t bytes,
size_t alignment)
override;
65 const pw::pmr::memory_resource& other)
const noexcept override;
79class AsPmrAllocator final :
public pw::pmr::polymorphic_allocator<std::byte> {
81 using Base = pw::pmr::polymorphic_allocator<std::byte>;
84 memory_resource_.set_allocator(allocator);
87 Allocator& allocator() {
return memory_resource_.allocator(); }
Definition: allocator.h:32
Definition: as_pmr_allocator.h:79
Definition: as_pmr_allocator.h:52
Provides basic helpers for reading and writing UTF-8 encoded strings.
Definition: alignment.h:27