operator==
測試運算子左邊的 物件是否等於右邊的 物件。
bool operator==(const error_code& left,
const error_condition& right);
bool operator==(const error_condition& left,
const error_code& right);
bool operator==(const error_condition& left,
const error_condition& right);
參數
left
要測試是否相等的物件。
right
要測試是否相等的物件。
傳回值
true 如果物件相等,則為 ; false 如果物件不相等,則為 。
備註
此函式會傳回 left.category() == right.category() && left.value() == right.value()。
operator!=
測試運算子左邊的 物件是否不等於右邊的 物件。
bool operator!=(const error_code& left, const error_condition& right);
bool operator!=(const error_condition& left, const error_code& right);
bool operator!=(const error_code& left, const error_code& right);
bool operator!=(const error_condition& left, const error_condition& right);
參數
left
要測試是否不相等的物件。
right
要測試是否不相等的物件。
傳回值
如果傳入 左 的物件不等於傳入 right的物件,true;否則 false。
備註
此函式會傳回 !(left == right)。
operator<
測試物件是否小於傳入的物件以進行比較。
template <class _Enum>
inline bool operator<(
_Enum left,
typename enable_if<is_error_code_enum<_Enum>::value,
const error_code&>::type right);
template <class _Enum>
inline bool operator<(
typename enable_if<is_error_code_enum<_Enum>::value,
const error_code&>::type left, _Enum right);
template <class _Enum>
inline bool operator<(
_Enum left,
typename enable_if<is_error_condition_enum<_Enum>::value,
const error_condition&>::type right);
template <class _Enum>
inline bool operator<(
typename enable_if<is_error_condition_enum<_Enum>::value,
const error_condition&>::type left, _Enum right);
參數
left
要比較的物件。
right
要比較的物件。
傳回值
如果傳入 left 的物件小於傳入 right的物件,true;否則,false。
備註
這個功能測試錯誤順序。
operator<<
將 error_code 物件插入輸出數據流。
template <class charT, class traits>
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& os, const error_code& ec);
參數
os
目標輸出數據流。
ec
要輸出 error_code 物件。
傳回值
已修改輸出數據流的參考。
備註
這個運算子會執行相當於 os << ec.category().name() << ':' << ec.value()。
例
#include <iostream>
#include <system_error>
int main()
{
std::error_code ec(1234, std::generic_category());
std::cout << ec;
}
generic:1234