• gamer@lemm.ee
      link
      fedilink
      arrow-up
      6
      ·
      edit-2
      8 hours ago

      Consider what the disassembly would look like. There’s no fast way to do it.

      It’s also unnecessary since 8 bytes is a negligible amount in most cases. Serialization is the only real scenario where it matters. (Edit: and embedded)

    • Anders429@programming.dev
      link
      fedilink
      arrow-up
      30
      ·
      11 hours ago

      It would be slower to read the value if you had to also do bitwise operations to get the value.

      But you can also define your own bitfield types to store booleans packed together if you really need to. I would much rather that than have the compiler do it automatically for me.

    • timhh@programming.dev
      link
      fedilink
      arrow-up
      23
      ·
      12 hours ago

      Well there are containers that store booleans in single bits (e.g. std::vector<bool> - which was famously a big mistake).

      But in the general case you don’t want that because it would be slower.