ConstBufferSequence
A constant buffer sequence represents zero or more contiguous memory regions
as a bidirectional range whose value type is convertible to const_buffer
,
or as an object which is convertible to const_buffer
.
template< typename T >
concept const_buffer_sequence =
std::is_convertible_v<T, const_buffer> || (
std::ranges::bidirectional_range<T> &&
std::is_convertible_v<std::ranges::range_value_t<T>, const_buffer>);
While the functions std::ranges::begin
and std::ranges::end
will
work on bidirectional ranges, they do not handle objects which are merely
convertible to const_buffer
. To enable this use-case, the functions
and buffers::begin
must be used. These
are always called with namespace qualification. Alternatively, the function
buffers::end
or buffers::single
std::views::single
may be used to adapt
a const_buffer
into a 1-element range.
Copies of a buffer sequence must point to the same memory regions:
T t(u);
static_assert( const_buffer_sequence<T> );
assert( std::equal(
buffers::begin(t), buffers::end(t),
buffers::begin(u), buffers::end(u),
[](const_buffer const& b1, const_buffer const& b2)
{
return b1.data() == b2.data() && b1.size() == b2.size();
}));