std::basic_ostream< _CharT, _Traits > Class Template Reference

Controlling output. More...

Inheritance diagram for std::basic_ostream< _CharT, _Traits >:

Inheritance graph
[legend]
Collaboration diagram for std::basic_ostream< _CharT, _Traits >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef _CharT char_type
typedef _Traits::int_type int_type
typedef _Traits::pos_type pos_type
typedef _Traits::off_type off_type
typedef _Traits traits_type

Public Methods

 basic_ostream (__streambuf_type *__sb)
 Base constructor.

virtual ~basic_ostream ()
 Base destructor.

__ostream_type & flush ()
 Synchronizing the stream buffer.

pos_type tellp ()
 Getting the current write position.

__ostream_type & seekp (pos_type)
 Changing the current write position.

__ostream_type & seekp (off_type, ios_base::seekdir)
 Changing the current write position.

__ostream_type & operator<< (__ostream_type &(*__pf)(__ostream_type &))
 Interface for manipulators.

__ostream_type & operator<< (__ios_type &(*__pf)(__ios_type &))
 Interface for manipulators.

__ostream_type & operator<< (ios_base &(*__pf)(ios_base &))
 Interface for manipulators.

Arithmetic Inserters
All the operator<< functions (aka formatted output functions) have some common behavior. Each starts by constructing a temporary object of type std::basic_ostream::sentry. This can have several effects, concluding with the setting of a status flag; see the sentry documentation for more.

If the sentry status is good, the function tries to generate whatever data is appropriate for the type of the argument.

If an exception is thrown during insertion, ios_base::badbit will be turned on in the stream's error state without causing an ios_base::failure to be thrown. The original exception will then be rethrown.

__ostream_type & operator<< (long __n)
 Basic arithmetic inserters.

__ostream_type & operator<< (unsigned long __n)
 Basic arithmetic inserters.

__ostream_type & operator<< (bool __n)
 Basic arithmetic inserters.

__ostream_type & operator<< (short __n)
 Basic arithmetic inserters.

__ostream_type & operator<< (unsigned short __n)
 Basic arithmetic inserters.

__ostream_type & operator<< (int __n)
 Basic arithmetic inserters.

__ostream_type & operator<< (unsigned int __n)
 Basic arithmetic inserters.

__ostream_type & operator<< (long long __n)
 Basic arithmetic inserters.

__ostream_type & operator<< (unsigned long long __n)
 Basic arithmetic inserters.

__ostream_type & operator<< (double __f)
 Basic arithmetic inserters.

__ostream_type & operator<< (float __f)
 Basic arithmetic inserters.

__ostream_type & operator<< (long double __f)
 Basic arithmetic inserters.

__ostream_type & operator<< (const void *__p)
 Basic arithmetic inserters.

__ostream_type & operator<< (__streambuf_type *__sb)
 Extracting from another streambuf.

Unformatted Output Functions
All the unformatted output functions have some common behavior. Each starts by constructing a temporary object of type std::basic_ostream::sentry. This has several effects, concluding with the setting of a status flag; see the sentry documentation for more.

If the sentry status is good, the function tries to generate whatever data is appropriate for the type of the argument.

If an exception is thrown during insertion, ios_base::badbit will be turned on in the stream's error state. If badbit is on in the stream's exceptions mask, the exception will be rethrown without completing its actions.

__ostream_type & put (char_type __c)
 Simple insertion.

__ostream_type & write (const char_type *__s, streamsize __n)
 Character string insertion.


Detailed Description

template<typename _CharT, typename _Traits>
class std::basic_ostream< _CharT, _Traits >

Controlling output.

This is the base class for all output streams. It provides text formatting of all builtin types, and communicates with any class derived from basic_streambuf to do the actual output.

Definition at line 58 of file ostream.


Member Typedef Documentation

template<typename _CharT, typename _Traits>
typedef _CharT std::basic_ostream< _CharT, _Traits >::char_type
 

These are standard types. They permit a standardized way of referring to names of (or names dependant on) the template parameters, which are specific to the implementation.

Reimplemented from std::basic_ios< _CharT, _Traits > .

Reimplemented in std::basic_ofstream< _CharT, _Traits > , std::basic_fstream< _CharT, _Traits > , std::basic_ostringstream< _CharT, _Traits, _Alloc > , and std::basic_stringstream< _CharT, _Traits, _Alloc > .

Definition at line 62 of file ostream.

Referenced by std::basic_ostream< _CharT, _Traits >::operator<<() .

template<typename _CharT, typename _Traits>
typedef _Traits::int_type std::basic_ostream< _CharT, _Traits >::int_type
 

