[cfe-commits] [libcxx] r151492 - /libcxx/trunk/include/vector
Howard Hinnant
hhinnant at apple.com
Sun Feb 26 07:30:12 PST 2012
Author: hhinnant
Date: Sun Feb 26 09:30:12 2012
New Revision: 151492
URL: http://llvm.org/viewvc/llvm-project?rev=151492&view=rev
Log:
vector::emplace_back was mistakenly requiring move assignable. Fixed that and did a little drive-by optimization at the same time. This fixes http://llvm.org/bugs/show_bug.cgi?id=12085.
Modified:
libcxx/trunk/include/vector
Modified: libcxx/trunk/include/vector
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/vector?rev=151492&r1=151491&r2=151492&view=diff
==============================================================================
--- libcxx/trunk/include/vector (original)
+++ libcxx/trunk/include/vector Sun Feb 26 09:30:12 2012
@@ -796,6 +796,11 @@
#else
__push_back_slow_path(_Up& __x);
#endif
+#if !defined(_LIBCPP_HAS_NO_VARIADICS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+ template <class... _Args>
+ void
+ __emplace_back_slow_path(_Args&&... __args);
+#endif
};
template <class _Tp, class _Allocator>
@@ -1495,6 +1500,19 @@
template <class _Tp, class _Allocator>
template <class... _Args>
void
+vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args)
+{
+ allocator_type& __a = this->__alloc();
+ __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);
+// __v.emplace_back(_VSTD::forward<_Args>(__args)...);
+ __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(__v.__end_++), _VSTD::forward<_Args>(__args)...);
+ __swap_out_circular_buffer(__v);
+}
+
+template <class _Tp, class _Allocator>
+template <class... _Args>
+_LIBCPP_INLINE_VISIBILITY inline
+void
vector<_Tp, _Allocator>::emplace_back(_Args&&... __args)
{
if (this->__end_ < this->__end_cap())
@@ -1505,12 +1523,7 @@
++this->__end_;
}
else
- {
- allocator_type& __a = this->__alloc();
- __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);
- __v.emplace_back(_VSTD::forward<_Args>(__args)...);
- __swap_out_circular_buffer(__v);
- }
+ __emplace_back_slow_path(_VSTD::forward<_Args>(__args)...);
}
#endif // _LIBCPP_HAS_NO_VARIADICS
More information about the cfe-commits
mailing list