Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::asio::const_buffer Class Reference

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

#include <buffer.hpp>

Inheritance diagram for boost::asio::const_buffer:

Public Member Functions

 const_buffer ()
 Construct an empty buffer. More...
 
 const_buffer (const void *data, std::size_t size)
 Construct a buffer to represent a given memory range. More...
 
 const_buffer (const mutable_buffer &b)
 Construct a non-modifiable buffer from a modifiable one. More...
 

Friends

const void * boost::asio::detail::buffer_cast_helper (const const_buffer &b)
 
std::size_t boost::asio::detail::buffer_size_helper (const const_buffer &b)
 

Related Functions

(Note that these are not member functions.)

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

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 boost::asio::buffer_size and boost::asio::buffer_cast functions:

std::size_t s1 = boost::asio::buffer_size(b1);
const unsigned char* p1 = boost::asio::buffer_cast<const unsigned char*>(b1);

The boost::asio::buffer_cast function permits violations of type safety, so uses of it in application code should be carefully considered.

Constructor & Destructor Documentation

boost::asio::const_buffer::const_buffer ( )
inline

Construct an empty buffer.

boost::asio::const_buffer::const_buffer ( const void *  data,
std::size_t  size 
)
inline

Construct a buffer to represent a given memory range.

boost::asio::const_buffer::const_buffer ( const mutable_buffer b)
inline

Construct a non-modifiable buffer from a modifiable one.

Friends And Related Function Documentation

const void* boost::asio::detail::buffer_cast_helper ( const const_buffer b)
friend
std::size_t boost::asio::detail::buffer_size_helper ( const const_buffer b)
friend
const_buffer operator+ ( const const_buffer b,
std::size_t  start 
)
related

Create a new non-modifiable buffer that is offset from the start of another.

References boost::asio::b, boost::asio::buffer_cast(), and boost::asio::buffer_size().

const_buffer operator+ ( std::size_t  start,
const const_buffer b 
)
related

Create a new non-modifiable buffer that is offset from the start of another.

References boost::asio::b, boost::asio::buffer_cast(), and boost::asio::buffer_size().


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