• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

    最終更新日時(UTC):
    が更新

    履歴 編集

    function
    <string>

    std::char_traits::eof

    static int_type eof();                    // C++03
    static constexpr int_type eof() noexcept; // C++11
    

    概要

    ファイル終端文字(EOF)を表す数値を取得する。

    戻り値

    文字集合の全ての文字cに対してeq_int_type(e, to_int_type(c)) == falseとなるようなeを返す。

    標準で定義される特殊化は、以下の値を返す:

    • char: 定数値EOFを返す。
    • char8_t: UTF-8の文字単位として有効な、実装定義のEOFを表す定数値を返す。
    • char16_t: UTF-16の文字単位として有効な、実装定義のEOFを表す定数値を返す。
    • char32_t: Unicodeコードポイントとしての、実装定義のEOFを表す定数値を返す。
    • wchar_t: 定数値WEOFを返す。

    計算量

    定数時間

    #include <iostream>
    #include <string>
    
    int main()
    {
      int eof = std::char_traits<char>::eof();
      std::cout << eof << std::endl;
    }
    

    出力例

    -1
    

    参照