As others have noted, uint8_t is passed as an unsigned char . I sometimes used bit fields from integer types that are passed as integers or integers to avoid the need to throw or overload operator<< , but only when it does not lose space, as in the Pos structure below:
#include <iostream> struct WasteAbyte { unsigned short has_byte_range:8; }; struct Pos { unsigned short x:8; unsigned short y:8; }; int main() { WasteAbyte W = {255}; ++W.has_byte_range; std::cout << W.has_byte_range << std::endl; std::cout << sizeof(WasteAbyte) << std::endl; std::cout << sizeof(Pos) << std::endl; return 0; }
Output:
0 2 2
Ted Lyngmo Nov 23 '17 at 19:33 2017-11-23 19:33
source share