16 Buffers [buffer]

16.5 Class const_buffer [buffer.const]

namespace std {
namespace experimental {
namespace net {
inline namespace v1 {

  class const_buffer
  {
  public:
    // constructors:
    const_buffer() noexcept;
    const_buffer(const void* p, size_t n) noexcept;
    const_buffer(const mutable_buffer& b) noexcept;

    // members:
    const void* data() const noexcept;
    size_t size() const noexcept;
    const_buffer& operator+=(size_t n) noexcept;

  private:
    const void* data_; // exposition only
    size_t size_; // exposition only
  };

} // inline namespace v1
} // namespace net
} // namespace experimental
} // namespace std

The const_buffer class satisfies requirements of ConstBufferSequence ([buffer.reqmts.constbuffersequence]), DefaultConstructible (C++ 2014 [defaultconstructible]), and CopyAssignable (C++ 2014 [copyassignable]).

const_buffer() noexcept;

Postconditions: data_ == nullptr and size_ == 0.

const_buffer(const void* p, size_t n) noexcept;

Postconditions: data_ == p and size_ == n.

const_buffer(const mutable_buffer& b);

Postconditions: data_ == b.data() and size_ == b.size().

const void* data() const noexcept;

Returns: data_.

size_t size() const noexcept;

Returns: size_.

const_buffer& operator+=(size_t n) noexcept;

Effects: Sets data_ to static_cast<const char*>(data_) + min(n, size_), and then size_ to size_ - min(n, size_).

Returns: *this.