Boost logo

Boost :

From: Gavin Lambert (boost_at_[hidden])
Date: 2020-03-10 02:30:07

On 10/03/2020 09:56, Janson R. wrote:
> Observation is mostly correct, and it is one of the main reasons I've
> come to ask for feedback here; Vinnie rightfully pointed out that the
> question being asked is "what [does] a clean, Boost-quality, modern C++
> API to codec that operates on memory buffers [look] like[?]".

That answer may be different depending on your context; for example
Boost.Asio provides a number of buffer concepts and methods for
manipulating them.

Which are good, in that they're templates and support all kinds of
different buffer concepts (from basic vectors and strings through to
dynamic multi-buffer streams), and you only pay for the complexity that
you actually use.

They're also bad, in that they're templates and they're harder to
consume generically without forcing your own code to also be a template.

But if you're in the context of Boost.Beast or some other app that uses
Asio, it makes sense to use these buffer concepts rather than
reinventing the wheel, especially with these things
probably-maybe-eventually landing in the standard.

Forthcoming std::span might be another interesting candidate.

> Since the emails discussions have begun I've integrated the following
> prototype API after suggestion by a few of the people here:
> ```
> optional<std::string> easy_compress(string_view in, wrap wrapping =
> wrap::none);
> optional<std::string> easy_uncompress(string_view in, wrap wrapping =
> wrap::none);
> ```
While it works (and I do sometimes use it myself if I'm especially lazy)
I dislike use of std::string and friends for arbitrary binary data.

std::basic_string<uint8_t> / std::basic_string_view<uint8_t> are better,
but still carry unfortunate "pretending to be text" implications.

std::vector<uint8_t> is probably the best standard container type for a
basic block-o-bytes, absent generic template buffer concept magic and/or
C++20 spans.

Boost list run by bdawes at, gregod at, cpdaniel at, john at