• pelya
    link
    fedilink
    3325 days ago

    std::vector<bool> fits eight booleans into one byte.

    • TimeSquirrel
      link
      fedilink
      825 days ago

      std::vector<std::vector<bool>> is how I stored the representation of a play field for a Tetris game I made once.

    • @borokov@lemmy.world
      link
      fedilink
      223 days ago
      auto v = std::vector<bool>(8);
      bool* vPtr = v.data;
      vPtr[2] = true;
      // KABOOM !!!
      

      I’ve spent days tracking this bug… That’s how I learned about bool specialisation of std::vector.