Add postincrement and postdecrement operators (#86)

pull/93/head
Pharap 4 years ago committed by GitHub
parent d8c2300585
commit 109d1d21fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      src/FixedPoints/SFixedFreeFunctions.h
  2. 20
      src/FixedPoints/UFixedFreeFunctions.h

@ -28,6 +28,26 @@ constexpr SFixed<Integer * 2, Fraction * 2> multiply(const SFixed<Integer, Fract
return ResultType::fromInternal(static_cast<InternalType>(static_cast<InternalType>(left.getInternal()) * static_cast<InternalType>(right.getInternal())));
}
//
// Postincrement and Postdecrement
//
template< unsigned Integer, unsigned Fraction >
SFixed<Integer, Fraction> operator ++(SFixed<Integer, Fraction> & value, int)
{
const auto oldValue = value;
++value;
return oldValue;
}
template< unsigned Integer, unsigned Fraction >
SFixed<Integer, Fraction> operator --(SFixed<Integer, Fraction> & value, int)
{
const auto oldValue = value;
--value;
return oldValue;
}
//
// Basic Logic Operations
//

@ -28,6 +28,26 @@ constexpr UFixed<Integer * 2, Fraction * 2> multiply(const UFixed<Integer, Fract
return ResultType::fromInternal(static_cast<InternalType>(static_cast<InternalType>(left.getInternal()) * static_cast<InternalType>(right.getInternal())));
}
//
// Postincrement and Postdecrement
//
template< unsigned Integer, unsigned Fraction >
UFixed<Integer, Fraction> operator ++(UFixed<Integer, Fraction> & value, int)
{
const auto oldValue = value;
++value;
return oldValue;
}
template< unsigned Integer, unsigned Fraction >
UFixed<Integer, Fraction> operator --(UFixed<Integer, Fraction> & value, int)
{
const auto oldValue = value;
--value;
return oldValue;
}
//
// Basic Logic Operations
//

Loading…
Cancel
Save