[libcxx-commits] [libcxx] [libc++] Add the __is_replaceable type trait (PR #132408)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 25 06:26:44 PDT 2025


================
@@ -65,8 +65,11 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
   friend _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep) _NOEXCEPT;
 
 public:
-  // exception_ptr is basically a COW string.
+  // exception_ptr is basically a COW string so it is trivially relocatable.
+  // However, it's not replaceable because destroying and move-constructing could cause
+  // the underlying refcount to hit 0 if we're self-assigning.
----------------
philnik777 wrote:

I'm not sure I understand this. If we're self-assigning it's a no-op and shouldn't potentially delete the underlying resource.

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


More information about the libcxx-commits mailing list