Clementine
Public Member Functions | Related Functions | List of all members
asio::const_buffer Class Reference

Holds a buffer that cannot be modified. More...

#include <buffer.hpp>

Inheritance diagram for asio::const_buffer:
Inheritance graph
[legend]

Public Member Functions

 const_buffer () ASIO_NOEXCEPT
 Construct an empty buffer.
 
 const_buffer (const void *data, std::size_t size) ASIO_NOEXCEPT
 Construct a buffer to represent a given memory range.
 
 const_buffer (const mutable_buffer &b) ASIO_NOEXCEPT
 Construct a non-modifiable buffer from a modifiable one.
 
const void * data () const ASIO_NOEXCEPT
 Get a pointer to the beginning of the memory range.
 
std::size_t size () const ASIO_NOEXCEPT
 Get the size of the memory range.
 
const_bufferoperator+= (std::size_t n) ASIO_NOEXCEPT
 Move the start of the buffer by the specified number of bytes.
 

Related Functions

(Note that these are not member functions.)

const_buffer operator+ (const const_buffer &b, std::size_t n) ASIO_NOEXCEPT
 Create a new non-modifiable buffer that is offset from the start of another.
 
const_buffer operator+ (std::size_t n, const const_buffer &b) ASIO_NOEXCEPT
 Create a new non-modifiable buffer that is offset from the start of another.
 

Detailed Description

Holds a buffer that cannot be modified.

The const_buffer class provides a safe representation of a buffer that cannot be modified. It does not own the underlying data, and so is cheap to copy or assign.

Accessing Buffer Contents

The contents of a buffer may be accessed using the data() and size() member functions:

std::size_t s1 = b1.size();
const unsigned char* p1 = static_cast<const unsigned char*>(b1.data());

The data() member function permits violations of type safety, so uses of it in application code should be carefully considered.


The documentation for this class was generated from the following file: