• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <ios>

    std::make_error_code

    namespace std {
      error_code make_error_code(io_errc e);          // C++11
      error_code make_error_code(io_errc e) noexcept; // C++14
    }
    

    概要

    io_errcからerror_codeを生成する

    戻り値

    error_code(static_cast<int>(e), iostream_category())

    例外

    投げない

    #include <iostream> // 自動的に<ios>もインクルードされる
    #include <string>
    
    int main()
    {
      std::error_code ec = std::make_error_code(std::io_errc::stream);
    
      std::cout << "category : " << ec.category().name() << std::endl;
      std::cout << "value : " << ec.value() << std::endl;
      std::cout << "message : " << ec.message() << std::endl;
    }
    

    出力例

    category : iostream
    value : 1
    message : iostream stream error
    

    バージョン

    言語

    • C++11

    処理系

    参照