Debian Codegraph @

clang-tools-extra/docs/clang-tidy/checks/abseil/duration-factory-float.rst

raw
1 .. title:: clang-tidy - abseil-duration-factory-float
2
3 abseil-duration-factory-float
4 =============================
5
6 Checks for cases where the floating-point overloads of various
7 ``absl::Duration`` factory functions are called when the more-efficient
8 integer versions could be used instead.
9
10 This check will not suggest fixes for literals which contain fractional
11 floating point values or non-literals. It will suggest removing
12 superfluous casts.
13
14 Examples:
15
16 .. code-block:: c++
17
18 // Original - Providing a floating-point literal.
19 absl::Duration d = absl::Seconds(10.0);
20
21 // Suggested - Use an integer instead.
22 absl::Duration d = absl::Seconds(10);
23
24
25 // Original - Explicitly casting to a floating-point type.
26 absl::Duration d = absl::Seconds(static_cast<double>(10));
27
28 // Suggested - Remove the explicit cast
29 absl::Duration d = absl::Seconds(10);