错误类型,用于 std::expected
| 335 | |
| 336 | /// 错误类型,用于 std::expected |
| 337 | struct Error { |
| 338 | ErrorCode code{ErrorCode::kSuccess}; |
| 339 | |
| 340 | explicit constexpr Error(ErrorCode c) : code(c) {} |
| 341 | |
| 342 | /// @name 构造/析构函数 |
| 343 | /// @{ |
| 344 | Error() = default; |
| 345 | Error(const Error&) = default; |
| 346 | Error(Error&&) = default; |
| 347 | auto operator=(const Error&) -> Error& = default; |
| 348 | auto operator=(Error&&) -> Error& = default; |
| 349 | ~Error() = default; |
| 350 | /// @} |
| 351 | |
| 352 | [[nodiscard]] constexpr auto message() const -> const char* { |
| 353 | return GetErrorMessage(code); |
| 354 | } |
| 355 | }; |
| 356 | |
| 357 | /// std::expected 别名模板 |
| 358 | template <typename T> |
no outgoing calls