[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 09:21:12 PDT 2025


================
@@ -754,13 +755,20 @@ public:
   // external memory. In such cases, the destructor is responsible for unpoisoning
   // the memory to avoid triggering false positives.
   // Therefore it's crucial to ensure the destructor is called.
+  //
+  // However, it is replaceable since implementing move-assignment as a destroy + move-construct
+  // will maintain the right ASAN state.
----------------
ldionne wrote:

`__is_replaceable` means that you can destroy + move construct instead of assigning. This is orthogonal to whether performing those steps is equivalent to `memcpy` (which in the case of an ASAN-ified `string`, it isn't).

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


More information about the libcxx-commits mailing list