These are standard types. They permit a standardized way of referring to names of (or names dependant on) the template parameters, which are specific to the implementation.

Reimplemented from std::basic_ios< _CharT, _Traits > .

Reimplemented in std::basic_ofstream< _CharT, _Traits > , std::basic_fstream< _CharT, _Traits > , std::basic_ostringstream< _CharT, _Traits, _Alloc > , and std::basic_stringstream< _CharT, _Traits, _Alloc > .

Definition at line 63 of file ostream.

Referenced by std::basic_ostream< _CharT, _Traits >::put() .

template<typename _CharT, typename _Traits>
typedef _Traits::off_type std::basic_ostream< _CharT, _Traits >::off_type
 

These are standard types. They permit a standardized way of referring to names of (or names dependant on) the template parameters, which are specific to the implementation.

Reimplemented from std::basic_ios< _CharT, _Traits > .

Reimplemented in std::basic_ofstream< _CharT, _Traits > , std::basic_fstream< _CharT, _Traits > , std::basic_ostringstream< _CharT, _Traits, _Alloc > , and std::basic_stringstream< _CharT, _Traits, _Alloc > .

Definition at line 65 of file ostream.

Referenced by std::basic_ostream< _CharT, _Traits >::seekp() .

template<typename _CharT, typename _Traits>
typedef _Traits::pos_type std::basic_ostream< _CharT, _Traits >::pos_type
 

These are standard types. They permit a standardized way of referring to names of (or names dependant on) the template parameters, which are specific to the implementation.

Reimplemented from std::basic_ios< _CharT, _Traits > .

Reimplemented in std::basic_ofstream< _CharT, _Traits > , std::basic_fstream< _CharT, _Traits > , std::basic_ostringstream< _CharT, _Traits, _Alloc > , and std::basic_stringstream< _CharT, _Traits, _Alloc > .

Definition at line 64 of file ostream.

Referenced by std::basic_ostream< _CharT, _Traits >::seekp() , and std::basic_ostream< _CharT, _Traits >::tellp() .

template<typename _CharT, typename _Traits>
typedef _Traits std::basic_ostream< _CharT, _Traits >::traits_type
 

These are standard types. They permit a standardized way of referring to names of (or names dependant on) the template parameters, which are specific to the implementation.

Reimplemented from std::basic_ios< _CharT, _Traits > .

Reimplemented in std::basic_ofstream< _CharT, _Traits > , std::basic_fstream< _CharT, _Traits > , std::basic_ostringstream< _CharT, _Traits, _Alloc > , and std::basic_stringstream< _CharT, _Traits, _Alloc > .

Definition at line 66 of file ostream.


Constructor & Destructor Documentation

template<typename _CharT, typename _Traits>
std::basic_ostream< _CharT, _Traits >::basic_ostream __streambuf_type *    __sb [inline, explicit]
 

Base constructor.

This ctor is almost never called by the user directly, rather from derived classes' initialization lists, which pass a pointer to their own stream buffer.

Definition at line 85 of file ostream.

template<typename _CharT, typename _Traits>
virtual std::basic_ostream< _CharT, _Traits >::~basic_ostream   [inline, virtual]
 

Base destructor.

This does very little apart from providing a virtual base dtor.

Definition at line 94 of file ostream.


Member Function Documentation

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::flush  
 

Synchronizing the stream buffer.

Returns:
*this
If rdbuf() is a null pointer, changes nothing.

Otherwise, calls rdbuf()->pubsync(), and if that returns -1, sets badbit.

Definition at line 400 of file ostream.tcc.

References std::basic_ios< _CharT, _Traits >::rdbuf() , and std::basic_ios< _CharT, _Traits >::setstate() .

Referenced by std::flush() .

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::operator<< __streambuf_type *    __sb
 

Extracting from another streambuf.

Parameters:
sb A pointer to a streambuf
This function behaves like one of the basic arithmetic extractors, in that it also constructs a sentry onject and has the same error handling behavior.

If sb is NULL, the stream will set failbit in its error state.

Characters are extracted from sb and inserted into *this until one of the following occurs:

  • the input stream reaches end-of-file,
  • insertion into the output sequence fails (in this case, the character that would have been inserted is not extracted), or
  • an exception occurs while getting a character from sb, which sets failbit in the error state

If the function inserts no characters, failbit is set.

Definition at line 119 of file ostream.tcc.

References std::basic_ios< _CharT, _Traits >::exceptions() , and std::basic_ios< _CharT, _Traits >::setstate() .

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::operator<< const void *    __p
 

