[libcxx-commits] [libcxx] [libcxx][P1831R1] Deprecating volatile: library (PR #101439)
Josh Karns via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Aug 5 12:42:26 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>)
+
----------------
jkarns275 wrote:
Hmm I do think differentiating between `volatile` and `const volatile` may be confusing.
I'm not sure what a better name would be since there isn't a specific condition to refer to like `!is_always_lock_free`.
https://github.com/llvm/llvm-project/pull/101439
More information about the libcxx-commits
mailing list