1 .. title:: clang-tidy - abseil-duration-comparison
3 abseil-duration-comparison
4 ==========================
6 Checks for comparisons which should be in the ``absl::Duration`` domain instead
7 of the floating point or integer domains.
9 N.B.: In cases where a ``Duration`` was being converted to an integer and then
10 compared against a floating-point value, truncation during the ``Duration``
11 conversion might yield a different result. In practice this is very rare, and
12 still indicates a bug which should be fixed.
18 // Original - Comparison in the floating point domain
21 if (x < absl::ToDoubleSeconds(d)) ...
23 // Suggested - Compare in the absl::Duration domain instead
24 if (absl::Seconds(x) < d) ...
27 // Original - Comparison in the integer domain
30 if (x < absl::ToInt64Microseconds(d)) ...
32 // Suggested - Compare in the absl::Duration domain instead
33 if (absl::Microseconds(x) < d) ...