xref: /freebsd-src/contrib/llvm-project/libcxx/src/error_category.cpp (revision 5f757f3ff9144b609b3c433dfd370cc6bdc191ad)
1*5f757f3fSDimitry Andric //===----------------------------------------------------------------------===//
2*5f757f3fSDimitry Andric //
3*5f757f3fSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*5f757f3fSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*5f757f3fSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*5f757f3fSDimitry Andric //
7*5f757f3fSDimitry Andric //===----------------------------------------------------------------------===//
8*5f757f3fSDimitry Andric 
9*5f757f3fSDimitry Andric #include <__config>
10*5f757f3fSDimitry Andric 
11*5f757f3fSDimitry Andric #ifdef _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
12*5f757f3fSDimitry Andric #  define _LIBCPP_ERROR_CATEGORY_DEFINE_LEGACY_INLINE_FUNCTIONS
13*5f757f3fSDimitry Andric #endif
14*5f757f3fSDimitry Andric 
15*5f757f3fSDimitry Andric #include <system_error>
16*5f757f3fSDimitry Andric 
17*5f757f3fSDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
18*5f757f3fSDimitry Andric 
19*5f757f3fSDimitry Andric // class error_category
20*5f757f3fSDimitry Andric 
21*5f757f3fSDimitry Andric #if defined(_LIBCPP_ERROR_CATEGORY_DEFINE_LEGACY_INLINE_FUNCTIONS)
error_category()22*5f757f3fSDimitry Andric error_category::error_category() noexcept {}
23*5f757f3fSDimitry Andric #endif
24*5f757f3fSDimitry Andric 
~error_category()25*5f757f3fSDimitry Andric error_category::~error_category() noexcept {}
26*5f757f3fSDimitry Andric 
default_error_condition(int ev) const27*5f757f3fSDimitry Andric error_condition error_category::default_error_condition(int ev) const noexcept { return error_condition(ev, *this); }
28*5f757f3fSDimitry Andric 
equivalent(int code,const error_condition & condition) const29*5f757f3fSDimitry Andric bool error_category::equivalent(int code, const error_condition& condition) const noexcept {
30*5f757f3fSDimitry Andric   return default_error_condition(code) == condition;
31*5f757f3fSDimitry Andric }
32*5f757f3fSDimitry Andric 
equivalent(const error_code & code,int condition) const33*5f757f3fSDimitry Andric bool error_category::equivalent(const error_code& code, int condition) const noexcept {
34*5f757f3fSDimitry Andric   return *this == code.category() && code.value() == condition;
35*5f757f3fSDimitry Andric }
36*5f757f3fSDimitry Andric 
37*5f757f3fSDimitry Andric _LIBCPP_END_NAMESPACE_STD
38