[libcxx-commits] [libcxx] Fix LWG issue4481 disallow chrono::duration<const T, P> (PR #207558)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Jul 4 23:28:01 PDT 2026
================
@@ -164,6 +169,9 @@ template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duratio
template <class _Rep, class _Period>
class duration {
+#if _LIBCPP_STD_VER >= 26
+ static_assert(is_same_v<_Rep, remove_cv_t<_Rep>>, "A duration representation cannot be cv-qualified");
+#endif
----------------
frederick-vs-ja wrote:
Resolution LWG4481 should be applied to old modes. Also it's better to separately diagnose const- and volatile-qualifications.
```suggestion
static_assert(!is_const<_Rep, remove_cv_t<_Rep>>::value, "A duration representation cannot be const-qualified");
static_assert(is_volatile<_Rep, remove_cv_t<_Rep>>::value, "A duration representation cannot be volatile-qualified");
```
https://github.com/llvm/llvm-project/pull/207558
More information about the libcxx-commits
mailing list