[libcxx-commits] [libcxx] [libcxx][P1831R1] Deprecating volatile: library (PR #101439)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Aug 11 01:44:03 PDT 2024
================
@@ -27,6 +27,20 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#if _LIBCPP_STD_VER >= 20
+template <class _Tp, bool __lock_free>
+inline constexpr bool __deprecated_if_not_always_lock_free = true;
+
+template <class _Tp>
+[[deprecated("volatile atomic operations are deprecated when std::atomic<T>::is_always_lock_free is false")]]
+inline constexpr bool __deprecated_if_not_always_lock_free<_Tp, false> = true;
+# define _LIBCPP_DEPRECATED_NOT_ALWAYS_LOCK_FREE(_Tp, __is_always_lock_free) \
+ static_assert(__deprecated_if_not_always_lock_free<_Tp, __is_always_lock_free>)
+#else
+# define _LIBCPP_DEPRECATED_NOT_ALWAYS_LOCK_FREE(_Tp, __is_always_lock_free) \
+ {}
----------------
frederick-vs-ja wrote:
> I thought it was UB.
It's definitely not now per [P2809R3](https://wg21.link/p2809r3).
However..., shouldn't this be `do { } while(0)`?
https://github.com/llvm/llvm-project/pull/101439
More information about the libcxx-commits
mailing list