static_resource::static_resource
Constructors.
Synopsis
static_resource(
unsigned char* buffer,
std::size_t size) noexcept; (1)
static_resource(
std::byte* buffer,
std::size_t size) noexcept; (2)
template<
std::size_t N>
explicit
static_resource(
unsigned char (&buffer) [N]) noexcept; (3)
template<
std::size_t N>
explicit
static_resource(
std::byte (&buffer) [N]) noexcept; (4)
static_resource(
static_resource const&) = delete; (5)
Description
These construct the resource to use the specified buffer for subsequent calls to allocate. When the buffer is exhausted, allocate will throw std::bad_alloc
.
Ownership of buffer
is not transferred; the caller is responsible for ensuring that its lifetime extends until the resource is destroyed.
Overload (5) is the copy constructor. The type is neither copyable nor movable, so this overload is deleted.
Complexity
Constant.
Exception Safety
No-throw guarantee.
Template Parameters
Type | Description |
---|---|
|
The size of |
Parameters
Name | Description |
---|---|
|
The buffer to use. |
|
The number of valid bytes pointed to by |