jeudi 30 juillet 2020

Safe way to get number of bytes for a data type in C++

I'm using C++11 and higher and I was asking myself if it is safe to get the number of bytes required for a datatype like std::uint16_t to send over length agnostic protocols. More precise is it safe to call sizeof(std::uint16_t) and can I assume that this is always 2? What about std::int16_t?

Aucun commentaire:

Enregistrer un commentaire