static_resource::static_resource

Constructor.

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

This constructs the resource to use the specified buffer for subsequent calls to allocate. When the buffer is exhausted, allocate will throw std::bad_alloc.

Complexity

Constant.

Exception Safety

No-throw guarantee.

Parameters

Name Description

buffer

The buffer to use. Ownership is not transferred; the caller is responsible for ensuring that the lifetime of the buffer extends until the resource is destroyed.

size

The number of valid bytes pointed to by buffer.