- system_error[meta header]
- std[meta namespace]
- function[meta id-type]
- cpp11[meta cpp]
namespace std {
bool operator==(const error_code& lhs, const error_code& rhs) noexcept; // (1) C++11
bool operator==(const error_code& lhs, const error_condition& rhs) noexcept; // (2) C++11
bool operator==(const error_condition& lhs, const error_condition& rhs) noexcept; // (3) C++11
// (2)により以下のオーバーロードが使用可能になる (C++20)
bool operator==(const error_condition& lhs, const error_code& rhs) noexcept; // (4) C++11
}
- error_code[link /reference/system_error/error_code.md]
- error_condition[link /reference/system_error/error_condition.md]
error_code
, error_condition
の等値比較を行う
-
(1) :
lhs.category() == rhs.category() && lhs.value() == rhs.value()
- category()[link error_code/category.md]
- value()[link error_code/value.md]
-
(2) :
lhs.category().equivalent(lhs.value(), rhs) || rhs.category().equivalent(lhs, rhs.value())
- lhs.category()[link error_code/category.md]
- rhs.category()[link error_condition/category.md]
- equivalent[link error_category/equivalent.md]
- lhs.value()[link error_code/value.md]
- rhs.value()[link error_condition/value.md]
-
(3) :
lhs.category() == rhs.category() && lhs.value() == rhs.value()
- category()[link error_condition/category.md]
- value()[link error_condition/value.md]
-
(4) :
rhs.category().equivalent(rhs.value(), lhs) || lhs.category().equivalent(rhs, lhs.value())
- lhs.category()[link error_condition/category.md]
- rhs.category()[link error_code/category.md]
- equivalent[link error_category/equivalent.md]
- lhs.value()[link error_condition/value.md]
- rhs.value()[link error_code/value.md]
投げない
#include <iostream>
#include <system_error>
int main()
{
std::error_code ec1 = std::make_error_code(std::errc::invalid_argument);
std::error_code ec2 = std::make_error_code(std::errc::permission_denied);
std::error_condition ed1 = std::make_error_condition(std::errc::invalid_argument);
std::error_condition ed2 = std::make_error_condition(std::errc::permission_denied);
std::cout << std::boolalpha;
std::cout << "error_code == error_code : " << (ec1 == ec1) << std::endl;
std::cout << "error_code == error_code : " << (ec1 == ec2) << std::endl;
std::cout << "error_code == error_condition : " << (ec1 == ed1) << std::endl;
std::cout << "error_code == error_condition : " << (ec1 == ed2) << std::endl;
std::cout << "error_condition == error_condition : " << (ed1 == ed1) << std::endl;
std::cout << "error_condition == error_condition : " << (ed1 == ed2) << std::endl;
}
- std::error_code[link error_code.md]
- std::make_error_code[link make_error_code.md]
- std::errc::invalid_argument[link errc.md]
- std::errc::permission_denied[link errc.md]
- std::error_condition[link error_condition.md]
- std::make_error_condition[link make_error_condition.md]
error_code == error_code : true
error_code == error_code : false
error_code == error_condition : true
error_code == error_condition : false
error_condition == error_condition : true
error_condition == error_condition : false
- C++11
- Clang: ??
- GCC: 4.7.0 [mark verified]
- ICC: ??
- Visual C++: 2010 [mark verified]
- P1614R2 The Mothership has Landed
- C++20での三方比較演算子の追加と、関連する演算子の自動導出