Namespaces
Variants

std:: skipws, std:: noskipws

From cppreference.net
< cpp ‎ | io ‎ | manip
Input/output manipulators
Floating-point formatting
Integer formatting
Boolean formatting
Field width and fill control
Other formatting
Whitespace processing
skipws noskipws
Output flushing
Status flags manipulation
Time and money I/O
(C++11)
(C++11)
(C++11)
(C++11)
Quoted manipulator
(C++14)
定義済みヘッダー <ios>
(1)
std:: ios_base & noskipws ( std:: ios_base & str ) ;
(2)

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

1) skipws フラグをストリーム str で有効にする。 str. setf ( std:: ios_base :: skipws ) を呼び出した場合と同様の効果を持つ。
2) ストリーム str skipws フラグを無効にします。これは str. unsetf ( std:: ios_base :: skipws ) を呼び出した場合と同様です。

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

これはI/Oマニピュレータであり、 out << std :: noskipws のように、 out std::basic_ostream 型の場合に呼び出されるか、あるいは in >> std :: noskipws のように、 in std::basic_istream 型の場合に呼び出されます。

目次

パラメータ

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 フラグを設定する
(関数)
空白文字を消費する
(関数テンプレート)