| Home | Libraries | People | FAQ | More

## Function template operator>>

boost::logic::operator>> — Reads a tribool value from a stream.

## Synopsis

    template<typename CharT, typename Traits>
      std::basic_istream< CharT, Traits > &
      operator>>(std::basic_istream< CharT, Traits > & in, tribool & x);

## Description

When `(out.flags() & std::ios_base::boolalpha) == 0`, this function reads a `long` value from the input stream `in` and converts that value to a tribool. If that value is 0, `x` becomes `false`; if it is 1, `x` becomes `true`; if it is 2, `becomes` `indetermine`; otherwise, the operation fails (and the fail bit is set on the input stream `in`).

When `(out.flags() & std::ios_base::boolalpha) != 0`, this function first determines the names of the false, true, and indeterminate values. The false and true names are extracted from the `std::numpunct` facet of the input stream's locale (if the C++ standard library implementation supports locales), or from the `default_false_name` and `default_true_name` functions (if there is no locale support). The indeterminate name is extracted from the appropriate `indeterminate_name` facet (if it is available in the input stream's locale), or from the `get_default_indeterminate_name` function (if the C++ standard library implementation does not support locales, or the `indeterminate_name` facet is not specified for this locale object). The input is then matched to each of these names, and the tribool `x` is assigned the value corresponding to the longest name that matched. If no name is matched or all names are empty, the operation fails (and the fail bit is set on the input stream `in`).

Returns: | `in`