Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to represent raw bytes in a std::vector?

I'm working with the ZeroMQ library which uses void * to represent blocks of arbitrary binary data. However I'd like to use std::vector to copy and move these blocks around. What is the preferred, idiomatic way to make a std::vector representing raw bytes? I'm currently using a std::vector<unsigned char> but I want to make sure my code makes sense to other people.

like image 861
japreiss Avatar asked Nov 23 '25 03:11

japreiss


1 Answers

Either

std::vector<unsigned char>

or

#include <cstdint>

std::vector<std::uint8_t>

both seem fine to me.

like image 64
john Avatar answered Nov 24 '25 18:11

john



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!