std::basic_ostream::operator<<

来自cppreference.com
< cpp‎ | io‎ | basic ostream

 
 
输入/输出库
I / O操纵
C-风格的I / O
缓冲区
原文:
Buffers
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
basic_streambuf
basic_filebuf
basic_stringbuf
strstreambuf(已弃用)
原文:
Streams
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
抽象
原文:
Abstractions
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
ios_base
basic_ios
basic_istream
basic_ostream
basic_iostream
文件I / O
原文:
File I/O
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
basic_ifstream
basic_ofstream
basic_fstream
字符串I / O
原文:
String I/O
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
basic_istringstream
basic_ostringstream
basic_stringstream
阵列的I / O
原文:
Array I/O
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
istrstream(已弃用)
ostrstream(已弃用)
strstream(已弃用)
类型
原文:
Types
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
streamoff
streamsize
fpos
Error类的接口
原文:
Error category interface
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
iostream_category(C++11)
io_errc(C++11)
 
std::basic_ostream
全局对象
原文:
Global objects
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
成员函数
原文:
Member functions
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
basic_ostream::basic_ostream
basic_ostream::~basic_ostream
basic_ostream::operator=(C++11)
格式化的输入
原文:
Formatted input
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
basic_ostream::operator<<
未格式化的输入
原文:
Unformatted input
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
basic_ostream::put
basic_ostream::write
定位
原文:
Positioning
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
basic_ostream::tellp
basic_ostream::seekp
杂项
原文:
Miscellaneous
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
basic_ostream::flush
basic_ostream::swap(C++11)
会员类别
原文:
Member classes
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
basic_ostream::sentry
非成员函数
原文:
Non-member functions
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
operator<<(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 起)
basic_ostream& operator<<( float value );

basic_ostream& operator<<( double value );

basic_ostream& operator<<( long double value );
(5)
basic_ostream& operator<<( bool value );
(6)
basic_ostream& operator<<( const void* value );
(7)
basic_ostream& operator<<( std::basic_streambuf<CharT, Traits>* sb);
(8)
basic_ostream& operator<<( basic_ostream& st,

                           std::ios_base& (*func)(std::ios_base&) );
basic_ostream& operator<<( basic_ostream& st,
                           std::basic_ios<CharT,Traits>& (*func)(std::basic_ios<CharT,Traits>&) );
basic_ostream& operator<<( basic_ostream& st,

                           std::basic_ostream& (*func)(std::basic_ostream&) );
(9)
数据插入到流
原文:
Inserts data into the stream.
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
格式的输出功能。(1-7)版本的运营商的行为,而8)版本的数据的行为视为未格式化的输出功能。这些函数开始执行构造一个对象的类型sentry,刷新tie()'d的输出缓冲区,如果必要的检查流错误。项目建成后,如果哨兵对象返回false,函数返回没有尝试任何输出。如果发生错误,在输出过程中,格式化输出函数设置setstate(ios_base::failbit)。如果抛出一个异常,然后在输出的ios :: badbit((exceptions()&badbit) != 0被抑制,除非,在这种情况下,它被重新抛出异常)
原文:
The (1-7) versions of the operator behave as formatted output functions, and the 8) version behaves as unformatted output function. These functions 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, the functions return without attempting any output. If an error occurs during output, formatted output functions set 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 Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
1-2)
如果valueshortint,然后将其转换为unsigned shortunsigned int如果ios_base::flags() & ios_base::basefieldios_base::octios_base::hex。之后,在任何情况下,在3输出转换long)。如果valueunsigned shortunsigned int,蒙上unsigned long和输出的3)
原文:
If value is short or int, then casts it to unsigned short or unsigned int if ios_base::flags() & ios_base::basefield is ios_base::oct or ios_base::hex. After that, casts to long in any case and outputs as in 3). If value is unsigned short or unsigned int, casts to unsigned long and outputs as in 3)
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
3-4)
将一个整数值,通过调用num_put::put()。如果最终文件的情况过程中遇到的输出(put().failed() == true),设置ios::badbit.
原文:
Inserts an integer value by calling num_put::put(). If the end of file condition was encountered during output (put().failed() == true), sets ios::badbit.
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
5)
将一个浮点值,通过调用过程中遇到的输出(num_put::put()put().failed() == true如果最终文件的情况,设置ios::badbit.
原文:
Inserts a floating point value by calling num_put::put() If the end of file condition was encountered during output (put().failed() == true), sets ios::badbit.
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
6)
插入bool值通过调用num_put::put()如果最终的文件条件的过程中遇到的输出(put().failed() == true),设置ios::badbit.
原文:
Inserts bool value by calling num_put::put() If the end of file condition was encountered during output (put().failed() == true), sets ios::badbit.
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
7)
通过调用num_put::put()如果最终的文件条件的过程中遇到的输出(put().failed() == true)插入一个通用的指针值,设置ios::badbit.
原文:
Inserts a generic pointer value by calling num_put::put() If the end of file condition was encountered during output (put().failed() == true), sets ios::badbit.
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
8)
将所有数据从sb。构建哨兵对象后,检查是否sb是一个空指针。如果是的话,执行setstate(badbit)并退出。否则,提取的字符输入序列sb,并将其插入到控制*this,直到满足以下条件:1
原文:
Inserts all data from sb. After constructing the sentry object, checks if sb is a null pointer. If it is, executes setstate(badbit) and exits. Otherwise, extracts characters from the input sequence controlled by sb and inserts them into *this until one of the following conditions are met:
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
  • 文件结束发生在输入序列中;
    原文:
    end-of-file occurs on the input sequence;
    这段文字是通过 Google Translate 自动翻译生成的。
    您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
  • 插入输出序列中的失败(在这种情况下,要被插入的字符没有提取);
    原文:
    inserting in the output sequence fails (in which case the character to be inserted is not extracted);
    这段文字是通过 Google Translate 自动翻译生成的。
    您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
  • 异常发生时(在这种情况下,异常被捕获).
    原文:
    an exception occurs (in which case the exception is caught).
    这段文字是通过 Google Translate 自动翻译生成的。
    您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
