@@ -359,14 +359,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
noexcept(_Alloc_traits::_S_always_equal())
: _Base(std::move(__rv), __m)
{
- if (__rv.get_allocator() != __m)
- {
- this->_M_impl._M_finish =
- std::__uninitialized_move_a(__rv.begin(), __rv.end(),
- this->_M_impl._M_start,
- _M_get_Tp_allocator());
- __rv.clear();
- }
+ _M_move_elements(std::move(__rv), __m,
+ __bool_constant<_Alloc_traits::_S_always_equal()>());
}
/**
@@ -1522,14 +1516,33 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cplusplus >= 201103L
private:
+ // Used by allocator-extended move constructor for always-equal allocator
+ void
+ _M_move_elements(vector&& __rv, const allocator_type& __m, true_type)
+ { }
+
+ // Used by allocator-extended move constructor for allocators that might
+ // be unequal.
+ void
+ _M_move_elements(vector&& __rv, const allocator_type& __m, false_type)
+ {
+ if (__rv.get_allocator() != __m)
+ {
+ this->_M_impl._M_finish =
+ std::__uninitialized_move_a(__rv.begin(), __rv.end(),
+ this->_M_impl._M_start,
+ _M_get_Tp_allocator());
+ __rv.clear();
+ }
+ }
+
// Constant-time move assignment when source object's memory can be
// moved, either because the source's allocator will move too
// or because the allocators are equal.
void
_M_move_assign(vector&& __x, std::true_type) noexcept
{
- vector __tmp(get_allocator());
- this->_M_impl._M_swap_data(__tmp._M_impl);
+ const vector __tmp(std::move(*this), get_allocator());
this->_M_impl._M_swap_data(__x._M_impl);
std::__alloc_on_move(_M_get_Tp_allocator(), __x._M_get_Tp_allocator());
}