[libcxx-commits] [libcxx] [libc++] Implement single element vector::insert in terms of emplace (PR #210284)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jul 29 07:45:43 PDT 2026
================
@@ -1181,6 +1144,18 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) {
if (__p == __end) {
__emplace_back_assume_capacity(std::forward<_Args>(__args)...);
} else {
+#ifndef _LIBCPP_CXX03_LANG
+ if constexpr (sizeof...(_Args) == 1) {
----------------
ldionne wrote:
Let's add a comment like `// If we insert a single element that is the same as the value type, avoid creating a temporary`.
https://github.com/llvm/llvm-project/pull/210284
More information about the libcxx-commits
mailing list