[libcxx-commits] [libcxx] [libc++] Take advantage of trivial relocation in std::vector::erase (PR #116268)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Nov 18 16:14:58 PST 2024
================
@@ -23,14 +23,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// A type is trivially relocatable if a move construct + destroy of the original object is equivalent to
// `memcpy(dst, src, sizeof(T))`.
-
-#if __has_builtin(__is_trivially_relocatable)
-template <class _Tp, class = void>
-struct __libcpp_is_trivially_relocatable : integral_constant<bool, __is_trivially_relocatable(_Tp)> {};
-#else
+//
+// Note that we don't use Clang's __is_trivially_relocatable builtin because it doesn't honor the presence
+// of non-trivial special members like assignment operators, or even a copy constructor, making it possible
----------------
ldionne wrote:
Sorry for the delay, the last days have been busy. I believe what you are suggesting is essentially what http://wg21.link/P2687R9 introduced with the `replaceable` concept -- or were you aware of that concept but you had something else in mind?
Since I wrote this patch, my understanding has evolved and so did P2687, so I created [this draft PR](https://github.com/llvm/llvm-project/pull/116714/commits) to discuss with the P2687 authors. That PR implements the currently proposed semantics for P2687 (although with a IMO better library API).
https://github.com/llvm/llvm-project/pull/116268
More information about the libcxx-commits
mailing list