[libcxx-commits] [libcxx] [libc++][chrono] Implement LWG 4274: Allow chrono::hh_mm_ss to be constructed from unsigned durations (PR #209686)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jul 24 04:44:09 PDT 2026
================
@@ -45,6 +45,14 @@ class hh_mm_ss {
return 0;
}
+ _LIBCPP_HIDE_FROM_ABI static constexpr _Duration __abs_d(_Duration __d, bool __is_neg) {
+ if constexpr (is_unsigned_v<typename _Duration::rep>) {
+ return __d;
+ } else {
+ return __is_neg ? -__d : __d;
+ }
----------------
frederick-vs-ja wrote:
I think LLVM prefers a simpler style, see [here](https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements).
```suggestion
if constexpr (is_unsigned_v<typename _Duration::rep>)
return __d;
else
return __is_neg ? -__d : __d;
```
https://github.com/llvm/llvm-project/pull/209686
More information about the libcxx-commits
mailing list