5#ifndef BITCOIN_UTIL_BYTE_UNITS_H
6#define BITCOIN_UTIL_BYTE_UNITS_H
14template <
unsigned SHIFT>
18 if (!bytes || *bytes > std::numeric_limits<uint64_t>::max()) {
19 throw std::overflow_error(
"Too large");
26consteval uint64_t
operator""_MiB(
unsigned long long mebibytes)
28 return util::detail::ByteUnitsToBytes<20>(mebibytes);
32consteval uint64_t
operator""_GiB(
unsigned long long gibibytes)
34 return util::detail::ByteUnitsToBytes<30>(gibibytes);
consteval uint64_t ByteUnitsToBytes(unsigned long long units)
constexpr std::optional< T > CheckedLeftShift(T input, unsigned shift) noexcept
Left bit shift with overflow checking.