Go to the documentation of this file.
14 #include <type_traits>
28 template <
typename Resource,
typename T,
typename DefaultResource =
void>
43 template <
typename D =
void,
typename = std::enable_if_t<std::is_invocable_r_v<Resource*, DefaultResource>, D>>
54 return reinterpret_cast<T*
>(
m_resource->template allocate<alignof( T )>(
n *
sizeof( T ) ) );
60 m_resource->deallocate(
reinterpret_cast<std::byte*
>( p ),
n *
sizeof( T ) );
79 template <
typename,
typename,
typename>
85 template <
typename Resource,
typename T,
typename U,
typename DefaultResource>
88 return !( lhs == rhs );
constexpr bool operator!=(Arena< Resource, T, DefaultResource > const &lhs, Arena< Resource, U, DefaultResource > const &rhs)
void deallocate(T *p, std::size_t n) noexcept
Deallocate storage for n objects.
constexpr Arena(Resource *resource) noexcept
Construct an allocator using the given memory resource, which must be valid.
Arena()
Construct an allocator using the resource provided by DefaultResource.
constexpr Arena(Arena< Resource, U, DefaultResource > const &other) noexcept
Converting copy constructor, rebinding U -> T.
Resource * resource() const noexcept
Return a pointer to the memory resource.
Custom allocator holding a pointer to a generic memory resource.
constexpr friend bool operator==(Arena const &lhs, Arena< Resource, U, DefaultResource > const &rhs)
T * allocate(std::size_t n)
Allocate storage for n objects.