uint256: Update constructors to c++11, make ONE static

Replace the memset with C++11 value/aggregate initialisation of
the m_data array, which still ensures the unspecified values end
up as zero-initialised.

This then allows changing UINT256_ONE() from dynamically allocating an
object, to a simpler referencing a static allocation.
This commit is contained in:
Anthony Towns
2020-09-25 15:01:38 +10:00
parent 78f912c901
commit 183f308fff
3 changed files with 17 additions and 11 deletions

View File

@@ -278,4 +278,10 @@ BOOST_AUTO_TEST_CASE( operator_with_self )
BOOST_CHECK(v == UintToArith256(uint256S("0")));
}
BOOST_AUTO_TEST_CASE( check_ONE )
{
uint256 one = uint256S("0000000000000000000000000000000000000000000000000000000000000001");
BOOST_CHECK_EQUAL(one, uint256::ONE);
}
BOOST_AUTO_TEST_SUITE_END()