[libcxx-commits] [libcxx] Use `LIBCPP_STATIC_ASSERT` in chrono test (PR #132566)

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Sun Mar 23 05:38:32 PDT 2025


================
@@ -36,11 +36,10 @@
 #include "test_macros.h"
 
 // class gps_clock
-using rep                                 = std::chrono::gps_clock::rep;
-using period                              = std::chrono::gps_clock::period;
-using duration                            = std::chrono::gps_clock::duration;
-using time_point                          = std::chrono::gps_clock::time_point;
-[[maybe_unused]] constexpr bool is_steady = std::chrono::gps_clock::is_steady;
+using rep        = std::chrono::gps_clock::rep;
+using period     = std::chrono::gps_clock::period;
+using duration   = std::chrono::gps_clock::duration;
+using time_point = std::chrono::gps_clock::time_point;
----------------
mordante wrote:

I believe this fix is wrong. We used to test two things:

1. does the class satisfy the Standard requirement to have a `bool` member named `is_steady`?
2. does libc++'s implementation have the value `x`?

I think we can improve the existing test lightly, by testing the type is a `bool` and not just convertible to `bool` by using
```suggestion
using time_point = std::chrono::gps_clock::time_point;
[[maybe_unused]] constexpr  std::same_as<bool> decltype(auto) = std::chrono::gps_clock::is_steady;
```


https://github.com/llvm/llvm-project/pull/132566


More information about the libcxx-commits mailing list