Brief post on a somewhat vexing and irritating C++ problem I ran into some time ago. I hope that this page will help other people deal with this problem more quickly than I did.
I’ve long used std::basic_string, an unsigned char string, for fiddling with bits. You could use a regular char string, but especially when doing cryptographic or sub-byte operations, it is more convenient to not have to deal with sign bits.