Scroll to navigation

std::basic_ostream< _CharT, _Traits >(3cxx) std::basic_ostream< _CharT, _Traits >(3cxx)

NAME

std::basic_ostream< _CharT, _Traits > - Template class basic_ostream.

SYNOPSIS

Inherited by std::basic_ofstream< _CharT, _Traits >.

Classes


class sentry
Performs setup work for output streams.

Public Types


typedef ctype< _CharT > __ctype_type
typedef basic_ios< _CharT, _Traits > __ios_type
typedef num_put< _CharT, ostreambuf_iterator< _CharT, _Traits > > __num_put_type
typedef basic_ostream< _CharT, _Traits > __ostream_type
typedef basic_streambuf< _CharT, _Traits > __streambuf_type
typedef _CharT char_type
typedef _Traits::int_type int_type
typedef _Traits::off_type off_type
typedef _Traits::pos_type pos_type
typedef _Traits traits_type

Public Member Functions


basic_ostream (__streambuf_type *__sb)
Base constructor. virtual ~basic_ostream ()
Base destructor. template<typename _ValueT > basic_ostream< _CharT, _Traits > & _M_insert (_ValueT __v)
__ostream_type & operator<< (__ios_type &(*__pf)(__ios_type &))
__ostream_type & operator<< (__ostream_type &(*__pf)(__ostream_type &))
Interface for manipulators. __ostream_type & operator<< (ios_base &(*__pf)(ios_base &))

Friends


class sentry

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. void _M_write (const char_type *__s, streamsize __n)
Core write functionality, without sentry. __ostream_type & write (const char_type *__s, streamsize __n)
Character string insertion. __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. basic_ostream ()
Simple insertion. basic_ostream (basic_iostream< _CharT, _Traits > &)
Simple insertion. basic_ostream (const basic_ostream &)=delete
Simple insertion. basic_ostream (basic_ostream &&__rhs)
Simple insertion. basic_ostream & operator= (const basic_ostream &)=delete
Simple insertion. basic_ostream & operator= (basic_ostream &&__rhs)
Simple insertion. void swap (basic_ostream &__rhs)
Simple insertion. template<typename _ValueT > __ostream_type & _M_insert (_ValueT __v)
Simple insertion.

Detailed Description

template<typename _CharT, typename _Traits>

class std::basic_ostream< _CharT, _Traits >" Template class basic_ostream.

Template Parameters

_CharT Type of character stream.
_Traits Traits for character type, defaults to char_traits<_CharT>.

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.

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 84 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 93 of file ostream.

template<typename _CharT , typename _Traits > std::basic_ostream< _CharT, _Traits >::basic_ostream () [inline], [protected]

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 390 of file ostream.

template<typename _CharT , typename _Traits > std::basic_ostream< _CharT, _Traits >::basic_ostream (basic_iostream< _CharT, _Traits > &) [inline], [protected]

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 395 of file ostream.

template<typename _CharT , typename _Traits > std::basic_ostream< _CharT, _Traits >::basic_ostream (const basic_ostream< _CharT, _Traits > &) [protected], [delete]

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.

template<typename _CharT , typename _Traits > std::basic_ostream< _CharT, _Traits >::basic_ostream (basic_ostream< _CharT, _Traits > && __rhs) [inline], [protected]

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 399 of file ostream.

Member Function Documentation

template<typename _CharT , typename _Traits > template<typename _ValueT > __ostream_type& std::basic_ostream< _CharT, _Traits >::_M_insert (_ValueT __v) [protected]

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.

template<typename _CharT , typename _Traits > void std::basic_ostream< _CharT, _Traits >::_M_write (const char_type * __s, streamsize __n) [inline]

Core write functionality, without sentry.

Parameters

__s The array to insert.
__n Maximum number of characters to insert.

Definition at line 317 of file ostream.

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 210 of file ostream.tcc.

References std::ios_base::goodbit.

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

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

Interface for manipulators. Manipulators 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 107 of file ostream.

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 object 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 63 of file ostream.tcc.

References std::ios_base::goodbit.

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

Integer arithmetic inserters.

Parameters

__n A variable of builtin integral 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 173 of file ostream.

template<typename _CharT , typename _Traits > __ostream_type& std::basic_ostream< _CharT, _Traits >::operator<< (const void * __p) [inline]

Pointer arithmetic inserters.

Parameters

__p A variable of pointer 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 244 of file ostream.

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

Floating point arithmetic inserters.

Parameters

__f A variable of builtin floating point 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 219 of file ostream.

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

Integer arithmetic inserters.

Parameters

__n A variable of builtin integral 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 223 of file ostream.

template<typename _CharT , typename _Traits > basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::operator<< (int __n)

Integer arithmetic inserters.

Parameters

__n A variable of builtin integral 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 63 of file ostream.tcc.

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

Integer arithmetic inserters.

Parameters

__n A variable of builtin integral 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 165 of file ostream.

template<typename _CharT , typename _Traits > __ostream_type& std::basic_ostream< _CharT, _Traits >::operator<< (long double __f) [inline]

Integer arithmetic inserters.

Parameters

__n A variable of builtin integral 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 231 of file ostream.

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

Integer arithmetic inserters.

Parameters

__n A variable of builtin integral 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 200 of file ostream.

template<typename _CharT , typename _Traits > basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::operator<< (short __n)

Integer arithmetic inserters.

Parameters

__n A variable of builtin integral 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 63 of file ostream.tcc.

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

Integer arithmetic inserters.

Parameters

__n A variable of builtin integral 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 191 of file ostream.

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

Integer arithmetic inserters.

Parameters

__n A variable of builtin integral 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 169 of file ostream.

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

Integer arithmetic inserters.

Parameters

__n A variable of builtin integral 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 204 of file ostream.

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

Integer arithmetic inserters.

Parameters

__n A variable of builtin integral 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 180 of file ostream.

template<typename _CharT , typename _Traits > basic_ostream& std::basic_ostream< _CharT, _Traits >::operator= (basic_ostream< _CharT, _Traits > && __rhs) [inline], [protected]

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 408 of file ostream.

template<typename _CharT , typename _Traits > basic_ostream& std::basic_ostream< _CharT, _Traits >::operator= (const basic_ostream< _CharT, _Traits > &) [protected], [delete]

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.

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 148 of file ostream.tcc.

References std::ios_base::goodbit.

template<typename _CharT , typename _Traits > basic_ostream< _CharT, _Traits > & std::basic_ostream< _CharT, _Traits >::seekp (off_type __off, ios_base::seekdir __dir)

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 289 of file ostream.tcc.

References std::ios_base::goodbit.

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

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 257 of file ostream.tcc.

References std::ios_base::goodbit.

template<typename _CharT , typename _Traits > void std::basic_ostream< _CharT, _Traits >::swap (basic_ostream< _CharT, _Traits > & __rhs) [inline], [protected]

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 415 of file ostream.

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 236 of file ostream.tcc.

template<typename _CharT , typename _Traits > basic_ostream< _CharT, _Traits > & 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.

Definition at line 182 of file ostream.tcc.

Author

Generated automatically by Doxygen for libstdc++ from the source code.
Fri Sep 11 2020 libstdc++