namespace std {
// operator==により、以下の演算子が使用可能になる (C++20)
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_code& rhs) noexcept; // (3) C++11
bool operator!=(const error_condition& lhs, const error_condition& rhs) noexcept; // (4) C++11
}
概要
error_code
, error_condition
の非等値比較を行う
戻り値
!(lhs == rhs)
例外
投げない
例
#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;
}
23
#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;
出力
error_code != error_code : false
error_code != error_code : true
error_code != error_condition : false
error_code != error_condition : true
error_condition != error_condition : false
error_condition != error_condition : true
バージョン
言語
- C++11
処理系
- Clang: ??
- GCC: 4.7.0 ✅
- ICC: ??
- Visual C++: 2010 ✅
関連項目
参照
- P1614R2 The Mothership has Landed
- C++20での三方比較演算子の追加と、関連する演算子の自動導出