[libcxx-commits] [libcxx] [libcxx] Implementation of P1831R1 (PR #101439)

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Mon Aug 5 09:50:06 PDT 2024


================
@@ -741,6 +741,15 @@ typedef __char32_t char32_t;
 #    define _LIBCPP_DEPRECATED_WITH_CHAR8_T
 #  endif
 
+// P1831R1 deprecated many uses of volatile, but the way attributes work with template specializations require this
+// work-around to always raise warnings in cases where templates are specialized for volatile variants of STL types.
+template <class _Tp, bool __cxx20 = _LIBCPP_STD_VER >= 20>
+_LIBCPP_HIDE_FROM_ABI constexpr bool __volatile_deprecated_since_cxx20_warning = true;
+template <class _Tp>
+_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI constexpr bool __volatile_deprecated_since_cxx20_warning<_Tp, true> = true;
+#  define _LIBCPP_VOLATILE_DEPRECATED_WARNING static_assert(__volatile_deprecated_since_cxx20_warning<volatile _Tp>)
+#  define _LIBCPP_CONST_VOLATILE_DEPRECATED_WARNING static_assert(__volatile_deprecated_since_cxx20_warning<const volatile _Tp>)
+
----------------
mordante wrote:

Here we can do something similar as ` _LIBCPP_DEPRECATED_NOT_ALWAYS_LOCK_FREE`. In that case I don't think we need to differentiate between `volatile` and `const volatile`. I even wonder whether we then can make it a bit more generic in naming.

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


More information about the libcxx-commits mailing list