diff --git a/src/FixedPoints/SFixed.h b/src/FixedPoints/SFixed.h index b2aa96d..ab31d01 100644 --- a/src/FixedPoints/SFixed.h +++ b/src/FixedPoints/SFixed.h @@ -108,6 +108,8 @@ public: constexpr SFixed operator -() const; SFixed & operator ++(); SFixed & operator --(); + SFixed operator ++(int); + SFixed operator --(int); SFixed & operator +=(const SFixed & other); SFixed & operator -=(const SFixed & other); SFixed & operator *=(const SFixed & other); diff --git a/src/FixedPoints/SFixedMemberFunctions.h b/src/FixedPoints/SFixedMemberFunctions.h index e2ab090..ee994e0 100644 --- a/src/FixedPoints/SFixedMemberFunctions.h +++ b/src/FixedPoints/SFixedMemberFunctions.h @@ -232,6 +232,22 @@ SFixed & SFixed::operator --() return *this; } +template< unsigned Integer, unsigned Fraction > +SFixed SFixed::operator ++(int) +{ + const SFixed old(*this); + ++(*this); + return old; +} + +template< unsigned Integer, unsigned Fraction > +SFixed SFixed::operator --(int) +{ + const SFixed old(*this); + --(*this); + return old; +} + // // Compound Assignment Operators // diff --git a/src/FixedPoints/UFixed.h b/src/FixedPoints/UFixed.h index 64079da..8facf28 100644 --- a/src/FixedPoints/UFixed.h +++ b/src/FixedPoints/UFixed.h @@ -108,6 +108,8 @@ public: UFixed & operator ++(); UFixed & operator --(); + UFixed operator ++(int); + UFixed operator --(int); UFixed & operator +=(const UFixed & other); UFixed & operator -=(const UFixed & other); UFixed & operator *=(const UFixed & other); diff --git a/src/FixedPoints/UFixedMemberFunctions.h b/src/FixedPoints/UFixedMemberFunctions.h index 9f7ddd0..7cf84e7 100644 --- a/src/FixedPoints/UFixedMemberFunctions.h +++ b/src/FixedPoints/UFixedMemberFunctions.h @@ -177,10 +177,10 @@ constexpr UFixed::operator UFixed() using OutputType = UFixed; using OutputInternalType = typename OutputType::InternalType; using OutputShiftType = typename OutputType::ShiftType; - + using InputType = UFixed; using InputShiftType = typename InputType::ShiftType; - + return (FractionOut > FractionSize) ? OutputType::fromInternal(static_cast(static_cast(this->value) << ((FractionOut > FractionSize) ? (FractionOut - FractionSize) : 0))) : @@ -217,6 +217,22 @@ UFixed & UFixed::operator --() return *this; } +template< unsigned Integer, unsigned Fraction > +UFixed UFixed::operator ++(int) +{ + const UFixed old(*this); + ++(*this); + return old; +} + +template< unsigned Integer, unsigned Fraction > +UFixed UFixed::operator --(int) +{ + const UFixed old(*this); + --(*this); + return old; +} + // // Compound Assignment Operators //