Type checks

This commit is contained in:
Ashish Bhanu Daulatabad 2021-04-11 00:46:02 +05:30
parent a7ab392ace
commit b032274df1

View File

@ -197,7 +197,7 @@ class uint256_t {
* @returns addition of this and p, returning uint256_t integer
*/
inline uint256_t operator+(const uint256_t &p) {
bool app = s + p.s < s;
uint32_t app = (s + p.s < s);
return {f + app + p.f, p.s + s};
}
@ -210,7 +210,7 @@ class uint256_t {
template <typename T, typename = typename std::enable_if<
std::is_integral<T>::value, T>::type>
inline uint256_t &operator+=(const T &p) {
bool app = p + s < s;
uint32_t app = (p + s < s);
this->f += app;
this->s += p;
return *this;
@ -222,7 +222,7 @@ class uint256_t {
* @returns addition of this and p, returning this
*/
inline uint256_t &operator+=(const uint256_t &p) {
bool _app = (p.s + s < s);
uint32_t _app = (p.s + s < s);
f += _app + p.f;
s += p.s;
return *this;
@ -255,7 +255,7 @@ class uint256_t {
template <typename T, typename = typename std::enable_if<
std::is_integral<T>::value, T>::type>
inline uint256_t operator-(const T &p) {
bool app = p > s;
uint32_t app = (p > s);
return uint256_t(f - app, s - p);
}
@ -265,7 +265,7 @@ class uint256_t {
* @returns subtraction of this and p, returning uint256_t integer
*/
inline uint256_t operator-(const uint256_t &p) {
bool app = p.s > s;
uint32_t app = p.s > s;
return {f - p.f - app, s - p.s};
}
@ -302,7 +302,7 @@ class uint256_t {
template <typename T, typename = typename std::enable_if<
std::is_integral<T>::value, T>::type>
inline uint256_t operator-=(const T p) {
bool app = p > s;
uint32_t app = (p > s);
f -= app;
s -= p;
return *this;
@ -314,7 +314,7 @@ class uint256_t {
* @returns subtraction of this and p, returning this
*/
inline uint256_t &operator-=(const uint256_t &p) {
bool app = p.s > s;
uint32_t app = p.s > s;
f = f - app - p.f;
s -= p.s;
return *this;