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

The boost::asio::buffer_cast function is used to obtain a pointer to the underlying memory region associated with a buffer. More...

Functions

template<typename PointerToPodType >
PointerToPodType boost::asio::buffer_cast (const mutable_buffer &b)
 Cast a non-modifiable buffer to a specified pointer to POD type. More...
 
template<typename PointerToPodType >
PointerToPodType boost::asio::buffer_cast (const const_buffer &b)
 Cast a non-modifiable buffer to a specified pointer to POD type. More...
 

Detailed Description

The boost::asio::buffer_cast function is used to obtain a pointer to the underlying memory region associated with a buffer.

Examples:

To access the memory of a non-modifiable buffer, use:

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

To access the memory of a modifiable buffer, use:

unsigned char* p2 = boost::asio::buffer_cast<unsigned char*>(b2);

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

Function Documentation

template<typename PointerToPodType >
PointerToPodType boost::asio::buffer_cast ( const mutable_buffer &  b)
inline

#include <boost_1_57_0/boost/asio/buffer.hpp>

Cast a non-modifiable buffer to a specified pointer to POD type.

References boost::asio::detail::buffer_cast_helper().

Referenced by boost::asio::mutable_buffer::operator+(), and boost::asio::const_buffer::operator+().

template<typename PointerToPodType >
PointerToPodType boost::asio::buffer_cast ( const const_buffer &  b)
inline

#include <boost_1_57_0/boost/asio/buffer.hpp>

Cast a non-modifiable buffer to a specified pointer to POD type.

References boost::asio::detail::buffer_cast_helper().