From 1ebae5693cbc63b1c1ccffabd75673c08dfd146f Mon Sep 17 00:00:00 2001 From: Andrey Nefedov Date: Sat, 14 Dec 2024 22:07:18 +0000 Subject: [PATCH] multiprecision: big_uint: fix constructors from string-like types --- .../multiprecision/detail/big_uint/big_uint_impl.hpp | 5 ++--- .../multiprecision/detail/big_uint/type_traits.hpp | 10 ++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/crypto3/libs/multiprecision/include/nil/crypto3/multiprecision/detail/big_uint/big_uint_impl.hpp b/crypto3/libs/multiprecision/include/nil/crypto3/multiprecision/detail/big_uint/big_uint_impl.hpp index 7d36cf875..0ec75d040 100644 --- a/crypto3/libs/multiprecision/include/nil/crypto3/multiprecision/detail/big_uint/big_uint_impl.hpp +++ b/crypto3/libs/multiprecision/include/nil/crypto3/multiprecision/detail/big_uint/big_uint_impl.hpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include @@ -156,7 +155,7 @@ namespace nil::crypto3::multiprecision { constexpr big_uint() noexcept {} - template, int> = 0> + template, int> = 0> constexpr big_uint(const T& str) { *this = str; } @@ -188,7 +187,7 @@ namespace nil::crypto3::multiprecision { // Assignment - template, int> = 0> + template, int> = 0> constexpr big_uint& operator=(const T& str) { *this = detail::parse_int(str); return *this; diff --git a/crypto3/libs/multiprecision/include/nil/crypto3/multiprecision/detail/big_uint/type_traits.hpp b/crypto3/libs/multiprecision/include/nil/crypto3/multiprecision/detail/big_uint/type_traits.hpp index 412b00533..fd97efc30 100644 --- a/crypto3/libs/multiprecision/include/nil/crypto3/multiprecision/detail/big_uint/type_traits.hpp +++ b/crypto3/libs/multiprecision/include/nil/crypto3/multiprecision/detail/big_uint/type_traits.hpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include #include "nil/crypto3/multiprecision/detail/big_uint/storage.hpp" @@ -21,6 +23,14 @@ namespace nil::crypto3::multiprecision { template constexpr bool is_integral_v = std::is_integral_v || is_big_uint_v; + template + constexpr bool is_supported_string_type_v = + (std::is_array_v && + std::is_same_v>, char>) || + (std::is_pointer_v && + (std::is_same_v>, char>)) || + std::is_same_v || std::is_same_v; + template, int> = 0> constexpr std::size_t get_bits() { return sizeof(T) * CHAR_BIT;