std::setfill
來自 cppreference.com
定義於標頭檔案 <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) { // set fill character str.fill(c); }
[編輯] 注意
當前的填充字元可以透過 std::ostream::fill 獲取。
[編輯] 示例
執行此程式碼
輸出
default fill: [ 42] setfill('*'): [********42]
[編輯] 缺陷報告
下列更改行為的缺陷報告追溯地應用於以前出版的 C++ 標準。
缺陷報告 | 應用於 | 釋出時的行為 | 正確的行為 |
---|---|---|---|
LWG 183 | C++98 | setbase 只能與型別為 std::ostream 的流一起使用 |
可用於任何輸出 字元流 |
[編輯] 另請參閱
管理填充字元 ( std::basic_ios<CharT,Traits> 的公共成員函式) | |
設定填充字元的位置 (函式) | |
更改下一個輸入/輸出欄位的寬度 (函式) |