名前空間
変種
操作

std::skipws, std::noskipws

From cppreference.com
< cpp‎ | io‎ | manip
 
 
 
入出力マニピュレータ
浮動小数点フォーマット
整数フォーマット
boolフォーマット
フィールド幅と埋め文字制御
その他のフォーマット
空白文字の処理
skipwsnoskipws
出力のフラッシュ
(C++20)  

ステータスフラグの操作
時間と通貨のI/O
(C++11)
(C++11)
(C++11)
(C++11)
クォート付きマニピュレータ
(C++14)
 
ヘッダ<ios>で定義
std::ios_base& skipws( std::ios_base& str );
(1)
std::ios_base& noskipws( std::ios_base& str );
(2)

フォーマットされた入力関数による先行空白文字のスキップを有効または無効にします(デフォルトで有効)。出力には影響しません。

1) ストリーム strskipws フラグを、str.setf(std::ios_base::skipws) を呼び出すかのように有効にします。
2) ストリーム strskipws フラグを、str.unsetf(std::ios_base::skipws) を呼び出すかのように無効にします。

空白文字のスキップは、std::basic_istream::sentry のコンストラクタによって実行されます。これは、ストリームに埋め込まれたロケールの std::ctype ファセットによって空白文字として分類される文字を読み取って破棄します。

これは I/O マニピュレータであり、std::basic_ostream 型の任意の out に対して out << std::noskipws のような式、または std::basic_istream 型の任意の in に対して in >> std::noskipws のような式で呼び出すことができます。

目次

[編集] パラメータ

str - I/Oストリームへの参照

[編集] 戻り値

str (操作後のストリームへの参照)。

[編集]

#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フラグを設定する
(関数) [編集]
空白文字を消費する
(関数テンプレート) [編集]
English 日本語 中文(简体) 中文(繁體)