| 1 |
// -*- C++ -*- |
| 2 |
//===----------------------------------------------------------------------===// |
| 3 |
// |
| 4 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 |
// See https://llvm.org/LICENSE.txt for license information. |
| 6 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 7 |
// |
| 8 |
//===----------------------------------------------------------------------===// |
| 9 |
|
| 10 |
#ifndef _LIBCPP___CXX03_SYSTEM_ERROR |
| 11 |
#define _LIBCPP___CXX03_SYSTEM_ERROR |
| 12 |
|
| 13 |
/* |
| 14 |
system_error synopsis |
| 15 |
|
| 16 |
namespace std |
| 17 |
{ |
| 18 |
|
| 19 |
class error_category |
| 20 |
{ |
| 21 |
public: |
| 22 |
virtual ~error_category() noexcept; |
| 23 |
|
| 24 |
constexpr error_category(); |
| 25 |
error_category(const error_category&) = delete; |
| 26 |
error_category& operator=(const error_category&) = delete; |
| 27 |
|
| 28 |
virtual const char* name() const noexcept = 0; |
| 29 |
virtual error_condition default_error_condition(int ev) const noexcept; |
| 30 |
virtual bool equivalent(int code, const error_condition& condition) const noexcept; |
| 31 |
virtual bool equivalent(const error_code& code, int condition) const noexcept; |
| 32 |
virtual string message(int ev) const = 0; |
| 33 |
|
| 34 |
bool operator==(const error_category& rhs) const noexcept; |
| 35 |
bool operator!=(const error_category& rhs) const noexcept; // removed in C++20 |
| 36 |
bool operator<(const error_category& rhs) const noexcept; // removed in C++20 |
| 37 |
strong_ordering operator<=>(const error_category& rhs) const noexcept; // C++20 |
| 38 |
}; |
| 39 |
|
| 40 |
const error_category& generic_category() noexcept; |
| 41 |
const error_category& system_category() noexcept; |
| 42 |
|
| 43 |
template <class T> struct is_error_code_enum |
| 44 |
: public false_type {}; |
| 45 |
|
| 46 |
template <class T> struct is_error_condition_enum |
| 47 |
: public false_type {}; |
| 48 |
|
| 49 |
template <class _Tp> |
| 50 |
inline constexpr bool is_error_condition_enum_v = is_error_condition_enum<_Tp>::value; // C++17 |
| 51 |
|
| 52 |
template <class _Tp> |
| 53 |
inline constexpr bool is_error_code_enum_v = is_error_code_enum<_Tp>::value; // C++17 |
| 54 |
|
| 55 |
class error_code |
| 56 |
{ |
| 57 |
public: |
| 58 |
// constructors: |
| 59 |
error_code() noexcept; |
| 60 |
error_code(int val, const error_category& cat) noexcept; |
| 61 |
template <class ErrorCodeEnum> |
| 62 |
error_code(ErrorCodeEnum e) noexcept; |
| 63 |
|
| 64 |
// modifiers: |
| 65 |
void assign(int val, const error_category& cat) noexcept; |
| 66 |
template <class ErrorCodeEnum> |
| 67 |
error_code& operator=(ErrorCodeEnum e) noexcept; |
| 68 |
void clear() noexcept; |
| 69 |
|
| 70 |
// observers: |
| 71 |
int value() const noexcept; |
| 72 |
const error_category& category() const noexcept; |
| 73 |
error_condition default_error_condition() const noexcept; |
| 74 |
string message() const; |
| 75 |
explicit operator bool() const noexcept; |
| 76 |
}; |
| 77 |
|
| 78 |
// non-member functions: |
| 79 |
template <class charT, class traits> |
| 80 |
basic_ostream<charT,traits>& |
| 81 |
operator<<(basic_ostream<charT,traits>& os, const error_code& ec); |
| 82 |
|
| 83 |
class error_condition |
| 84 |
{ |
| 85 |
public: |
| 86 |
// constructors: |
| 87 |
error_condition() noexcept; |
| 88 |
error_condition(int val, const error_category& cat) noexcept; |
| 89 |
template <class ErrorConditionEnum> |
| 90 |
error_condition(ErrorConditionEnum e) noexcept; |
| 91 |
|
| 92 |
// modifiers: |
| 93 |
void assign(int val, const error_category& cat) noexcept; |
| 94 |
template <class ErrorConditionEnum> |
| 95 |
error_condition& operator=(ErrorConditionEnum e) noexcept; |
| 96 |
void clear() noexcept; |
| 97 |
|
| 98 |
// observers: |
| 99 |
int value() const noexcept; |
| 100 |
const error_category& category() const noexcept; |
| 101 |
string message() const noexcept; |
| 102 |
explicit operator bool() const noexcept; |
| 103 |
}; |
| 104 |
|
| 105 |
class system_error |
| 106 |
: public runtime_error |
| 107 |
{ |
| 108 |
public: |
| 109 |
system_error(error_code ec, const string& what_arg); |
| 110 |
system_error(error_code ec, const char* what_arg); |
| 111 |
system_error(error_code ec); |
| 112 |
system_error(int ev, const error_category& ecat, const string& what_arg); |
| 113 |
system_error(int ev, const error_category& ecat, const char* what_arg); |
| 114 |
system_error(int ev, const error_category& ecat); |
| 115 |
|
| 116 |
const error_code& code() const noexcept; |
| 117 |
const char* what() const noexcept; |
| 118 |
}; |
| 119 |
|
| 120 |
template <> struct is_error_condition_enum<errc> |
| 121 |
: true_type { } |
| 122 |
|
| 123 |
error_code make_error_code(errc e) noexcept; |
| 124 |
error_condition make_error_condition(errc e) noexcept; |
| 125 |
|
| 126 |
// Comparison operators: |
| 127 |
bool operator==(const error_code& lhs, const error_code& rhs) noexcept; |
| 128 |
bool operator==(const error_code& lhs, const error_condition& rhs) noexcept; |
| 129 |
bool operator==(const error_condition& lhs, const error_code& rhs) noexcept; // removed in C++20 |
| 130 |
bool operator==(const error_condition& lhs, const error_condition& rhs) noexcept; |
| 131 |
bool operator!=(const error_code& lhs, const error_code& rhs) noexcept; // removed in C++20 |
| 132 |
bool operator!=(const error_code& lhs, const error_condition& rhs) noexcept; // removed in C++20 |
| 133 |
bool operator!=(const error_condition& lhs, const error_code& rhs) noexcept; // removed in C++20 |
| 134 |
bool operator!=(const error_condition& lhs, const error_condition& rhs) noexcept; // removed in C++20 |
| 135 |
bool operator<(const error_condition& lhs, const error_condition& rhs) noexcept; // removed in C++20 |
| 136 |
bool operator<(const error_code& lhs, const error_code& rhs) noexcept; // removed in C++20 |
| 137 |
strong_ordering operator<=>(const error_code& lhs, const error_code& rhs) noexcept; // C++20 |
| 138 |
strong_ordering operator<=>(const error_condition& lhs, const error_condition& rhs) noexcept; // C++20 |
| 139 |
|
| 140 |
template <> struct hash<std::error_code>; |
| 141 |
template <> struct hash<std::error_condition>; |
| 142 |
|
| 143 |
} // std |
| 144 |
|
| 145 |
*/ |
| 146 |
|
| 147 |
#include <__cxx03/__config> |
| 148 |
#include <__cxx03/__system_error/errc.h> |
| 149 |
#include <__cxx03/__system_error/error_category.h> |
| 150 |
#include <__cxx03/__system_error/error_code.h> |
| 151 |
#include <__cxx03/__system_error/error_condition.h> |
| 152 |
#include <__cxx03/__system_error/system_error.h> |
| 153 |
#include <__cxx03/version> |
| 154 |
|
| 155 |
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 156 |
# pragma GCC system_header |
| 157 |
#endif |
| 158 |
|
| 159 |
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) |
| 160 |
# include <__cxx03/cstdint> |
| 161 |
# include <__cxx03/cstring> |
| 162 |
# include <__cxx03/limits> |
| 163 |
# include <__cxx03/type_traits> |
| 164 |
#endif |
| 165 |
|
| 166 |
#endif // _LIBCPP___CXX03_SYSTEM_ERROR |