Skip to content

Latest commit

 

History

History
68 lines (52 loc) · 1.64 KB

make_error_code.md

File metadata and controls

68 lines (52 loc) · 1.64 KB

make_error_code

  • ios[meta header]
  • std[meta namespace]
  • function[meta id-type]
  • cpp11[meta cpp]
namespace std {
  error_code make_error_code(io_errc e);          // C++11
  error_code make_error_code(io_errc e) noexcept; // C++14
}
  • error_code[link /reference/system_error/error_code.md]
  • io_errc[link io_errc.md]

概要

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;
}
  • std::make_error_code[color ff0000]
  • std::io_errc::stream[link io_errc.md]
  • ec.category()[link /reference/system_error/error_code/category.md]
  • name()[link /reference/system_error/error_category/name.md]
  • ec.value()[link /reference/system_error/error_code/value.md]

出力例

category : iostream
value : 1
message : iostream stream error

バージョン

言語

  • C++11

処理系

参照