diff --git a/features/FEATURE_BLE/ble/common/Duration.h b/features/FEATURE_BLE/ble/common/Duration.h index a9082c894c..5057fa7ee4 100644 --- a/features/FEATURE_BLE/ble/common/Duration.h +++ b/features/FEATURE_BLE/ble/common/Duration.h @@ -126,50 +126,68 @@ typedef Duration microsecond_t; typedef Duration millisecond_t; typedef Duration second_t; -template -DurationOut durationCast(Duration duration) { +template +DurationOut durationCast(Duration duration) { return DurationOut(((duration.value() * TBIn) + DurationOut::TIME_BASE - 1) / DurationOut::TIME_BASE); } // ADDITION OPERATOR -template -microsecond_t operator+(Duration lhs, Duration rhs) { +template< + typename RepLHS, uint32_t TBLHS, typename RangeLHS, typename FLHS, + typename RepRHS, uint32_t TBRHS, typename RangeRHS, typename FRHS> +microsecond_t operator+( + Duration lhs, + Duration rhs +) +{ return microsecond_t((lhs.value() * lhs.TIME_BASE) + (rhs.value() * rhs.TIME_BASE)); } -template -Duration operator+(Duration lhs, Duration rhs) { - return Duration(lhs.value() + rhs.value()); +template +Duration operator+( + Duration lhs, + Duration rhs +) { + return Duration(lhs.value() + rhs.value()); } // MULTIPLICATION OPERATOR -template -Duration operator*(Duration lhs, uint32_t rhs) { - return Duration(lhs.value() * rhs); +template +Duration operator*(Duration lhs, uint32_t rhs) { + return Duration(lhs.value() * rhs); } -template -Duration operator*(uint32_t lhs, Duration rhs) { - return Duration(lhs * rhs.value()); +template +Duration operator*(uint32_t lhs, Duration rhs) { + return Duration(lhs * rhs.value()); } // LESS THAN -template -bool operator<(Duration lhs, Duration rhs) { +template< + typename RepLHS, uint32_t TBLHS, typename RangeLHS, typename FLHS, + typename RepRHS, uint32_t TBRHS, typename RangeRHS, typename FRHS +> +bool operator<(Duration lhs, Duration rhs) { return lhs.value() * lhs.TIME_BASE < rhs.value() * rhs.TIME_BASE; } -template -bool operator<(Duration lhs, Duration rhs) { +template +bool operator<(Duration lhs, Duration rhs) { return lhs.value() < rhs.value(); } // LESS OR EQUAL TO -template -bool operator<=(Duration lhs, Duration rhs) { +template< + typename RepLHS, uint32_t TBLHS, typename RangeLHS, typename FLHS, + typename RepRHS, uint32_t TBRHS, typename RangeRHS, typename FRHS +> +bool operator<=( + Duration lhs, + Duration rhs +) { return lhs.value() * lhs.TIME_BASE <= rhs.value() * rhs.TIME_BASE; } @@ -180,49 +198,73 @@ bool operator<=(Duration lhs, Duration rhs) { // EQUAL -template -bool operator==(Duration lhs, Duration rhs) { +template< + typename RepLHS, uint32_t TBLHS, typename RangeLHS, typename FLHS, + typename RepRHS, uint32_t TBRHS, typename RangeRHS, typename FRHS +> +bool operator==( + Duration lhs, + Duration rhs +) { return lhs.value() * lhs.TIME_BASE == rhs.value() * rhs.TIME_BASE; } -template -bool operator==(Duration lhs, Duration rhs) { +template +bool operator==(Duration lhs, Duration rhs) { return lhs.value() == rhs.value(); } // NOT EQUAL -template -bool operator!=(Duration lhs, Duration rhs) { +template< + typename RepLHS, uint32_t TBLHS, typename RangeLHS, typename FLHS, + typename RepRHS, uint32_t TBRHS, typename RangeRHS, typename FRHS +> +bool operator!=( + Duration lhs, + Duration rhs +) { return !(lhs == rhs); } -template -bool operator!=(Duration lhs, Duration rhs) { +template +bool operator!=(Duration lhs, Duration rhs) { return !(lhs == rhs); } // GREATER OR EQUAL -template -bool operator>=(Duration lhs, Duration rhs) { +template< + typename RepLHS, uint32_t TBLHS, typename RangeLHS, typename FLHS, + typename RepRHS, uint32_t TBRHS, typename RangeRHS, typename FRHS +> +bool operator>=( + Duration lhs, + Duration rhs +) { return rhs <= lhs; } -template -bool operator>=(Duration lhs, Duration rhs) { +template +bool operator>=(Duration lhs, Duration rhs) { return rhs <= lhs; } // GREATER THAN -template -bool operator>(Duration lhs, Duration rhs) { +template< + typename RepLHS, uint32_t TBLHS, typename RangeLHS, typename FLHS, + typename RepRHS, uint32_t TBRHS, typename RangeRHS, typename FRHS +> +bool operator>( + Duration lhs, + Duration rhs +) { return rhs < lhs; } -template -bool operator>(Duration lhs, Duration rhs) { +template +bool operator>(Duration lhs, Duration rhs) { return rhs < lhs; }