[libcxx-commits] [libcxx] [libc++] Use relocation in vector::emplace_back (PR #159365)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Sep 17 09:57:35 PDT 2025


================
@@ -1188,19 +1188,43 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 inline
     void
----------------
ldionne wrote:

Let's refactor this into `__emplace_back` which unconditionally returns the reference and then either discard it or not from `emplace_back` depending on C++17. This avoids introducing:

```
#if _LIBCPP_STD_VER >= 17
    return __end_[-1];
#endif
``

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


More information about the libcxx-commits mailing list