1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15:17:36 +00:00

LibCrypto: Make the constructors of (Un)SignedBigInteger templated

This means it can take any (un)signed word of size at most Word.
This means the constructor can be disambiguated if we were to add a
double constructor :^).

This requires a change in just one test.
This commit is contained in:
davidot 2022-08-25 23:35:34 +02:00 committed by Linus Groh
parent 48ac6ba372
commit c87d10365b
3 changed files with 13 additions and 5 deletions

View file

@ -16,9 +16,11 @@ struct SignedDivisionResult;
class SignedBigInteger {
public:
SignedBigInteger(i32 x)
: m_sign(x < 0)
, m_unsigned_data(abs(x))
template<typename T>
requires(IsSigned<T> && sizeof(T) <= sizeof(i32))
SignedBigInteger(T value)
: m_sign(value < 0)
, m_unsigned_data(abs(static_cast<i32>(value)))
{
}