Detailed Description
You can add your own free function overloads to tell AFIO how to convert your custom types into ASIO scatter gather buffers. Note that const types must convert into asio::const_buffer, and non-const types must convert into asio::mutable_buffer. It is entirely acceptable for types to allow writing (const) only and not reading.
Default overloads provided are as follows:
- Any trivial type T * and number of items.
- void * and const void * with number of bytes.
- C array types are treated as if a std::array.
- asio::const_buffer and asio::mutable_buffer are passed through as-is.
- Any container type holding a trivial type T. This includes std::basic_string (write only), std::vector and std::array, all three of which are specially collapsed into a single scatter gather as they guarantee storing their contents contiguously.
- Any container type holding any of the above, including other containers. These will be converted into scatter gather lists for you. Note that the constness of the type returned by the container's iterator is respected, so if the container iterator returns a const reference (e.g. std::basic_string) then you cannot gather read into that container, and instead should receive a compile time error.
Function Documentation
std::vector<asio::mutable_buffer> boost::afio::to_asio_buffers |
( |
asio::mutable_buffer & |
v | ) |
|
Passing through asio::mutable_buffer.
- Returns:
- A vector of ASIO buffers
Definition at line 2859 of file afio.hpp.
std::vector<asio::const_buffer> boost::afio::to_asio_buffers |
( |
asio::const_buffer & |
v | ) |
|
Passing through asio::const_buffer.
- Returns:
- A vector of ASIO buffers
Definition at line 2869 of file afio.hpp.
template<class T >
std::vector<asio::mutable_buffer> boost::afio::to_asio_buffers |
( |
T * |
v, |
|
|
size_t |
length |
|
) |
| |
A buffer at v sized length*sizeof(T)
- Template Parameters:
-
class T | Any trivial type T |
- Returns:
- A vector of ASIO buffers
Definition at line 2880 of file afio.hpp.
template<class T >
std::vector<asio::const_buffer> boost::afio::to_asio_buffers |
( |
const T * |
v, |
|
|
size_t |
length |
|
) |
| |
A buffer at v sized length*sizeof(T)
- Template Parameters:
-
class T | Any trivial type T |
- Returns:
- A vector of ASIO buffers
Definition at line 2892 of file afio.hpp.
std::vector<asio::mutable_buffer> boost::afio::to_asio_buffers |
( |
void * |
v, |
|
|
size_t |
length |
|
) |
| |
A buffer at v sized length.
- Returns:
- A vector of ASIO buffers
Definition at line 2903 of file afio.hpp.
std::vector<asio::const_buffer> boost::afio::to_asio_buffers |
( |
const void * |
v, |
|
|
size_t |
length |
|
) |
| |
A buffer at v sized length.
- Returns:
- A vector of ASIO buffers
Definition at line 2913 of file afio.hpp.
template<class T >
std::vector< asio::mutable_buffer > boost::afio::to_asio_buffers |
( |
T & |
v | ) |
|
Any trivial type T or STL container.
Trivial types turn into a buffer of &v sized sizeof(T). Container types have their value type deduced and to_asio_buffers() called on that value_type. Additional specialisations are provided for string, vector and array to collapse the scatter gather buffers into a single one for contiguous storage.
- Template Parameters:
-
class T | Any trivial type T or STL container |
- Returns:
- A vector of ASIO buffers
Definition at line 3044 of file afio.hpp.
template<class T >
std::vector< asio::const_buffer > boost::afio::to_asio_buffers |
( |
const T & |
v | ) |
|
Any trivial type T or STL container.
Trivial types turn into a buffer of &v sized sizeof(T). Container types have their value type deduced and to_asio_buffers() called on that value_type. Additional specialisations are provided for string, vector and array to collapse the scatter gather buffers into a single one for contiguous storage.
- Template Parameters:
-
class T | Any trivial type T or STL container |
- Returns:
- A vector of ASIO buffers
Definition at line 3061 of file afio.hpp.
template<class T , size_t N>
std::vector< asio::mutable_buffer > boost::afio::to_asio_buffers |
( |
T(&) |
v[N] | ) |
|
A buffer at v sized N*sizeof(T)
- Template Parameters:
-
class T | Any trivial type T |
- Returns:
- A vector of ASIO buffers
Definition at line 3073 of file afio.hpp.
template<class T , size_t N>
std::vector< asio::const_buffer > boost::afio::to_asio_buffers |
( |
const T(&) |
v[N] | ) |
|
A buffer at v sized N*sizeof(T)
- Template Parameters:
-
class T | Any trivial type T |
- Returns:
- A vector of ASIO buffers
Definition at line 3084 of file afio.hpp.