Skip to content
Snippets Groups Projects
Commit 9ffe1010 authored by Howard Hinnant's avatar Howard Hinnant
Browse files

vector::emplace_back was mistakenly requiring move assignable. Fixed that and...

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.

llvm-svn: 151492
parent 6b2dc73d
No related branches found
No related tags found
No related merge requests found
...@@ -796,6 +796,11 @@ private: ...@@ -796,6 +796,11 @@ private:
#else #else
__push_back_slow_path(_Up& __x); __push_back_slow_path(_Up& __x);
#endif #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> template <class _Tp, class _Allocator>
...@@ -1495,6 +1500,19 @@ vector<_Tp, _Allocator>::push_back(value_type&& __x) ...@@ -1495,6 +1500,19 @@ vector<_Tp, _Allocator>::push_back(value_type&& __x)
template <class _Tp, class _Allocator> template <class _Tp, class _Allocator>
template <class... _Args> template <class... _Args>
void 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) vector<_Tp, _Allocator>::emplace_back(_Args&&... __args)
{ {
if (this->__end_ < this->__end_cap()) if (this->__end_ < this->__end_cap())
...@@ -1505,12 +1523,7 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) ...@@ -1505,12 +1523,7 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args)
++this->__end_; ++this->__end_;
} }
else else
{ __emplace_back_slow_path(_VSTD::forward<_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)...);
__swap_out_circular_buffer(__v);
}
} }
#endif // _LIBCPP_HAS_NO_VARIADICS #endif // _LIBCPP_HAS_NO_VARIADICS
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment