empty

提供:cppreference.com
移動: 案内, 検索

Syntax:

    #include <string>
    bool empty() const;

empty()関数は、要素がからの時に true を返します。それ以外は、 false を返します。

例:

    string s1;
    string s2("");
    string s3("This is a string");
    cout.setf(ios::boolalpha);
    cout << s1.empty() << endl;
    cout << s2.empty() << endl;
    cout << s3.empty() << endl;

出力結果:

    true
    true
    false

Related Topics: size

個人用ツール
名前空間
変種
操作
案内
ツールボックス
他の言語