mirror of
https://github.com/boostorg/charconv.git
synced 2026-02-09 23:12:24 +00:00
Add increment operators
This commit is contained in:
@@ -444,10 +444,16 @@ struct uint128
|
||||
|
||||
BOOST_CHARCONV_CXX14_CONSTEXPR uint128 &operator++() noexcept;
|
||||
|
||||
BOOST_CHARCONV_CXX14_CONSTEXPR uint128 &operator++(int) noexcept;
|
||||
|
||||
BOOST_CHARCONV_CXX14_CONSTEXPR friend uint128 operator-(uint128 lhs, uint128 rhs) noexcept;
|
||||
|
||||
BOOST_CHARCONV_CXX14_CONSTEXPR uint128 &operator-=(uint128 v) noexcept;
|
||||
|
||||
BOOST_CHARCONV_CXX14_CONSTEXPR uint128 &operator--() noexcept;
|
||||
|
||||
BOOST_CHARCONV_CXX14_CONSTEXPR uint128 &operator--(int) noexcept;
|
||||
|
||||
inline friend uint128 operator*(uint128 lhs, uint128 rhs) noexcept;
|
||||
|
||||
inline uint128 &operator*=(uint128 v) noexcept;
|
||||
@@ -601,6 +607,11 @@ BOOST_CHARCONV_CXX14_CONSTEXPR uint128 &uint128::operator++() noexcept
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOST_CHARCONV_CXX14_CONSTEXPR uint128 &uint128::operator++(int) noexcept
|
||||
{
|
||||
return ++(*this);
|
||||
}
|
||||
|
||||
BOOST_CHARCONV_CXX14_CONSTEXPR uint128 operator-(uint128 lhs, uint128 rhs) noexcept
|
||||
{
|
||||
const uint128 temp {lhs.high - rhs.high, lhs.low - rhs.low};
|
||||
@@ -620,6 +631,26 @@ BOOST_CHARCONV_CXX14_CONSTEXPR uint128 &uint128::operator-=(uint128 v) noexcept
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOST_CHARCONV_CXX14_CONSTEXPR uint128 &uint128::operator--() noexcept
|
||||
{
|
||||
if (this->low == 0)
|
||||
{
|
||||
this->low = UINT64_MAX;
|
||||
--this->high;
|
||||
}
|
||||
else
|
||||
{
|
||||
--this->low;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOST_CHARCONV_CXX14_CONSTEXPR uint128 &uint128::operator--(int) noexcept
|
||||
{
|
||||
return --(*this);
|
||||
}
|
||||
|
||||
inline uint128 operator*(uint128 lhs, uint128 rhs) noexcept
|
||||
{
|
||||
#if defined(BOOST_CHARCONV_HAS_MSVC_64BIT_INTRINSICS)
|
||||
@@ -672,7 +703,7 @@ BOOST_CHARCONV_CXX14_CONSTEXPR int high_bit(uint128 v) noexcept
|
||||
// See: https://stackoverflow.com/questions/5386377/division-without-using
|
||||
BOOST_CHARCONV_CXX14_CONSTEXPR void div_impl(uint128 lhs, uint128 rhs, uint128& quotient, uint128& remainder) noexcept
|
||||
{
|
||||
const uint128 one {0, 1};
|
||||
constexpr uint128 one {0, 1};
|
||||
|
||||
if (rhs > lhs)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user