diff --git a/src/uint256.cpp b/src/uint256.cpp index bd3d0170853..314a2bb00d1 100644 --- a/src/uint256.cpp +++ b/src/uint256.cpp @@ -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); diff --git a/src/uint256.h b/src/uint256.h index a92ce07f111..4ebeffd082d 100644 --- a/src/uint256.h +++ b/src/uint256.h @@ -27,6 +27,9 @@ class base_blob 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& 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& vch) : base_blob<256>(vch) {} /** A cheap hash function that just returns 64 bits from the result, it can be @@ -135,6 +139,9 @@ class uint256 : public base_blob<256> { { return ReadLE64(data); } + + static const uint256 ZERO; + static const uint256 ONE; }; /* uint256 from const char *.