17#ifndef SPARROW_USE_LARGE_INT_PLACEHOLDERS
20# if defined(__clang__) || defined(__GNUC__)
21# pragma GCC diagnostic push
22# pragma GCC diagnostic ignored "-Wold-style-cast"
23# pragma GCC diagnostic ignored "-Wsign-conversion"
24# pragma GCC diagnostic ignored "-Wshadow"
29# if defined(__clang__) || defined(__GNUC__)
30# pragma GCC diagnostic pop
40#ifdef SPARROW_USE_LARGE_INT_PLACEHOLDERS
47 std::uint64_t words[2];
51 return words[0] == other.words[0] && words[1] == other.words[1];
56 return !(*
this == other);
67 return words[0] == other.words[0] && words[1] == other.words[1] && words[2] == other.words[2]
68 && words[3] == other.words[3];
73 return !(*
this == other);
77 constexpr bool is_int_placeholder_v = std::is_same_v<T, int128_t> || std::is_same_v<T, int256_t>;
95 bool negative =
false;
96 for (
auto it = str.begin(); it != str.end(); ++it)
100 if (it == str.begin())
107 throw std::invalid_argument(
"Invalid character in string for conversion to large integer");
110 else if (*it <
'0' || *it >
'9')
112 throw std::invalid_argument(
"Invalid character in string for conversion to large integer");
115 digits += T(*it -
'0');
127#if __has_include(<format>)
131#if defined(__cpp_lib_format)
136template <
class charT>
139 template <
class ParseContext>
140 constexpr ParseContext::iterator parse(ParseContext& ctx)
145 template <
class FmtContext>
148# ifdef SPARROW_USE_LARGE_INT_PLACEHOLDERS
149 return std::format_to(ctx.out(),
"int128_t({}, {})", n.words[0], n.words[1]);
152 return std::format_to(ctx.out(),
"{}", str);
157template <
class charT>
160 template <
class ParseContext>
161 constexpr ParseContext::iterator parse(ParseContext& ctx)
166 template <
class FmtContext>
169# ifdef SPARROW_USE_LARGE_INT_PLACEHOLDERS
170 return std::format_to(ctx.out(),
"int256_t({}, {}, {}, {})", n.words[0], n.words[1], n.words[2], n.words[3]);
173 return std::format_to(ctx.out(),
"{}", str);
operator std::uint64_t() const
bool operator!=(const int256_t &other) const
bool operator==(const int256_t &other) const
Support for int128_t, uint128_t types.
256-bit signed integer type based on Andrew G.
std::string to_string(const uint128_t &n)
primesum::int128_t int128_t
SPARROW_API bool operator==(const array &lhs, const array &rhs)
Compares the content of two arrays.
constexpr bool is_int_placeholder_v
constexpr bool large_int_placeholders
primesum::int256_t int256_t
constexpr T stobigint(std::string_view str)
XSIMD_INLINE bool operator!=(const aligned_allocator< T1, Align1 > &lhs, const aligned_allocator< T2, Align2 > &rhs) noexcept