[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 09:30:29 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 don't think you have to consider the same memory location case. You can't relocate an object into the same place it is already in, since you can't relocate from an object that is already destroyed (which you just did by relocating into the same memory location).

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


More information about the libcxx-commits mailing list