You should do it manually. Iterate over the bits, pack them into unsigned char
s, and stream.put
the chars into the file.
Directly writing the native block_type
causes the file format to depend on platform-specific endianness, which is generally undesirable. (And setting block_type
to char
would harm performance.)
Looking at your other question, I see that this is the same as what Nawaz suggested, and that you might want to go back to using std::vector<bool>
instead.