Defined in the header file <ostream>
template< class CharT, |
Class template basic_ostream
Provides high-level output operations on character streams. Supported operations include formatted output (such as integer values) and unformatted output (such as raw characters and character arrays). This functionality basic_streambuf
is implemented with the interface provided by the class, basic_ios
accessed through the base class. In a typical implementation, basic_ostream
there are no non-inherited data members.
Two specializations for common character types are also provided:
defined in the header file |
|
type | definition |
ostream |
basic_ostream<char> |
wostream |
basic_ostream<wchar_t> |
global object
The standard library provides six global basic_ostream objects.
defined in the header file |
|
coutwcout |
Writes to the standard C output stream stdout (global object) |
cerrwcerr |
Write to the standard C error stream stderr, unbuffered (global object) |
clockwork |
Writes to the standard C error stream stderr (global object) |
member type
member type | definition |
char_type |
CharT |
traits_type |
Traits ; if Traits::char_type not CharT the program is ill-formed. |
int_type |
Traits::int_type |
pos_type |
Traits::pos_type |
off_type |
Traits::off_type |
member function
(Constructor) |
Construct object (public member function) |
(destructor) [virtual] |
Destruct object (virtual public member function) |
operator= (C++11) |
basic_ostream move assignment from another (protected member function) |
formatted output |
|
operator<< |
Insert formatted data (public member function) |
unformatted output |
|
put |
caret character (public member function) |
write |
insert character block (public member function) |
locate |
|
tellp |
Returns the output position indicator (public member function) |
seekp |
set output position indicator (public member function) |
miscellaneous |
|
flush |
Synchronize with the underlying storage device (public member function) |
swap (C++11) |
Swap stream objects, except associated buffers (protected member function) |
member class
sentry |
Implements basic logic for stream preparation for output operations (public member class) |
non-member function
operator<<(std::basic_ostream) |
insert character data |
Inherited from std::basic_ios
member type
member type | definition |
char_type |
CharT |
traits_type |
Traits |
int_type |
Traits::int_type |
pos_type |
Traits::pos_type |
off_type |
Traits::off_type |
member function
state function |
|
good |
Check that no errors have occurred, such as whether I/O operations can be performed ( std::basic_ios<CharT,Traits> public member functions) |
eof |
Check if end of file has been reached ( std::basic_ios<CharT,Traits> public member function of |
fail |
Checks if a recoverable error has occurred ( std::basic_ios<CharT,Traits> public member function of |
bad |
检查是否已发生不可恢复的错误 ( std::basic_ios<CharT,Traits> 的公开成员函数) |
operator! |
检查是否有错误发生(fail() 的同义词) ( std::basic_ios<CharT,Traits> 的公开成员函数) |
operator void*operator bool (C++11 前)(C++11 起) |
检查是否没有发生错误(!fail()的同义词) ( std::basic_ios<CharT,Traits> 的公开成员函数) |
rdstate |
返回状态标志 ( std::basic_ios<CharT,Traits> 的公开成员函数) |
setstate |
设置状态标志 ( std::basic_ios<CharT,Traits> 的公开成员函数) |
clear |
修改状态标志 ( std::basic_ios<CharT,Traits> 的公开成员函数) |
格式化 |
|
copyfmt |
复制格式化信息 ( std::basic_ios<CharT,Traits> 的公开成员函数) |
fill |
管理填充字符 ( std::basic_ios<CharT,Traits> 的公开成员函数) |
杂项 |
|
exceptions |
管理异常掩码 ( std::basic_ios<CharT,Traits> 的公开成员函数) |
imbue |
设置本地环境 ( std::basic_ios<CharT,Traits> 的公开成员函数) |
rdbuf |
管理相关的流缓冲区 ( std::basic_ios<CharT,Traits> 的公开成员函数) |
tie |
管理绑定的流 ( std::basic_ios<CharT,Traits> 的公开成员函数) |
narrow |
窄化字符 ( std::basic_ios<CharT,Traits> 的公开成员函数) |
widen |
拓宽字符 ( std::basic_ios<CharT,Traits> 的公开成员函数) |
继承自 std::ios_base
成员函数
格式化 |
|
flags |
管理格式标志 ( std::ios_base 的公开成员函数) |
setf |
设置特定格式标志 ( std::ios_base 的公开成员函数) |
unsetf |
清除特定格式的标志 ( std::ios_base 的公开成员函数) |
precision |
管理浮点操作的精度 ( std::ios_base 的公开成员函数) |
width |
管理域的宽度 ( std::ios_base 的公开成员函数) |
本地环境 |
|
imbue |
设置本地环境 ( std::ios_base 的公开成员函数) |
getloc |
返回当前本地环境 ( std::ios_base 的公开成员函数) |
内部可扩展数组 |
|
xalloc [静态] |
返回能安全用作 pword() 和 iword() 下标的程序范围内独有的整数 ( std::ios_base 的公开静态成员函数) |
iword |
如果有必要的话,调整私有存储的大小,并且访问位于提供的下标的long元素 ( std::ios_base 的公开成员函数) |
pword |
若需要则重置私有存储的大小,并访问位于指定下标的 void* 元素 ( std::ios_base 的公开成员函数) |
杂项 |
|
register_callback |
注册事件回调函数 ( std::ios_base 的公开成员函数) |
sync_with_stdio [静态] |
设置C++和C的IO库是否可以互操作 ( std::ios_base 的公开静态成员函数) |
成员类 |
|
failure |
流异常 ( std::ios_base 的公开成员类) |
Init |
初始化标准流对象 ( std::ios_base 的公开成员类) |
成员类型和常量 |
|||||||||||||||||||||||||||||||||||||||
类型 | 解释 | ||||||||||||||||||||||||||||||||||||||
openmode |
流打开模式类型 亦定义下列常量:
(typedef) |
||||||||||||||||||||||||||||||||||||||
fmtflags |
格式化标志类型 亦定义下列常量:
(typedef) |
||||||||||||||||||||||||||||||||||||||
iostate |
流状态类型 亦定义下列常量:
(typedef) |
||||||||||||||||||||||||||||||||||||||
seekdir |
寻位方向类型 亦定义下列常量:
(typedef) |
||||||||||||||||||||||||||||||||||||||
event |
指定事件类型 (枚举) |
||||||||||||||||||||||||||||||||||||||
event_callback |
回调函数类型 (typedef) |