[libcxx-commits] [libcxx] [libc++][NFC] Simplify duration comparisons a bit (PR #201788)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jun 5 01:47:24 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions h -- libcxx/include/__chrono/duration.h --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libcxx/include/__chrono/duration.h b/libcxx/include/__chrono/duration.h
index 4c39ae78c..269d3eefa 100644
--- a/libcxx/include/__chrono/duration.h
+++ b/libcxx/include/__chrono/duration.h
@@ -304,8 +304,8 @@ typedef duration<int, ratio<static_cast<int>(365.2425 * 60 * 60 * 24) / 12>> mon
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
operator==(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
- typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Ct;
- return _Ct(__lhs).count() == _Ct(__rhs).count();
+ typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Ct;
+ return _Ct(__lhs).count() == _Ct(__rhs).count();
}
#if _LIBCPP_STD_VER <= 17
@@ -325,8 +325,8 @@ operator!=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
operator<(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
- typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Ct;
- return _Ct(__lhs).count() < _Ct(__rhs).count();
+ typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Ct;
+ return _Ct(__lhs).count() < _Ct(__rhs).count();
}
// Duration >
``````````
</details>
https://github.com/llvm/llvm-project/pull/201788
More information about the libcxx-commits
mailing list