basic_ostream::operator<<

basic_ostream& operator<<(
    basic_ostream& (*pf)(basic_ostream&));
basic_ostream& operator<<(
    basic_ios<E, T>& (*pf)(basic_ios<E, T>&));
basic_ostream& operator<<(
    ios_base<E, T>& (*pf)(ios_base<E, T>&));
basic_ostream& operator<<(
    basic_streambuf<E, T> *sb);
basic_ostream& operator<<(const char *s);
basic_ostream& operator<<(char c);
basic_ostream& operator<<(bool n);
basic_ostream& operator<<(short n);
basic_ostream& operator<<(unsigned short n);
basic_ostream& operator<<(int n);
basic_ostream& operator<<(unsigned int n);
basic_ostream& operator<<(long n);
basic_ostream& operator<<(unsigned long n);
basic_ostream& operator<<(float n);
basic_ostream& operator<<(double n);
basic_ostream& operator<<(long double n);
basic_ostream& operator<<(void *n);

The first member function ensures that an expression of the form ostr <<: endl calls endl(ostr), then returns *this. The second and third functions ensure that other manipulators, such as hex behave similarly. The remaining functions are all formatted output functions.

The function:

basic_ostream& operator<<(
    basic_streambuf<E, T> *sb);

extracts elements from sb, if sb is not a null pointer, and inserts them. Extraction stops on end-of-file, or if an extraction throws an exception (which is rethrown). It also stops, without extracting the element in question, if an insertion fails. If the function inserts no elements, or if an extraction throws an exception, the function calls setstate(failbit). In any case, the function returns *this.

The function:

basic_ostream& operator<<(const char *s);

determines the length n = strlen(s) of the sequence beginning at s, and inserts the widened sequence. Each element c of the sequence is widened by calling use_facet< ctype<E> >( getloc()). widen(c). If n < width(), then the function also inserts a repetition of width() - n fill characters. The repetition precedes the sequence if (flags() & adjustfield != left. Otherwise, the repetition follows the sequence.

The function:

basic_ostream& operator<<(char c);

inserts the widened element use_facet< ctype<E> >( getloc()). widen(c). It returns *this.

The function:

basic_ostream& operator<<(bool n);

converts n to a Boolean field and inserts it by calling use_facet<num_put<E, OutIt>(getloc()). put(OutIt( rdbuf()), *this, getloc(), n). Here, OutIt is defined as ostreambuf_iterator<E, T>. The function returns *this.

The functions:

basic_ostream& operator<<(short n);
basic_ostream& operator<<(unsigned short n);
basic_ostream& operator<<(int n);
basic_ostream& operator<<(unsigned int n);
basic_ostream& operator<<(long n);
basic_ostream& operator<<(unsigned long n);
basic_ostream& operator<<(void *n);

each convert n to a numeric field and insert it by calling use_facet<num_put<E, OutIt>(getloc()). put(OutIt( rdbuf()), *this, getloc(), n). Here, OutIt is defined as ostreambuf_iterator<E, T>. The function returns *this.

The functions:

basic_ostream& operator<<(float n);
basic_ostream& operator<<(double n);
basic_ostream& operator<<(long double n);

each convert n to a numeric field and insert it by calling use_facet<num_put<E, OutIt>(getloc()). put(OutIt( rdbuf()), *this, getloc(), n). Here, OutIt is defined as ostreambuf_iterator<E, T>. The function returns *this.