Basic arithmetic inserters.

Parameters:
A variable of builtin type.
Returns:
*this if successful
These functions use the stream's current locale (specifically, the num_get facet) to perform numeric formatting.

Definition at line 347 of file ostream.tcc.

References std::basic_ios< _CharT, _Traits >::exceptions() , and std::basic_ios< _CharT, _Traits >::setstate() .

template<typename _CharT, typename _Traits>
__ostream_type& std::basic_ostream< _CharT, _Traits >::operator<< long double    __f
 

Basic arithmetic inserters.

Parameters:
A variable of builtin type.
Returns:
*this if successful
These functions use the stream's current locale (specifically, the num_get facet) to perform numeric formatting.

template<typename _CharT, typename _Traits>
__ostream_type& std::basic_ostream< _CharT, _Traits >::operator<< float    __f [inline]
 

Basic arithmetic inserters.

Parameters:
A variable of builtin type.
Returns:
*this if successful
These functions use the stream's current locale (specifically, the num_get facet) to perform numeric formatting.

Definition at line 198 of file ostream.

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::operator<< double    __f
 

Basic arithmetic inserters.

Parameters:
A variable of builtin type.
Returns:
*this if successful
These functions use the stream's current locale (specifically, the num_get facet) to perform numeric formatting.

Definition at line 297 of file ostream.tcc.

References std::basic_ios< _CharT, _Traits >::exceptions() , and std::basic_ios< _CharT, _Traits >::setstate() .

template<typename _CharT, typename _Traits>
__ostream_type& std::basic_ostream< _CharT, _Traits >::operator<< unsigned long long    __n
 

Basic arithmetic inserters.

Parameters:
A variable of builtin type.
Returns:
*this if successful
These functions use the stream's current locale (specifically, the num_get facet) to perform numeric formatting.

template<typename _CharT, typename _Traits>
__ostream_type& std::basic_ostream< _CharT, _Traits >::operator<< long long    __n
 

Basic arithmetic inserters.

Parameters:
A variable of builtin type.
Returns:
*this if successful
These functions use the stream's current locale (specifically, the num_get facet) to perform numeric formatting.

template<typename _CharT, typename _Traits>
__ostream_type& std::basic_ostream< _CharT, _Traits >::operator<< unsigned int    __n [inline]
 

Basic arithmetic inserters.

Parameters:
A variable of builtin type.
Returns:
*this if successful
These functions use the stream's current locale (specifically, the num_get facet) to perform numeric formatting.

Definition at line 183 of file ostream.

template<typename _CharT, typename _Traits>
__ostream_type& std::basic_ostream< _CharT, _Traits >::operator<< int    __n [inline]
 

Basic arithmetic inserters.

Parameters:
A variable of builtin type.
Returns:
*this if successful
These functions use the stream's current locale (specifically, the num_get facet) to perform numeric formatting.

Definition at line 172 of file ostream.

template<typename _CharT, typename _Traits>
__ostream_type& std::basic_ostream< _CharT, _Traits >::operator<< unsigned short    __n [inline]
 

Basic arithmetic inserters.

Parameters:
A variable of builtin type.
Returns:
*this if successful
These functions use the stream's current locale (specifically, the num_get facet) to perform numeric formatting.

Definition at line 168 of file ostream.

template<typename _CharT, typename _Traits>
__ostream_type& std::basic_ostream< _CharT, _Traits >::operator<< short    __n [inline]
 

Basic arithmetic inserters.

Parameters:
A variable of builtin type.
Returns:
*this if successful
These functions use the stream's current locale (specifically, the num_get facet) to perform numeric formatting.

Definition at line 157 of file ostream.

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::operator<< bool    __n
 

Basic arithmetic inserters.

Parameters:
A variable of builtin type.
Returns:
*this if successful
These functions use the stream's current locale (specifically, the num_get facet) to perform numeric formatting.

Definition at line 145 of file ostream.tcc.

References std::basic_ios< _CharT, _Traits >::exceptions() , and std::basic_ios< _CharT, _Traits >::setstate() .

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::operator<< unsigned long    __n
 

Basic arithmetic inserters.

Parameters:
A variable of builtin type.
Returns:
*this if successful
These functions use the stream's current locale (specifically, the num_get facet) to perform numeric formatting.

Definition at line 207 of file ostream.tcc.

References std::basic_ios< _CharT, _Traits >::exceptions() , and std::basic_ios< _CharT, _Traits >::setstate() .

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::operator<< long    __n
 

Basic arithmetic inserters.

