add constant contructors for uint256

This commit is contained in:
Patrick Lodder 2024-07-05 19:42:36 -04:00
parent 38c3f67833
commit 4add9776c2
No known key found for this signature in database
GPG Key ID: 7C523F5FBABE80E7
2 changed files with 10 additions and 0 deletions

View File

@ -80,3 +80,6 @@ template std::string base_blob<256>::GetHex() const;
template std::string base_blob<256>::ToString() const;
template void base_blob<256>::SetHex(const char*);
template void base_blob<256>::SetHex(const std::string&);
const uint256 uint256::ZERO(0);
const uint256 uint256::ONE(1);

View File

@ -27,6 +27,9 @@ public:
memset(data, 0, sizeof(data));
}
/* constructor for constants between 1 and 255 */
constexpr explicit base_blob(uint8_t v) : data{v} {}
explicit base_blob(const std::vector<unsigned char>& vch);
bool IsNull() const
@ -124,6 +127,7 @@ class uint256 : public base_blob<256> {
public:
uint256() {}
uint256(const base_blob<256>& b) : base_blob<256>(b) {}
constexpr explicit uint256(uint8_t v) : base_blob<256>(v) {}
explicit uint256(const std::vector<unsigned char>& vch) : base_blob<256>(vch) {}
/** A cheap hash function that just returns 64 bits from the result, it can be
@ -135,6 +139,9 @@ public:
{
return ReadLE64(data);
}
static const uint256 ZERO;
static const uint256 ONE;
};
/* uint256 from const char *.