[libcxx-commits] [libcxx] [libc++] refactor `cxx_atomic_wait` to make it reusable for atomic_ref (PR #81427)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri Feb 16 06:57:17 PST 2024


================
@@ -102,26 +102,42 @@ struct __atomic_base // false
     return std::__cxx_atomic_compare_exchange_strong(std::addressof(__a_), std::addressof(__e), __d, __m, __m);
   }
 
+  friend _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI _Tp
+  __tag_invoke(__atomic_load_cpo, const __atomic_base& __this, memory_order __order) {
----------------
ldionne wrote:

Generally speaking, I find `tag_invoke` to be a bit complex for what it provides. I'd be curious to see how much code duplication we need to handle `atomic` and `__atomic_base` without `tag_invoke` -- in the long term I think we might even be able to remove `__atomic_base`, so in that case the point would become moot anyway.

I can live with the current approach, but I would be curious to at least investigate the alternative without `tag_invoke` if you haven't already.

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


More information about the libcxx-commits mailing list