[/
    Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)

    Distributed under the Boost Software License, Version 1.0. (See accompanying
    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

    Official repository: https://github.com/boostorg/beast
]

[section:DynamicBuffer 动态缓冲区]

动态缓冲区用于封装可根据需要自动调整大小的内存存储。该内存被划分为一个输入序列和一个输出序列。这些内存区域属于动态缓冲区的内部，但提供对元素的直接访问，以便将其高效用于 I/O 操作，例如套接字的发送或接收操作。写入动态缓冲区对象输出序列的数据，将被追加到该对象的输入序列中。

该概念的接口旨在支持以下实现策略：

* 使用单个连续字节数组，并根据需要对该数组进行重新分配
  accommodate changes in the size of the octet sequence. This is the
  implementation approach currently offered by __flat_buffer__.

* 使用一个或多个字节数组的序列，其中每个数组的大小均相同
  size. Additional octet array objects are appended to the sequence to
  accommodate changes in the size of the octet sequence.

* 使用一个或多个大小可变的字节数组序列。额外的字节
  array objects are appended to the sequence to accommodate changes in the
  size of the character sequence. This is the implementation approach
  currently offered by __multi_buffer__.

[heading 关联于]

* `boost::asio::is_dynamic_buffer`
* __ConstBufferSequence__
* __MutableBufferSequence__

[heading 要求]

* `D`：用于表示一个动态缓冲区类。
* `a`：用于表示一个 `D` 类型的值。
* `c`：用于表示一个 `D` 类型的值（可能为 const）。
* `n`：用于表示一个 `std::size_t` 类型的值。
* `T`：用于表示一个满足 __ConstBufferSequence__ 要求的类型。
* `U`：用于表示一个满足 __MutableBufferSequence__ 要求的类型。

[table 合法表达式
[[表达式] [类型] [语义，前置/后置条件]]
[
    [`D::const_buffers_type`]
    [`T`]
    [该类型用于表示与输入序列关联的内存。]
][
    [`D::mutable_buffers_type`]
    [`U`]
    [该类型用于表示与输出序列关联的内存。]
][
    [`c.size()`]
    [`std::size_t`]
    [返回输入序列的大小（以字节为单位）。]
][
    [`c.max_size()`]
    [`std::size_t`]
    [返回输入序列和输出序列大小之和的允许最大值。]
][
    [`c.capacity()`]
    [`std::size_t`]
    [返回动态缓冲区在无需重新分配内存的情况下，所能容纳的输入序列和输出序列大小之和的最大值。]
][
    [`c.data()`]
    [`D::const_buffers_type`]
    [返回一个常量缓冲区序列 `u`，该序列表示与输入序列关联的内存，且满足 `buffer_size(u) == size()`。]
][
    [`a.prepare(n)`]
    [`D::mutable_buffers_type`]
    [返回一个表示输出序列的可变缓冲区序列 `u`，且满足 `buffer_size(u) == n`。动态缓冲区会根据需要重新分配内存。此前通过 `data()` 或 `prepare()` 获取的所有常量或可变缓冲区序列均会失效。

抛出异常：如果 `size() + n` 超过 `max_size()`，则抛出 `length_error`。]
][
    [`a.commit(n)`]
    [ ]
    [将输出序列开头的 `n` 个字节追加到输入序列的末尾。输出序列的剩余部分将被丢弃。如果 `n` 大于输出序列的大小，则将整个输出序列追加到输入序列中。此前通过 `data()` 或 `prepare()` 获取的所有常量或可变缓冲区序列均会失效。]
][
    [`a.consume(n)`]
    [ ]
    [从输入序列的开头移除 `n` 个字节。如果 `n` 大于输入序列的大小，则移除整个输入序列。此前通过 `data()` 或 `prepare()` 获取的所有常量或可变缓冲区序列均会失效。]
]]

[heading 模型]

* [link beast.ref.boost__beast__basic_flat_buffer `basic_flat_buffer`]
* [link beast.ref.boost__beast__basic_multi_buffer `basic_multi_buffer`]
* [link beast.ref.boost__beast__flat_buffer `flat_buffer`]
* [link beast.ref.boost__beast__flat_static_buffer `flat_static_buffer`]
* [link beast.ref.boost__beast__flat_static_buffer_base `flat_static_buffer_base`]
* [link beast.ref.boost__beast__static_buffer `static_buffer`]
* [link beast.ref.boost__beast__static_buffer_base `static_buffer_base`]
* [link beast.ref.boost__beast__multi_buffer `multi_buffer`]

[endsect]
