diff options
Diffstat (limited to 'boot/result.cc')
| -rw-r--r-- | boot/result.cc | 26 |
1 files changed, 2 insertions, 24 deletions
diff --git a/boot/result.cc b/boot/result.cc index e9090de..30b4576 100644 --- a/boot/result.cc +++ b/boot/result.cc @@ -328,28 +328,6 @@ namespace elna::boot return *this; } - std::optional<std::ptrdiff_t> integer_literal::to_signed() const - { - if (is_negative_minimum(sizeof(std::ptrdiff_t) * CHAR_BIT)) - { - return std::numeric_limits<ptrdiff_t>::min(); - } - auto [written, rop] = export_to_words<std::ptrdiff_t>(); - - if (written > 1 || rop < 0) - { - return std::nullopt; - } - return is_negative() ? -rop : rop; - } - - std::optional<std::size_t> integer_literal::to_unsigned() const - { - auto [written, rop] = export_to_words<std::size_t>(); - - return written > 1 ? std::nullopt : std::make_optional(rop); - } - bool integer_literal::fit_into(const std::size_t target_size) { if (fits_in(target_size * CHAR_BIT)) @@ -485,14 +463,14 @@ std::size_t std::hash<elna::boot::integer_literal>::operator()(const elna::boot: { if (key.is_signed()) { - if (auto converted = key.to_signed()) + if (auto converted = key.try_to<std::ptrdiff_t>()) { return std::hash<std::ptrdiff_t>{}(*converted); } } else { - if (auto converted = key.to_unsigned()) + if (auto converted = key.try_to<std::size_t>()) { return std::hash<std::size_t>{}(*converted); } |
