[libcxx-commits] [libcxx] [libc++][chrono] Implement LWG 4481: disallow chrono::duration<const T, P> (PR #207558)

via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jul 5 19:25:47 PDT 2026


================
@@ -164,6 +166,8 @@ template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duratio
 
 template <class _Rep, class _Period>
 class duration {
+  static_assert(!is_const<_Rep>::value, "A duration representation can not be const-qualified");
----------------
emmett2020 wrote:

Thanks for the reviewing. I think `__is_unqualified_v<T>` has the same functional effect with `!is_const<T> && !is_volatile<T>`. However, we can give users a more concrete and specific error message with separated check. There're also  same usage at https://github.com/llvm/llvm-project/blob/9b2d44a51252891b4612330c485fa11464866455/libcxx/include/__memory/allocator.h#L68. 

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


More information about the libcxx-commits mailing list