operator<<,>>(std::bitset)
From cppreference.com
                    
                                        
                    
                    
                                                            
                    |   template <class CharT, class Traits, size_t N> std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os,   | 
(1) | |
|   template <class CharT, class Traits, size_t N> std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& is,   | 
(2) | |
Inserts or extracts a bitset from a character stream.
1) Writes the bitset x to the character stream os.
2) Extracts up to N characters from is and stores the characters in the bitset x.
Characters are extracted until either
- N characters have been read,
 - end-of-file occurs in is, or
 - the next character is neither is.widen('0') nor is.widen('1').
 
If no characters are extracted, is.setstate(ios_base::failbit) is called.
Contents | 
[edit] Parameters
| os | - | the character stream to write to | 
| is | - | the character stream to read from | 
| x | - | the bitset to be read or written | 
[edit] Return value
The character stream that was operated on, e.g. os or is.
[edit] Example
#include <bitset> #include <iostream> #include <sstream> int main() { std::string bit_string = "001101"; std::istringstream bit_stream(bit_string); std::bitset<3> b1; bit_stream >> b1; std::cout << b1 << '\n'; std::bitset<8> b2; bit_stream >> b2; std::cout << b2 << '\n'; }
Output:
001 00000101
[edit] See also
|    performs binary shift left and shift right  (public member function)  | |