Class to represent an error code value.
| 78 | |
| 79 | /// Class to represent an error code value. |
| 80 | class error_code |
| 81 | { |
| 82 | public: |
| 83 | /// Default constructor. |
| 84 | error_code() |
| 85 | : value_(0), |
| 86 | category_(&system_category()) |
| 87 | { |
| 88 | } |
| 89 | |
| 90 | /// Construct with specific error code and category. |
| 91 | error_code(int v, const error_category& c) |
| 92 | : value_(v), |
| 93 | category_(&c) |
| 94 | { |
| 95 | } |
| 96 | |
| 97 | /// Construct from an error code enum. |
| 98 | template <typename ErrorEnum> |
| 99 | error_code(ErrorEnum e) |
| 100 | { |
| 101 | *this = make_error_code(e); |
| 102 | } |
| 103 | |
| 104 | /// Clear the error value to the default. |
| 105 | void clear() |
| 106 | { |
| 107 | value_ = 0; |
| 108 | category_ = &system_category(); |
| 109 | } |
| 110 | |
| 111 | /// Assign a new error value. |
| 112 | void assign(int v, const error_category& c) |
| 113 | { |
| 114 | value_ = v; |
| 115 | category_ = &c; |
| 116 | } |
| 117 | |
| 118 | /// Get the error value. |
| 119 | int value() const |
| 120 | { |
| 121 | return value_; |
| 122 | } |
| 123 | |
| 124 | /// Get the error category. |
| 125 | const error_category& category() const |
| 126 | { |
| 127 | return *category_; |
| 128 | } |
| 129 | |
| 130 | /// Get the message associated with the error. |
| 131 | std::string message() const |
| 132 | { |
| 133 | return category_->message(value_); |
| 134 | } |
| 135 | |
| 136 | struct unspecified_bool_type_t |
| 137 | { |
no outgoing calls
no test coverage detected