12 : _upper(0), _lower(0)
17 : _upper(0), _lower(value)
22 : _upper(0), _lower(value)
27 : _upper(0), _lower(value)
32 : _upper(0), _lower(value)
37 : _upper(0), _lower(value)
42 : _upper(0), _lower(value)
47 : _upper(0), _lower(value)
52 : _upper(0), _lower(value)
57 : _upper(0), _lower(value)
63 : _upper(0), _lower(value)
65 static_assert((std::is_integral<T>::value || std::is_same<T, uint128_t>::value || std::is_same<T, uint256_t>::value),
"Input argument type must be an integer!");
68 template <
typename TUpper,
typename TLower>
70 : _upper(upper), _lower(lower)
72 static_assert(((std::is_integral<TUpper>::value || std::is_same<TUpper, uint128_t>::value || std::is_same<TUpper, uint256_t>::value) && (std::is_integral<TLower>::value || std::is_same<TLower, uint128_t>::value || std::is_same<TLower, uint256_t>::value)),
"Input argument types must be integers!");
75 template <
typename TUpperUpper,
typename TUpperLower,
typename TLowerUpper,
typename TLowerLower>
76 inline uint256_t::uint256_t(
const TUpperUpper& upper_upper,
const TUpperLower& upper_lower,
const TLowerUpper& lower_upper,
const TLowerLower& lower_lower) noexcept
77 : _upper(upper_upper, upper_lower), _lower(lower_upper, lower_lower)
79 static_assert((std::is_integral<TUpperUpper>::value && std::is_integral<TUpperLower>::value && std::is_integral<TLowerUpper>::value && std::is_integral<TLowerLower>::value),
"Input argument types must be integers!");
85 static_assert((std::is_integral<T>::value || std::is_same<T, uint128_t>::value || std::is_same<T, uint256_t>::value),
"Input argument type must be an integer!");
94 return uint256_t(value1._upper + value2._upper + (((value1._lower + value2._lower) < value1._lower) ? 1 : 0), value1._lower + value2._lower);
99 return uint256_t(value1._upper - value2._upper - (((value1._lower - value2._lower) > value1._lower) ? 1 : 0), value1._lower - value2._lower);
114 return uint256_t(value1._upper & value2._upper, value1._lower & value2._lower);
119 return uint256_t(value1._upper | value2._upper, value1._lower | value2._lower);
124 return uint256_t(value1._upper ^ value2._upper, value1._lower ^ value2._lower);
129 return ((value1._upper == value2._upper) && (value1._lower == value2._lower));
134 return ((value1._upper != value2._upper) || (value1._lower != value2._lower));
139 return (value1._upper == value2._upper) ? (value1._lower < value2._lower) : (value1._upper < value2._upper);
144 return (value1._upper == value2._upper) ? (value1._lower > value2._lower) : (value1._upper > value2._upper);
149 return ((value1 < value2) || (value1 == value2));
154 return ((value1 > value2) || (value1 == value2));
159 return ((
bool)value1 && (
bool)value2);
164 return ((
bool)value1 || (
bool)value2);
169 if (os.flags() & os.oct)
171 else if (os.flags() & os.dec)
173 else if (os.flags() & os.hex)
180 if (os.flags() & os.oct)
182 else if (os.flags() & os.dec)
184 else if (os.flags() & os.hex)
192 swap(_upper, value._upper);
193 swap(_lower, value._lower);
203 #if defined(FMT_VERSION)
205 struct fmt::formatter<
CppCommon::uint256_t> : formatter<std::string_view>
207 template <
typename FormatContext>
220 typedef size_t result_type;
222 result_type operator() (
const argument_type& value)
const
224 result_type result = 17;
225 std::hash<CppCommon::uint128_t> hasher;
226 result = result * 31 + hasher(value.upper());
227 result = result * 31 + hasher(value.lower());
Unsigned 128-bit integer type.
Unsigned 256-bit integer type.
std::wstring wstring(size_t base=10, size_t length=0) const
Get wide string from the current 128-bit integer.
std::string string(size_t base=10, size_t length=0) const
Get string from the current 128-bit integer.
static std::pair< uint256_t, uint256_t > divmod(const uint256_t &x, const uint256_t &y)
Calculate quotient and remainder when dividing X by Y.
uint256_t & operator=(const T &value) noexcept
void swap(uint256_t &value) noexcept
Swap two instances.
C++ Common project definitions.
std::ostream & operator<<(std::ostream &os, const uint128_t &value)
constexpr auto operator|(TEnum value1, TEnum value2) noexcept -> typename std::enable_if< IsEnumFlags< TEnum >::value, Flags< TEnum >>::type
bool operator==(const uint128_t &value1, const uint128_t &value2) noexcept
std::string format(fmt::format_string< T... > pattern, T &&... args)
Format string.
uint128_t operator-(const uint128_t &value1, const uint128_t &value2) noexcept
bool operator!=(const uint128_t &value1, const uint128_t &value2) noexcept
void swap(FileCache &cache1, FileCache &cache2) noexcept
constexpr auto operator^(TEnum value1, TEnum value2) noexcept -> typename std::enable_if< IsEnumFlags< TEnum >::value, Flags< TEnum >>::type
bool operator<(const uint128_t &value1, const uint128_t &value2) noexcept
bool operator>(const uint128_t &value1, const uint128_t &value2) noexcept
uint128_t operator%(const uint128_t &value1, const uint128_t &value2)
bool operator<=(const uint128_t &value1, const uint128_t &value2) noexcept
uint128_t operator+(const uint128_t &value1, const uint128_t &value2) noexcept
uint128_t operator/(const uint128_t &value1, const uint128_t &value2)
void swap(uint256_t &value1, uint256_t &value2) noexcept
bool operator>=(const uint128_t &value1, const uint128_t &value2) noexcept
bool operator&&(const uint128_t &value1, const uint128_t &value2) noexcept
constexpr auto operator&(TEnum value1, TEnum value2) noexcept -> typename std::enable_if< IsEnumFlags< TEnum >::value, Flags< TEnum >>::type
bool operator||(const uint128_t &value1, const uint128_t &value2) noexcept