如果没有字符被插入,执行setstate(badbit)。如果一个异常被抛出,而提取,设置failbit
原文:
If no characters were inserted, executes setstate(badbit). If an exception was thrown while extracting, sets failbit
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
9)
调用func(*this);。此重载是用来实现输出I / O操纵,如std::endl.
原文:
Calls func(*this);. This overload is used to implement output I/O manipulators such as std::endl.
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里

目录

[编辑] 参数

value -
整数,浮点型,布尔型,或指针的值插入
原文:
integer, floating-point, boolean, or pointer value to insert
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
func -
要调用的函数
原文:
function to call
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里
sb -
指针的streambuffer阅读
原文:
pointer to the streambuffer to read the data from
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里

[编辑] 返回值

*this

[编辑] 注释

有没有过载,易挥发或函数指针的指针(其他的签名,比那些接受9)过载)。试图输出这些对象调用隐式转换为bool,对于任何非空指针值,该值1打印(除非boolalpha设置),.
原文:
There are no overload for pointers to volatile or function pointers (other than the ones with signatures accepted by the 9) overload). Attempting to output such objects invokes implicit conversion to bool, and, for any non-null pointer value, the value 1 is printed (unless boolalpha was set).
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里

[编辑] 示例

#include <iostream>
#include <iomanip>
#include <sstream>
int main()
{
    std::istringstream input(" \"Some text.\" ");
    volatile int n = 42;
    double f = 3.14;
    bool b = true;;
    std::cout << n   // int overload
              << ' ' // non-member overload
              << std::boolalpha << b // bool overload
              << " " // non-member overload
              << std::fixed << f // double overload
              << input.rdbuf() // streambuf overload
              << &n // bool overload
              << std::endl; // function overload
}

输出:

42 true 3.140000 "Some text." true

[编辑] 另请参阅

插入字符数据
原文:
inserts character data
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里

(函数) [edit]
一个整数值,通过调用执行I / O流的字符串
原文:
performs stream I/O of strings
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里

(函数模板)
执行流的输入和输出的位集
原文:
performs stream input and output of bitsets
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里

(函数)
序列化和反序列化一个复杂的数
原文:
serializes and deserializes a complex number
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里

(函数模板)
执行流的输入和输出的伪随机数的发动机
原文:
performs stream input and output on pseudo-random number engine
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里

(函数) [edit]
执行流输入和输出的伪随机数分布
原文:
performs stream input and output on pseudo-random number distribution
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里

(函数) [edit]
插入一个字符
原文:
inserts a character
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里

(公共成员函数) [edit]
插入的字符块
原文:
inserts blocks of characters
这段文字是通过 Google Translate 自动翻译生成的。
您可以帮助我们检查、纠正翻译中的错误。详情请点击这里

(公共成员函数) [edit]