| 17 | bool ErrorCode::HasSigned() const { return std::holds_alternative<int64_t>(integral_); } |
| 18 | bool ErrorCode::HasIntegral() const { return !std::holds_alternative<std::monostate>(integral_); } |
| 19 | bool ErrorCode::Fits32() const |
| 20 | { |
| 21 | if (auto u = AsUnsigned()) { |
| 22 | return *u <= std::numeric_limits<uint32_t>::max(); |
| 23 | } |
| 24 | else if (auto u = AsSigned()) { |
| 25 | using i32 = std::numeric_limits<int32_t>; |
| 26 | return *u >= i32::min() && *u <= i32::max(); |
| 27 | } |
| 28 | // doesn't really apply, but return true anyways |
| 29 | return true; |
| 30 | } |
| 31 | std::optional<uint64_t> ErrorCode::AsUnsigned() const { |
| 32 | return HasUnsigned() ? |
| 33 | std::optional{ std::get<uint64_t>(integral_) } : std::nullopt; |
nothing calls this directly
no outgoing calls
no test coverage detected