basic_ostream::operator<<

  basic_ostream<charT, traits>& operator<<
  (basic_ostream<charT, traits>&
  (*pf)(basic_ostream<charT, traits>&));
  

Returns pf(*this).

  basic_ostream<charT, traits>& operator<<
  (basic_ostream<charT, traits>&
  (*pf)(basic_ios<charT, traits>&));
  

Calls pf(*this) return *this.

  basic_ostream<charT, traits>& operator<<
  (const char_type *s)basic_ostream<charT, traits>& operator<<
  (char_type c)basic_ostream<charT, traits>& operator<<(bool n)
  

Behaves depending on how the boolalpha flag is set.

  basic_ostream<charT, traits>& operator<<(void p)
  

Converts the pointer to void p as if the specifier was %p and returns *this.

  basic_ostream<charT, traits>& operator<<
     (basic_streambuf>char_type, traits>* sb);
   

If sb is null calls setstate(failbit) otherwise gets characters from sb and inserts them into *this until:

If the operation fails, it calls setstate(failbit) or re-throws the exception, otherwise returns *this.

Remarks

The formatted output functions insert the values into the appropriate argument type.

Most inserters (unless noted otherwise) return the this pointer.

Listing: Example of basic_ostream inserter usage:
#include <iostream>
#include <fstream>

#include <cstdlib>

char oFile[81] = "ewl-test";

int main() 

{

using namespace std;

   ofstream out(oFile);

   out << "float " << 33.33;

   out << " double " << 3.16e+10;

   out << " Integer " << 789;

   out << " character " << 'C' << endl;

   out.close();

   cout << "float " << 33.33;

   cout << "\ndouble " << 3.16e+10;

   cout << "\nInteger " << 789;

   cout << "\ncharacter " << 'C' << endl;

   return 0;

}

Result:

  Output: to ewl-test
  float 33.33 double 3.16e+10 Integer 789 character C
  Output to console
  float 33.33
  double 3.16e+10
  Integer 789
  character C