| 675 | namespace NDateTimeHelpers { |
| 676 | template <typename T> |
| 677 | static constexpr T SumWithSaturation(T a, T b) { |
| 678 | static_assert(!std::numeric_limits<T>::is_signed, "expect !std::numeric_limits<T>::is_signed"); |
| 679 | |
| 680 | return Max<T>() - a < b ? Max<T>() : a + b; |
| 681 | } |
| 682 | |
| 683 | template <typename T> |
| 684 | static constexpr T DiffWithSaturation(T a, T b) { |