简体   繁体   中英

boost::endian and non-1 byte atomic endianness?

I have read on Wikipedia that there are three main types of endianness:

  • big endian
  • little endian
  • middle endian

boost::endian focuses on the two firsts because:

PDP-11 and the other middle endian approaches are interesting historical curiosities but have no relevance to today's C++ developers.

But I also read on Wikipedia that there are 8-bit and 16-bit versions (and maybe others?) of little and big endianness.

  • Is boost::endian managing both versions?
  • If yes, how?
  • If not, why?

I don't know much about the boost libraries, but endianness pervades pretty much everything in a computer and can be a headache when dealing with trying to write endian-neutral code. If you have a 128 bit integer the little endian computer's pointer will point to the low order bit while the big endian pointer will point to the high order bit. Depending on the datatypes the pointer could be anywhere up and down the memory in a big endian system. Since the little-endian system always points to the low order byte and there's no datatype smaller than a byte, type coercion becomes a no-op on a little endian machine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM