Template Function rclcpp::sub_will_overflow

Function Documentation

template<typename T>
bool rclcpp::sub_will_overflow(const T x, const T y)

Safely check if subtraction will overflow.

The type of the operands, T, should have defined std::numeric_limits<T>::max(), >, < and + operators.

Parameters:
  • x[in] is the minuend.

  • y[in] is the subtrahend.

Template Parameters:

T – is type of the operands.

Returns:

True if the difference x - y sum is grater than T::max value.