Closed jdgarciauc3m closed 10 months ago
Hi @jdgarciauc3m, Thanks for submitting this issue 😃. Since the questions here are discussing interfaces that aren't fully specified by the Core Guidelines, I've forwarded the question to that repo (https://github.com/isocpp/CppCoreGuidelines/issues/2067), along with some thoughts/comments.
Maintainers call: The Core Guidelines maintainers prefer not to add individual span
overloads/wrappers for standard library interfaces that take raw pointers and lengths, that should be in the standard. We've asked the standards committee to do this and there is interest in making span
interfaces throughout the standard library including this example.
The iostream library offers a classical interface for binary read/write, which requires a char* and a size. This is an error-prone interface. Besides it does not integrate well with buffers represented as spans of std::byte.
There are, at least, a couple of alternatives that could be integrated in the GSL:
as_buffer
along the lines of theas_bytes
function in Programming Principles and Practice 2nd Ed (Bjarne Stroustrup).Wrapper functions
We might offer global functions
We might need specializations for specific types (e.g.:
span
)Buffer convenience function
Programming Principles and Practice offers the following function:
We might name such a function
as_buffer
.An addition might be to offer an specialization when
T
is aspan
ofbytes
.