std::basic_ostream::operator<<
From Cppreference
C++ Standard Library | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Input/output library | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::basic_ostream | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
basic_ostream& operator<<( short value );
basic_ostream& operator<<( unsigned short value ); |
(1) | |||
basic_ostream& operator<<( int value );
basic_ostream& operator<<( unsigned int value ); |
(2) | |||
basic_ostream& operator<<( long value );
basic_ostream& operator<<( unsigned long value ); |
(3) | |||
basic_ostream& operator<<( long long value );
basic_ostream& operator<<( unsigned long long value ); |
(4) | (C++11 feature) | ||
basic_ostream& operator<<( float value );
basic_ostream& operator<<( double value ); |
(5) | |||
basic_ostream& operator<<( bool value );
|
(6) | |||
basic_ostream& operator<<( const void* value );
|
(7) | |||
basic_ostream& operator<<( CharT ch );
basic_ostream& operator<<( signed char ch ); |
(8) | this operator is declared outside the class body
|
||
basic_ostream& operator<<( CharT* s );
basic_ostream& operator<<( signed char* s ); |
(9) | this operator is declared outside the class body
|
||
basic_ostream&
operator<<( ios_base& (*func)(ios_base&) ); |
(10) | this operator is declared outside the class body | ||
basic_ostream& operator<<( basic_streambuf<CharT,Traits>* sb );
|
(11) | this operator is declared outside the class body | ||
Inserts data to the stream.
The (1-8) versions of the operator behave as formatted output functions. That is, they construct a sentry object at the beginning that flushes the buffers if needed and checks for errors. The output is written only if the sentry object returns true.
1-4) Inserts an integer value
5) Inserts a floating point value
6) Inserts bool value
7) Inserts a generic pointer value
8) Inserts a character
9) Inserts a character string. The characters are extracted until a whitespace character is found.
10) Calls func(*this);
11) Inserts all data from sb. The insertion stops if one of the following conditions are met:
- end-of-file occurs on the input sequence;
- inserting in the output sequence fails (in which case the character to be inserted is not extracted);
- an exception occurs (in which case the exception is caught).
Contents |
[edit] Parameters
value | - | reference to an integer value to insert | ||
ch | - | reference to a character to insert | ||
s | - | pointer to a character string to insert | ||
func | - | function to call
|
||
sb | - | pointer to the streambuffer to read the data from |
[edit] Return value
*this
[edit] Example
This section is incomplete |
[edit] See also
|
inserts a character (public member function) |
|
|
inserts blocks of characters (public member function) |