| Home | Libraries | People | FAQ | More

#### read_size_or_throw

Returns a natural read size or throw if the buffer is full.

##### Synopsis

Defined in header `<boost/beast/core/read_size.hpp>`

    template<
        class DynamicBuffer>
    std::size_t
    read_size_or_throw(
        DynamicBuffer& buffer,
        std::size_t max_size);

##### Description

This function inspects the capacity, size, and maximum size of the dynamic buffer. Then it computes a natural read size given the passed-in upper limit. It favors a read size that does not require a reallocation, subject to a reasonable minimum to avoid tiny reads.

##### Parameters

Name | Description
--- | ---
`buffer` | The dynamic buffer to inspect.
`max_size` | An upper limit on the returned value.

##### Exceptions

Type | Thrown On
--- | ---
`std::length_error` | if `max_size > 0` and the buffer is full.

Convenience header `<boost/beast/core.hpp>`