[libcxx-commits] [libcxx] [libc++] Add the __is_replaceable type trait (PR #132408)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Mar 25 11:06:31 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.
----------------
ldionne wrote:
That makes me wonder how useful `__is_replaceable` is as a trait outside of relocation use cases. It might not be.
In order to make progress for the time being, I will add documentation clarifying that `__is_replaceable` doesn't apply if you're doing a self-assignment. And then I will revisit whether these types can be replaceable or not based on that new point of view.
https://github.com/llvm/llvm-project/pull/132408
More information about the libcxx-commits
mailing list