Parameters:
A variable of builtin type.
Returns:
*this if successful
These functions use the stream's current locale (specifically, the num_get facet) to perform numeric formatting.

Definition at line 170 of file ostream.tcc.

References std::basic_ostream< _CharT, _Traits >::char_type , std::basic_ios< _CharT, _Traits >::exceptions() , std::basic_ios< _CharT, _Traits >::fill() , std::ios_base::flags() , and std::basic_ios< _CharT, _Traits >::setstate() .

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::operator<< ios_base &(*    __pf)(ios_base &)
 

Interface for manipulators.

Manuipulators such as std::endl and std::hex use these functions in constructs like "std::cout << std::endl". For more information, see the iomanip header.

Definition at line 98 of file ostream.tcc.

References std::basic_ios< _CharT, _Traits >::exceptions() , and std::basic_ios< _CharT, _Traits >::setstate() .

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::operator<< __ios_type &(*    __pf)(__ios_type &)
 

Interface for manipulators.

Manuipulators such as std::endl and std::hex use these functions in constructs like "std::cout << std::endl". For more information, see the iomanip header.

Definition at line 76 of file ostream.tcc.

References std::basic_ios< _CharT, _Traits >::exceptions() , and std::basic_ios< _CharT, _Traits >::setstate() .

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::operator<< __ostream_type &(*    __pf)(__ostream_type &)
 

Interface for manipulators.

Manuipulators such as std::endl and std::hex use these functions in constructs like "std::cout << std::endl". For more information, see the iomanip header.

Definition at line 54 of file ostream.tcc.

References std::basic_ios< _CharT, _Traits >::exceptions() , and std::basic_ios< _CharT, _Traits >::setstate() .

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::put char_type    __c
 

Simple insertion.

Parameters:
c The character to insert.
Returns:
*this
Tries to insert c.

Note:
This function is not overloaded on signed char and unsigned char.

Definition at line 372 of file ostream.tcc.

References std::basic_ostream< _CharT, _Traits >::int_type , std::basic_ios< _CharT, _Traits >::rdbuf() , and std::basic_ios< _CharT, _Traits >::setstate() .

Referenced by std::endl() , and std::ends() .

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::seekp off_type   ,
ios_base::seekdir   
 

Changing the current write position.

Parameters:
off A file offset object.
dir The direction in which to seek.
Returns:
*this
If fail() is not true, calls rdbuf()->pubseekoff(off,dir). If that function fails, sets failbit.

Definition at line 443 of file ostream.tcc.

References std::basic_ios< _CharT, _Traits >::fail() , std::basic_ostream< _CharT, _Traits >::off_type , std::basic_ostream< _CharT, _Traits >::pos_type , std::basic_ios< _CharT, _Traits >::rdbuf() , and std::basic_ios< _CharT, _Traits >::setstate() .

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::seekp pos_type   
 

Changing the current write position.

Parameters:
pos A file position object.
Returns:
*this
If fail() is not true, calls rdbuf()->pubseekpos(pos). If that function fails, sets failbit.

Definition at line 424 of file ostream.tcc.

References std::basic_ios< _CharT, _Traits >::fail() , std::basic_ostream< _CharT, _Traits >::off_type , std::basic_ostream< _CharT, _Traits >::pos_type , std::basic_ios< _CharT, _Traits >::rdbuf() , and std::basic_ios< _CharT, _Traits >::setstate() .

template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits >::pos_type std::basic_ostream< _CharT, _Traits >::tellp  
 

Getting the current write position.

Returns:
A file position object.
If fail() is not false, returns pos_type(-1) to indicate failure. Otherwise returns rdbuf()->pubseekoff(0,cur,out).

Definition at line 413 of file ostream.tcc.

References std::basic_ios< _CharT, _Traits >::fail() , std::basic_ostream< _CharT, _Traits >::pos_type , and std::basic_ios< _CharT, _Traits >::rdbuf() .

template<typename _CharT, typename _Traits>
__ostream_type& std::basic_ostream< _CharT, _Traits >::write const char_type   __s,
streamsize    __n
 

Character string insertion.

Parameters:
s The array to insert.
n Maximum number of characters to insert.
Returns:
*this
Characters are copied from s and inserted into the stream until one of the following happens:

  • n characters are inserted
  • inserting into the output sequence fails (in this case, badbit will be set in the stream's error state)

Note:
This function is not overloaded on signed char and unsigned char.

Referenced by std::operator<<() .


The documentation for this class was generated from the following files:
Generated on Thu Nov 21 03:13:23 2002 for libstdc++-v3 Source by doxygen1.2.18-20021030