boost::operator>> :: Boost.DynamicBitset

# boost::operator>>

Extracts a `dynamic_bitset` from an input stream.

## Synopsis

Declared in `<boost/dynamic_bitset/dynamic_bitset.hpp>`

    template<
        typename CharT,
        typename Traits,
        typename Block,
        typename AllocatorOrContainer>
    std::basic_istream<CharT, Traits>&
    operator>>(
        std::basic_istream<CharT, Traits>& is,
        dynamic_bitset<Block, AllocatorOrContainer>& b);

## Definitions

- A (non‐eof) character `c` extracted from `is` is a bitset digit if and only if either `Traits::eq(c, is.widen('0'))` or `Traits::eq(c, is.widen('1'))` return `true`.

- If `c` is a bitset digit, its corresponding bit value is 0 if `Tr::eq(c, is.widen('0'))` returns true, 1 otherwise.

The extractor begins by constructing a `sentry` object `k` as if by `typename std::basic_istream< Char, Traits >::sentry k( is )`. If `bool( k )` is `true`, it calls `b.clear()` then attempts to extract characters from `is`. For each character `c` that is a bitset digit, the corresponding bit value is appended to the less significant end of `b` (appending may throw). If `is.width()` is greater than zero and smaller than `b.max_size()` then the maximum number `n` of bits appended is `is.width()`; otherwise `n = b.max_size()`. Unless the extractor is exited via an exception, characters are extracted (and corresponding bits appended) until any of the following occurs:

- `n` bits are stored into the bitset;

- end‐of‐file, or an error, occurs on the input sequence;

- the next available input character isn't a bitset digit.

If no exception caused the function to exit then `is.width( 0 )` is called, regardless of how many characters were actually extracted. The sentry object `k` is destroyed.

If the function extracts no characters, it calls `is.setstate( std::ios::failbit )`, which may throw `std::ios_base::failure`.

## Return Value

`is`.

## Parameters

Name | Description
is | The left operand
b | The right operand

Created with MrDocs