名稱空間
變體
操作

std::generic_category

來自 cppreference.com
< cpp‎ | 錯誤
定義於標頭檔案 <system_error>
const std::error_category& generic_category() noexcept;
(C++11 起)

獲取通用錯誤的靜態錯誤類別物件的引用。該物件需要重寫虛擬函式 error_category::name() 以返回指向字串 "generic" 的指標。它用於識別與 POSIX errno 程式碼對應的錯誤條件。

目錄

[編輯] 引數

(無)

[編輯] 返回值

對靜態物件的引用,該靜態物件的執行時型別未指定,派生自 std::error_category

[編輯] 示例

#include <cerrno>
#include <iostream>
#include <string>
#include <system_error>
 
int main()
{
    std::error_condition econd = std::generic_category().default_error_condition(EDOM);
    std::cout << "Category: " << econd.category().name() << '\n'
              << "Value: " << econd.value() << '\n'
              << "Message: " << econd.message() << '\n';
}

輸出

Category: generic
Value: 33
Message: Numerical argument out of domain

[編輯] 參閱

標識作業系統錯誤類別
(函式) [編輯]
(C++11)
列出所有標準 <cerrno> 宏常量的 std::error_condition 列舉
(類) [編輯]