[ Web Proxy ]
URL:
Viewing: https://ru.cppreference.com/cpp/io/basic_ostream/operator_ltlt2 [Back]  [Original]

operator<<<div class="t-tr-text">(STD :: basic_ostream)<div class="t-tr-dropdown"><div><div><div class="t-tr-dropdown-arrow-border"></div><div class="t-tr-dropdown-arrow"></div><div class="t-tr-dropdown-h">:</div><div class="t-tr-dropdown-orig">(std::basic_ostream)</div><div class="t-tr-dropdown-notes"> [http://translate.google.com Google].<br/> . [http://en.cppreference.com/w/Cppreference:MachineTranslations ].</div></div></div></div></div> cppreference.com
cppreference.com

operator<<<div class="t-tr-text">(STD :: basic_ostream)<div class="t-tr-dropdown"><div><div><div class="t-tr-dropdown-arrow-border"></div><div class="t-tr-dropdown-arrow"></div><div class="t-tr-dropdown-h">:</div><div class="t-tr-dropdown-orig">(std::basic_ostream)</div><div class="t-tr-dropdown-notes"> [http://translate.google.com Google].<br/> . [http://en.cppreference.com/w/Cppreference:MachineTranslations ].</div></div></div></div></div>

cppreference.com

<metanoindex/>

<tbody> </tbody>
template< class CharT, class Traits> basic_ostream<CharT,Traits>& operator<<( basic_ostream<CharT,Traits>& os, CharT ch ); template< class CharT, class Traits> basic_ostream<CharT,Traits>& operator<<( basic_ostream<CharT,Traits>& os, char ch ); template< class Traits > basic_ostream<char,Traits>& operator<<( basic_ostream<char,Traits>& os, char ch ); template< class Traits > basic_ostream<char,Traits>& operator<<( basic_ostream<char,Traits>& os, signed char ch ); template< class Traits > basic_ostream<char,Traits>& operator<<( basic_ostream<char,Traits>& os, unsigned char ch );
(1)
template< class CharT, class Traits > basic_ostream<CharT,Traits>& operator<<( basic_ostream<CharT,Traits>& os, const CharT* s ); template< class CharT, class Traits > basic_ostream<CharT,Traits>& operator<<( basic_ostream<CharT,Traits>& os, const char* s ); template< class Traits > basic_ostream<char,Traits>& operator<<( basic_ostream<char,Traits>& os, const char* s ); template< class Traits > basic_ostream<char,Traits>& operator<<( basic_ostream<char,Traits>& os, const signed char* s ); template< class Traits > basic_ostream<char,Traits>& operator<<( basic_ostream<char,traits>& os, const unsigned char* s );
(2)
template< class CharT, class Traits, class T > basic_ostream< charT, traits >& operator<<( basic_ostream<CharT,Traits>&& os, const T& value );
(3) ( C++11)
.
:
Inserts a character or a character string.
Google.
. .

1-2)

: sentry, tie()'d . , false, . , setstate(ios_base::failbit). , IOS :: badbit ( , exceptions()&badbit) != 0, )
:
are formatted output functions: they begin execution by constructing an object of type sentry, which flushes the tie()'d output buffers if necessary and checks the stream errors. After construction, if the sentry object returns false, these functions return without attempting any output. If an error occurs during output, these functions call setstate(ios_base::failbit). If an exception is thrown during output, then ios::badbit is set (the exception is suppressed unless exceptions()&badbit) != 0, in which case it is rethrown)
Google.
. .

1)

ch. CharT, os.widen(ch). 3 num_put::put(). , width(0) .
:
Inserts a 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.
Google.
. .

2)

, , s.
:
Inserts successive characters from the character array whose first element is pointed to by s.
Google.
. .
  • ( CharT ch), traits::length(s) .
    :
    for the first and third overloads (where CharT matches the type of ch), exactly traits::length(s) characters are inserted.
    Google.
    . .
  • , std::char_traits<char>::length(s) .
    :
    for the second overload, exactly std::char_traits<char>::length(s) characters are inserted.
    Google.
    . .
  • , traits::length(reinterpret_cast<const char*>(s)) .
    :
    for the last two overloads, exactly traits::length(reinterpret_cast<const char*>(s)) are inserted.
    Google.
    . .
3 num_put::put(). os.widen() . , width(0) .
:
Padding is determined as if by Stage 3 of num_put::put(). All characters are widened using os.widen() before insertion. After insertion, width(0) is called.
Google.
. .

3)

, RValue ( os << value).
:
Calls the appropriate insertion operator, given an rvalue reference to an output stream object (equivalent to os << value).
Google.
. .

os
:
output stream to insert data to
Google.
. .
ch
:
reference to a character to insert
Google.
. .
s
:
pointer to a character string to insert
Google.
. .

st

#include <iostream>
#include <sstream>
int main()
{
    std::cout << "Hello, world" // the const char* overlaod
              << '\n';          // the char overload
    std::string s = (std::ostringstream() << 1.2).str(); // rvalue overload
    std::cout << s << '\n';
}

:

Hello, world
1.2

.

std::basic_ostream
(public -) []

Web Proxy Viewer  |  New URL  |  Original Page