Boost logo

Boost :

From: Dominique Devienne (ddevienne_at_[hidden])
Date: 2024-10-18 16:09:23


On Fri, Oct 18, 2024 at 5:56 PM Ruben Perez via Boost
<boost_at_[hidden]> wrote:
> 5. According to what I read in the docs, message payloads might
> contain UTF-8 encoded text or just data blobs, depending on the
> payload_format_indicator property passed to publish. However,
> std::string is always used for payloads. As I understand it, if I want
> to send a binary blob, I need to copy my blob to a string (probably
> with a reinterpret_cast in the way), and then setting
> payload_format_indicator. Would it make sense to expose a simpler API
> taking a blob (e.g. a std::vector<unsigned char>) to make this use
> case safer?

These days, I'm passing std::span<const std::byte> for binary blobs.
This a C++17 lib, so no std::span, but please do consider std::byte at
least. --DD

PS: I used https://github.com/tcbrindle/span in C++17. Maybe Boost has a span?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk