Let's say I want to change the default way the std::bitset prints out its bit. The normal way is:
#include <iostream>
#include <bitset>
int main() {
std::cout << "size of int is: " << (sizeof (int)) << std::endl;
std::bitset<32> bits = 0xFFFF0000;
std::cout << "Original\n" << bits << std::endl;
return 0;
}
Which rightfully outputs (assuming 32 bit processor):
size of int is: 4
Original
11111111111111110000000000000000
Now I want it to print the bits with a space between each byte: e.g.
11111111 11111111 00000000 00000000
or a hypen between each byte:
11111111-11111111-00000000-00000000
I know that a solution is to I make my own function to print bits. But I want to know how can I extend or add more functionality and options to a standard library object.