operator<<(std::basic_ostream)
| (1) | ||
| template< class CharT, class Traits> basic_ostream<CharT,Traits>& operator<<( basic_ostream<CharT,Traits>& os, |
||
| template< class CharT, class Traits> basic_ostream<CharT,Traits>& operator<<( basic_ostream<CharT,Traits>& os, |
||
| template< class Traits > basic_ostream<char,Traits>& operator<<( basic_ostream<char,Traits>& os, |
||
| template< class Traits > basic_ostream<char,Traits>& operator<<( basic_ostream<char,Traits>& os, |
||
| template< class Traits > basic_ostream<char,Traits>& operator<<( basic_ostream<char,Traits>& os, |
||
| (2) | ||
| template< class CharT, class Traits > basic_ostream<CharT,Traits>& operator<<( basic_ostream<CharT,Traits>& os, |
||
| template< class CharT, class Traits > basic_ostream<CharT,Traits>& operator<<( basic_ostream<CharT,Traits>& os, |
||
| template< class Traits > basic_ostream<char,Traits>& operator<<( basic_ostream<char,Traits>& os, |
||
| template< class Traits > basic_ostream<char,Traits>& operator<<( basic_ostream<char,Traits>& os, |
||
| template< class Traits > basic_ostream<char,Traits>& operator<<( basic_ostream<char,traits>& os, |
||
| template< class CharT, class Traits, class T > basic_ostream< charT, traits >& operator<<( basic_ostream<CharT,Traits>&& os, |
(3) | (since C++11) |
Inserts a character or a character string.
FormattedOutputFunction. After constructing and checking the sentry object, inserts the character ch. If the type of the character is not CharT, it is first converted with os.widen(ch). Padding is determined as if by Stage 3 of num_put::put(). After insertion, width(0) is called to cancel the effects of std::setw, if any.FormattedOutputFunction. After constructing and checking the sentry object, inserts successive characters from the character array whose first element is pointed to by s.
- for the first and third overloads (where
CharTmatches the type ofch), exactlytraits::length(s)characters are inserted. - for the second overload, exactly std::char_traits<char>::length(s) characters are inserted.
- for the last two overloads, exactly traits::length(reinterpret_cast<const char*>(s)) are inserted.
Contents |
[edit] Parameters
| os | - | output stream to insert data to |
| ch | - | reference to a character to insert |
| s | - | pointer to a character string to insert |
[edit] Return value
st
[edit] Example
#include <iostream> #include <sstream> int main() { std::cout << "Hello, world" // the const char* overload << '\n'; // the char overload std::string s = (std::ostringstream() << 1.2).str(); // rvalue overload std::cout << s << '\n'; }
Output:
Hello, world 1.2
[edit] See also
| inserts formatted data (public member function) | |