std:: setfill
From cppreference.net
|
定义于头文件
<iomanip>
|
||
|
template
<
class
CharT
>
/*unspecified*/ setfill ( CharT c ) ; |
||
当在表达式 out << setfill ( c ) 中使用时,会将流 out 的填充字符设置为 c 。
目录 |
参数
| c | - | 填充字符的新值 |
返回值
一个未指定类型的对象,使得
-
如果
out
是类型为
std::
basic_ostream
<
CharT, Traits
>
的对象,则表达式
out
<<
setfill
(
c
)
- 具有类型 std:: basic_ostream < CharT, Traits > &
- 具有值 out
- 行为如同调用了 f ( out, c )
其中函数 f 定义为:
template<class CharT, class Traits> void f(std::basic_ios<CharT, Traits>& str, CharT c) { // 设置填充字符 str.fill(c); }
注释
当前填充字符可通过 std::ostream::fill 获取。
示例
运行此代码
输出:
default fill: [ 42]
setfill('*'): [********42]
缺陷报告
以下行为变更缺陷报告被追溯应用于先前发布的C++标准。
| 缺陷报告 | 应用于 | 发布时的行为 | 正确行为 |
|---|---|---|---|
| LWG 183 | C++98 |
setbase
仅能用于
类型为 std::ostream 的流 |
可用于任何输出
字符流 |
参见
|
管理填充字符
(
std::basic_ios<CharT,Traits>
的公开成员函数)
|
|
|
设置填充字符的位置
(函数) |
|
|
更改下一个输入/输出字段的宽度
(函数) |