Re: [Capy review] Some questions

Peter Dimov via Boost <[email protected]> Wed, 24 Jun 2026 18:33:12 +0300
Newsgroups gmane.comp.lib.boost.devel
Message-ID <[email protected]>
Ruben Perez wrote:
> 6) Can I write types that satisfy ConstBufferSequence or DynamicBuffer
> without explicitly depending on Capy? This would be useful for low-level
> protocol libraries that want to take as few dependencies as possible.
> Setting the concrete const_buffer and mutable_buffer types apart, the usual
> way of representing "raw bytes" would be span<const unsigned
> char>/span<std::byte>. For instance, std::as_bytes [12] uses std::byte. If
> I got the reasoning behind ConstBufferSequence right [13], the purpose is
> to avoid allocations with vectored I/O. I'd say it's reasonable to allow
> std::array<std::span<const unsigned char>> to satisfy ConstBufferSequence.
> 
> Note that I have read The Span Reflex [14]. I agree with the need
> of ConstBufferSequence. While I personally don't agree with the need of the
> concrete const_buffer and mutable_buffer types, I understand the rationale
> of avoiding std::byte. I'm not challenging these types, only asking for
> better compatibility with std::span.

I've never been particularly fond of the Asio requirement that buffers need
to be convertible specifically to the concrete types const_buffer and
mutable_buffer. (Among other things, this requires physical coupling.)

It being 2026, maybe we should explore the more principled

concept MutableBuffer;
concept ConstBuffer;

concept MutableBufferSequence = MutableBuffer or (Range of MutableBuffer);
concept ConstBufferSequence = ConstBuffer or (Range of ConstBuffer);

That's what we already have, so it's not that big of a leap; the only difference
is how the MutableBuffer and ConstBuffer concepts are specified (via the
convertibility requirement.)

If we formalize the above, we'd then be able to explore more relaxed
ConstBuffer and MutableBuffer concepts (ones that structurally match
span<unsigned char> and span<byte>, for example.)


_______________________________________________
Boost mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://lists.boost.org/mailman3/lists/boost.lists.boost.org/
Archived at: https://lists.boost.org/archives/list/[email protected]/message/SH6ODKOJ6T53EXHZ6AP4UE5QJGU2HLWS/