Does C++ say anything on bit-ordering? I’m especially working on protocol packet layouts, and I’m doubting whether there is a portable way to specify that a certain number be written into bits 5,6,7, where bit 5 is the ‘most significant’.
My questions:
- is 0x01 always represented as a byte with bit 7 set?
- is
bitset<8>().set(7).to_ulong()always equal to 1?
From 20.5/3 (ISO/IEC 14882:2011)
That is,
bitset<8>().set(7).to_ulong()is guaranteed to be(1 << 7) == 128.