Clementine
Functions
asio::buffer_copy

The asio::buffer_copy function is used to copy bytes from a source buffer (or buffer sequence) to a target buffer (or buffer sequence). More...

Functions

template<typename MutableBufferSequence , typename ConstBufferSequence >
std::size_t asio::buffer_copy (const MutableBufferSequence &target, const ConstBufferSequence &source) ASIO_NOEXCEPT
 Copies bytes from a source buffer sequence to a target buffer sequence. More...
 
template<typename MutableBufferSequence , typename ConstBufferSequence >
std::size_t asio::buffer_copy (const MutableBufferSequence &target, const ConstBufferSequence &source, std::size_t max_bytes_to_copy) ASIO_NOEXCEPT
 Copies a limited number of bytes from a source buffer sequence to a target buffer sequence. More...
 

Detailed Description

The asio::buffer_copy function is used to copy bytes from a source buffer (or buffer sequence) to a target buffer (or buffer sequence).

The buffer_copy function is available in two forms:

Both forms return the number of bytes actually copied. The number of bytes copied is the lesser of:

This prevents buffer overflow, regardless of the buffer sizes used in the copy operation.

Note that asio::buffer_copy is implemented in terms of memcpy, and consequently it cannot be used to copy between overlapping memory regions.

Function Documentation

◆ buffer_copy() [1/2]

template<typename MutableBufferSequence , typename ConstBufferSequence >
std::size_t asio::buffer_copy ( const MutableBufferSequence &  target,
const ConstBufferSequence &  source 
)
inline

Copies bytes from a source buffer sequence to a target buffer sequence.

Parameters
targetA modifiable buffer sequence representing the memory regions to which the bytes will be copied.
sourceA non-modifiable buffer sequence representing the memory regions from which the bytes will be copied.
Returns
The number of bytes copied.
Note
The number of bytes copied is the lesser of:
  • buffer_size(target)
  • buffer_size(source)

This function is implemented in terms of memcpy, and consequently it cannot be used to copy between overlapping memory regions.

◆ buffer_copy() [2/2]

template<typename MutableBufferSequence , typename ConstBufferSequence >
std::size_t asio::buffer_copy ( const MutableBufferSequence &  target,
const ConstBufferSequence &  source,
std::size_t  max_bytes_to_copy 
)
inline

Copies a limited number of bytes from a source buffer sequence to a target buffer sequence.

Parameters
targetA modifiable buffer sequence representing the memory regions to which the bytes will be copied.
sourceA non-modifiable buffer sequence representing the memory regions from which the bytes will be copied.
max_bytes_to_copyThe maximum number of bytes to be copied.
Returns
The number of bytes copied.
Note
The number of bytes copied is the lesser of:
  • buffer_size(target)
  • buffer_size(source)
  • max_bytes_to_copy

This function is implemented in terms of memcpy, and consequently it cannot be used to copy between overlapping memory regions.