std::basic_ostream
来自 cppreference.cn
定义于头文件 <ostream> |
||
template< class CharT, |
||
类模板basic_ostream
提供对字符流上高级输出操作的支持。支持的操作包括格式化输出(例如整数值)和非格式化输出(例如原始字符和字符数组)。此功能是根据basic_streambuf
类提供的接口实现的,通过basic_ios
基类访问。在典型的实现中,basic_ostream
没有非继承的数据成员。
继承图
提供了用于常见字符类型的几个 typedef
定义于头文件
<ostream> | |
类型 | 定义 |
std::ostream
|
std::basic_ostream<char> |
std::wostream
|
std::basic_ostream<wchar_t> |
目录 |
[编辑] 全局对象
标准库提供六个全局basic_ostream
对象
定义于头文件
<iostream> | |
写入标准 C 输出流 stdout (全局对象) | |
写入标准 C 错误流 stderr,无缓冲 (全局对象) | |
写入标准 C 错误流 stderr (全局对象) |
[编辑] 成员类型
成员类型 | 定义 |
char_type
|
CharT |
traits_type
|
Traits ;如果Traits::char_type 不是CharT ,则程序格式不正确。 |
int_type
|
Traits::int_type |
pos_type
|
Traits::pos_type |
off_type
|
Traits::off_type |
[编辑] 成员函数
构造对象 (public member function) | |
[虚函数] |
析构对象 (virtual public member function) |
(C++11) |
从另一个basic_ostream 移动赋值(protected member function) |
格式化输出 | |
插入格式化数据 (public member function) | |
非格式化输出 | |
插入一个字符 (public member function) | |
插入字符块 (public member function) | |
定位 | |
返回输出位置指示器 (public member function) | |
设置输出位置指示器 (public member function) | |
杂项 | |
与底层存储设备同步 (public member function) | |
(C++11) |
交换流对象,除了关联缓冲区 (protected member function) |
[编辑] 成员类
实现流为输出操作准备的基本逻辑 (public member class) |
[编辑] 非成员函数
插入字符数据或插入到右值流中 (函数模板) | |
(C++23) |
输出参数的格式化表示 (函数模板) |
(C++23) |
输出带附加 '\n' 的参数格式化表示 (函数模板) |
(C++23) |
使用类型擦除的参数表示执行 Unicode 感知输出 (函数) |
使用类型擦除的参数表示输出字符数据 (函数) |
继承自 std::basic_ios
成员类型
成员类型 | 定义 |
char_type
|
CharT
|
traits_type
|
特性
|
int_type
|
Traits::int_type
|
pos_type
|
Traits::pos_type
|
off_type
|
Traits::off_type
|
成员函数
状态函数 | |
检查是否没有发生错误,即 I/O 操作可用 ( std::basic_ios<CharT,Traits> 的公共成员函数) | |
检查是否已到达文件末尾 ( std::basic_ios<CharT,Traits> 的公共成员函数) | |
检查是否发生错误 ( std::basic_ios<CharT,Traits> 的公共成员函数) | |
检查是否发生不可恢复的错误 ( std::basic_ios<CharT,Traits> 的公共成员函数) | |
检查是否发生错误(fail() 的同义词) ( std::basic_ios<CharT,Traits> 的公共成员函数) | |
检查是否没有发生错误(! fail() 的同义词)( std::basic_ios<CharT,Traits> 的公共成员函数) | |
返回状态标志 ( std::basic_ios<CharT,Traits> 的公共成员函数) | |
设置状态标志 ( std::basic_ios<CharT,Traits> 的公共成员函数) | |
修改状态标志 ( std::basic_ios<CharT,Traits> 的公共成员函数) | |
格式化 | |
复制格式化信息 ( std::basic_ios<CharT,Traits> 的公共成员函数) | |
管理填充字符 ( std::basic_ios<CharT,Traits> 的公共成员函数) | |
杂项 | |
管理异常掩码 ( std::basic_ios<CharT,Traits> 的公共成员函数) | |
设置区域设置 ( std::basic_ios<CharT,Traits> 的公共成员函数) | |
管理关联的流缓冲区 ( std::basic_ios<CharT,Traits> 的公共成员函数) | |
管理绑定的流 ( std::basic_ios<CharT,Traits> 的公共成员函数) | |
窄化字符 ( std::basic_ios<CharT,Traits> 的公共成员函数) | |
宽化字符 ( std::basic_ios<CharT,Traits> 的公共成员函数) |
继承自 std::ios_base
成员函数
格式化 | |
管理格式标志 ( std::ios_base 的公共成员函数) | |
设置特定格式标志 ( std::ios_base 的公共成员函数) | |
清除特定格式标志 ( std::ios_base 的公共成员函数) | |
管理浮点运算的十进制精度 ( std::ios_base 的公共成员函数) | |
管理字段宽度 ( std::ios_base 的公共成员函数) | |
区域设置 | |
设置区域设置 ( std::ios_base 的公共成员函数) | |
返回当前区域设置 ( std::ios_base 的公共成员函数) | |
内部可扩展数组 | |
[静态] |
返回一个程序范围内的唯一整数,可安全用作 pword() 和 iword() 的索引 ( std::ios_base 的公共静态成员函数) |
如有必要,调整私有存储的大小,并访问给定索引处的 long 元素 ( std::ios_base 的公共成员函数) | |
如有必要,调整私有存储的大小,并访问给定索引处的 void* 元素 ( std::ios_base 的公共成员函数) | |
杂项 | |
注册事件回调函数 ( std::ios_base 的公共成员函数) | |
[静态] |
设置 C++ 和 C I/O 库是否可互操作 ( std::ios_base 的公共静态成员函数) |
成员类 | |
流异常 ( std::ios_base 的公共成员类) | |
初始化标准流对象 ( std::ios_base 的公共成员类) |
成员类型和常量 | |||||||||||||||||||||||||||||||||||||||
类型 | 解释 | ||||||||||||||||||||||||||||||||||||||
流打开模式类型 还定义了以下常量
(类型定义) | |||||||||||||||||||||||||||||||||||||||
格式化标志类型 还定义了以下常量
(类型定义) | |||||||||||||||||||||||||||||||||||||||
流状态类型 还定义了以下常量
(类型定义) | |||||||||||||||||||||||||||||||||||||||
定位方向类型 还定义了以下常量
(类型定义) | |||||||||||||||||||||||||||||||||||||||
指定事件类型 (枚举) | |||||||||||||||||||||||||||||||||||||||
回调函数类型 (类型定义) |