std::skipws, std::noskipws
提供: cppreference.com
ヘッダ <ios> で定義
|
||
std::ios_base& skipws( std::ios_base& str ); |
(1) | |
std::ios_base& noskipws( std::ios_base& str ); |
(2) | |
書式付き入力関数による先行するホワイトスペースのスキップを有効化または無効化します (デフォルトで有効です)。 出力には効果がありません。
1) str.setf(std::ios_base::skipws) を呼んだかのように、ストリーム str
の skipws
フラグを有効化します。
2) str.unsetf(std::ios_base::skipws) を呼んだかのように、ストリーム str
の skipws
フラグを無効化します。
ホワイトスペースのスキップは std::basic_istream::sentry のコンストラクタによって行われます。 ストリームの設定されているロケールの std::ctype ファセットによってホワイトスペースとして分類される文字を読み込み、破棄します。
これは入出力ストリームであり、 std::basic_ostream 型の任意の out
に対する out << std::noskipws のような式や std::basic_istream 型の任意の in
に対する in >> std::noskipws のような式で呼ぶことができます。
目次 |
[編集] 引数
str | - | 入出力ストリームへの参照 |
[編集] 戻り値
str
(操作後のストリームへの参照)。
[編集] 例
Run this code
#include <iostream> #include <sstream> int main() { char c1, c2, c3; std::istringstream("a b c") >> c1 >> c2 >> c3; std::cout << "Default behavior: c1 = " << c1 << " c2 = " << c2 << " c3 = " << c3 << '\n'; std::istringstream("a b c") >> std::noskipws >> c1 >> c2 >> c3; std::cout << "noskipws behavior: c1 = " << c1 << " c2 = " << c2 << " c3 = " << c3 << '\n'; }
出力:
Default behavior: c1 = a c2 = b c3 = c noskipws behavior: c1 = a c2 = c3 = b
[編集] 関連項目
指定された ios_base のフラグをクリアします (関数) | |
指定された ios_base のフラグを設定します (関数) | |
ホワイトスペースを消費します (関数テンプレート) |