1.. title:: clang-tidy - abseil-duration-comparison 2 3abseil-duration-comparison 4========================== 5 6Checks for comparisons which should be in the ``absl::Duration`` domain instead 7of the floating point or integer domains. 8 9N.B.: In cases where a ``Duration`` was being converted to an integer and then 10compared against a floating-point value, truncation during the ``Duration`` 11conversion might yield a different result. In practice this is very rare, and 12still indicates a bug which should be fixed. 13 14Examples: 15 16.. code-block:: c++ 17 18 // Original - Comparison in the floating point domain 19 double x; 20 absl::Duration d; 21 if (x < absl::ToDoubleSeconds(d)) ... 22 23 // Suggested - Compare in the absl::Duration domain instead 24 if (absl::Seconds(x) < d) ... 25 26 27 // Original - Comparison in the integer domain 28 int x; 29 absl::Duration d; 30 if (x < absl::ToInt64Microseconds(d)) ... 31 32 // Suggested - Compare in the absl::Duration domain instead 33 if (absl::Microseconds(x) < d) ... 34