Repository navigation
Replies: 1 comment 1 reply
|
Ok, it looks to me like Capy has an undocumented contract for all its buffer types (those qualifying as The advantage of So, the reason for introducuing |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
The "Span reflex" article criticizes two "reflex" opinions:
std::span<std::byte>for representing single buffersstd::span<std::span<std::byte>>for representing ranges of buffers.While I agree with the criticism of #2, the criticism of #1 looks insufficiently founded in the context of Capy.
In Capy, we have a concrete type
const_bufferwith the following contract:const_bufferform any recognizable range of trivially-copyable structures (includingchar).const_bufferto aniovecorWSABUF.It looks like using
std::span<const std::byte>instead ofconst_buffer(or makingconst_bufferan alias forstd::span<const std::byte>.It is true that
std::byteunnecessarily gives provision to do byte-shifting operations, but who cares, when the only thing the users do with this type is to create it viacapy::make_bufferand pass it to framework functions, which will now how to translate toiovecorWSABUF.And the benefit of using
std::span<const std::byte>is not having to introduce another type that the users have to learn.Having a distinct type to indicate a minimally narrower contract makes sense in general, but is inconsistent with other decisions in Capy: all async operations return
std::tuple<std::error_code, ...>even though there are special rules and relationships that apply to tuple elements.The choice to introduce a new type would be clearer if
const_bufferoffered implicit conversions from every known sequence of trivially-copyable elements (whatcapy::make_buffercurrently does), but this is not the case.All reactions