Commit d7e16fc5 by François Dumont

2016-06-15 François Dumont <fdumont@gcc.gnu.org>

	* include/bits/stl_deque.h
	(std::deque<>::operator=): Call _M_assign_aux.
	(std::deque<>::assign(initializer_list<>)): Likewise.
	(std::deque<>::resize(size_t, const value_type&)): Call _M_fill_insert.
	(std::deque<>::insert(const_iterator, initializer_list<>)):
	Call _M_range_insert_aux.
	(std::deque<>::_M_assign_aux<It>(It, It, std::forward_iterator_tag):
	Likewise.
	(std::deque<>::_M_fill_assign): Call _M_fill_insert.
	(std::deque<>::_M_move_assign2): Call _M_assign_aux.
	* include/bits/deque.tcc
	(std::deque<>::operator=): Call _M_range_insert_aux.
	(std::deque<>::_M_assign_aux<It>(It, It, std::input_iterator_tag)):
	Likewise.
	* include/bits/stl_vector.h
	(std::vector<>::operator=): Call _M_assign_aux.
	(std::vector<>::assign(initializer_list<>)): Likewise.
	(std::vector<>::resize(size_t, const value_type&)): Call _M_fill_insert.
	(std::vector<>::insert(const_iterator, initializer_list<>)):
	Call _M_range_insert.
	* include/bits/vector.tcc (std::vector<>::_M_assign_aux): Likewise.

From-SVN: r237495
parent 1a3c3ee9
2016-06-15 François Dumont <fdumont@gcc.gnu.org>
* include/bits/stl_deque.h
(std::deque<>::operator=): Call _M_assign_aux.
(std::deque<>::assign(initializer_list<>)): Likewise.
(std::deque<>::resize(size_t, const value_type&)): Call _M_fill_insert.
(std::deque<>::insert(const_iterator, initializer_list<>)):
Call _M_range_insert_aux.
(std::deque<>::_M_assign_aux<It>(It, It, std::forward_iterator_tag):
Likewise.
(std::deque<>::_M_fill_assign): Call _M_fill_insert.
(std::deque<>::_M_move_assign2): Call _M_assign_aux.
* include/bits/deque.tcc
(std::deque<>::operator=): Call _M_range_insert_aux.
(std::deque<>::_M_assign_aux<It>(It, It, std::input_iterator_tag)):
Likewise.
* include/bits/stl_vector.h
(std::vector<>::operator=): Call _M_assign_aux.
(std::vector<>::assign(initializer_list<>)): Likewise.
(std::vector<>::resize(size_t, const value_type&)): Call _M_fill_insert.
(std::vector<>::insert(const_iterator, initializer_list<>)):
Call _M_range_insert.
* include/bits/vector.tcc (std::vector<>::_M_assign_aux): Likewise.
2016-06-07 François Dumont <fdumont@gcc.gnu.org> 2016-06-07 François Dumont <fdumont@gcc.gnu.org>
* include/std/tuple (_Head_base<>): Default specialization condition at * include/std/tuple (_Head_base<>): Default specialization condition at
......
...@@ -119,7 +119,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -119,7 +119,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
{ {
const_iterator __mid = __x.begin() + difference_type(__len); const_iterator __mid = __x.begin() + difference_type(__len);
std::copy(__x.begin(), __mid, this->_M_impl._M_start); std::copy(__x.begin(), __mid, this->_M_impl._M_start);
insert(this->_M_impl._M_finish, __mid, __x.end()); _M_range_insert_aux(this->_M_impl._M_finish, __mid, __x.end(),
std::random_access_iterator_tag());
} }
} }
return *this; return *this;
...@@ -280,7 +281,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -280,7 +281,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
if (__first == __last) if (__first == __last)
_M_erase_at_end(__cur); _M_erase_at_end(__cur);
else else
insert(end(), __first, __last); _M_range_insert_aux(end(), __first, __last,
std::__iterator_category(__first));
} }
template <typename _Tp, typename _Alloc> template <typename _Tp, typename _Alloc>
......
...@@ -1081,7 +1081,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1081,7 +1081,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
deque& deque&
operator=(initializer_list<value_type> __l) operator=(initializer_list<value_type> __l)
{ {
this->assign(__l.begin(), __l.end()); _M_assign_aux(__l.begin(), __l.end(),
random_access_iterator_tag());
return *this; return *this;
} }
#endif #endif
...@@ -1142,7 +1143,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1142,7 +1143,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*/ */
void void
assign(initializer_list<value_type> __l) assign(initializer_list<value_type> __l)
{ this->assign(__l.begin(), __l.end()); } { _M_assign_aux(__l.begin(), __l.end(), random_access_iterator_tag()); }
#endif #endif
/// Get a copy of the memory allocation object. /// Get a copy of the memory allocation object.
...@@ -1306,7 +1307,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1306,7 +1307,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
{ {
const size_type __len = size(); const size_type __len = size();
if (__new_size > __len) if (__new_size > __len)
insert(this->_M_impl._M_finish, __new_size - __len, __x); _M_fill_insert(this->_M_impl._M_finish, __new_size - __len, __x);
else if (__new_size < __len) else if (__new_size < __len)
_M_erase_at_end(this->_M_impl._M_start _M_erase_at_end(this->_M_impl._M_start
+ difference_type(__new_size)); + difference_type(__new_size));
...@@ -1328,7 +1329,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1328,7 +1329,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
{ {
const size_type __len = size(); const size_type __len = size();
if (__new_size > __len) if (__new_size > __len)
insert(this->_M_impl._M_finish, __new_size - __len, __x); _M_fill_insert(this->_M_impl._M_finish, __new_size - __len, __x);
else if (__new_size < __len) else if (__new_size < __len)
_M_erase_at_end(this->_M_impl._M_start _M_erase_at_end(this->_M_impl._M_start
+ difference_type(__new_size)); + difference_type(__new_size));
...@@ -1645,7 +1646,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1645,7 +1646,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*/ */
iterator iterator
insert(const_iterator __p, initializer_list<value_type> __l) insert(const_iterator __p, initializer_list<value_type> __l)
{ return this->insert(__p, __l.begin(), __l.end()); } {
auto __offset = __p - cbegin();
_M_range_insert_aux(__p._M_const_cast(), __l.begin(), __l.end(),
std::random_access_iterator_tag());
return begin() + __offset;
}
#endif #endif
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
...@@ -1819,9 +1825,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1819,9 +1825,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_M_initialize_dispatch(_InputIterator __first, _InputIterator __last, _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
__false_type) __false_type)
{ {
typedef typename std::iterator_traits<_InputIterator>:: _M_range_initialize(__first, __last,
iterator_category _IterCategory; std::__iterator_category(__first));
_M_range_initialize(__first, __last, _IterCategory());
} }
// called by the second initialize_dispatch above // called by the second initialize_dispatch above
...@@ -1884,11 +1889,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1884,11 +1889,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
void void
_M_assign_dispatch(_InputIterator __first, _InputIterator __last, _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
__false_type) __false_type)
{ { _M_assign_aux(__first, __last, std::__iterator_category(__first)); }
typedef typename std::iterator_traits<_InputIterator>::
iterator_category _IterCategory;
_M_assign_aux(__first, __last, _IterCategory());
}
// called by the second assign_dispatch above // called by the second assign_dispatch above
template<typename _InputIterator> template<typename _InputIterator>
...@@ -1908,7 +1909,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1908,7 +1909,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_ForwardIterator __mid = __first; _ForwardIterator __mid = __first;
std::advance(__mid, size()); std::advance(__mid, size());
std::copy(__first, __mid, begin()); std::copy(__first, __mid, begin());
insert(end(), __mid, __last); _M_range_insert_aux(end(), __mid, __last,
std::__iterator_category(__first));
} }
else else
_M_erase_at_end(std::copy(__first, __last, begin())); _M_erase_at_end(std::copy(__first, __last, begin()));
...@@ -1922,7 +1924,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1922,7 +1924,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
if (__n > size()) if (__n > size())
{ {
std::fill(begin(), end(), __val); std::fill(begin(), end(), __val);
insert(end(), __n - size(), __val); _M_fill_insert(end(), __n - size(), __val);
} }
else else
{ {
...@@ -1970,9 +1972,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1970,9 +1972,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_InputIterator __first, _InputIterator __last, _InputIterator __first, _InputIterator __last,
__false_type) __false_type)
{ {
typedef typename std::iterator_traits<_InputIterator>:: _M_range_insert_aux(__pos, __first, __last,
iterator_category _IterCategory; std::__iterator_category(__first));
_M_range_insert_aux(__pos, __first, __last, _IterCategory());
} }
// called by the second insert_dispatch above // called by the second insert_dispatch above
...@@ -2196,8 +2197,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -2196,8 +2197,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
{ {
// The rvalue's allocator cannot be moved and is not equal, // The rvalue's allocator cannot be moved and is not equal,
// so we need to individually move each element. // so we need to individually move each element.
this->assign(std::__make_move_if_noexcept_iterator(__x.begin()), _M_assign_aux(std::__make_move_if_noexcept_iterator(__x.begin()),
std::__make_move_if_noexcept_iterator(__x.end())); std::__make_move_if_noexcept_iterator(__x.end()),
std::random_access_iterator_tag());
__x.clear(); __x.clear();
} }
} }
......
...@@ -72,7 +72,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -72,7 +72,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
struct _Vector_base struct _Vector_base
{ {
typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template
rebind<_Tp>::other _Tp_alloc_type; rebind<_Tp>::other _Tp_alloc_type;
typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>::pointer typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>::pointer
pointer; pointer;
...@@ -214,30 +214,30 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -214,30 +214,30 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
class vector : protected _Vector_base<_Tp, _Alloc> class vector : protected _Vector_base<_Tp, _Alloc>
{ {
// Concept requirements. // Concept requirements.
typedef typename _Alloc::value_type _Alloc_value_type; typedef typename _Alloc::value_type _Alloc_value_type;
#if __cplusplus < 201103L #if __cplusplus < 201103L
__glibcxx_class_requires(_Tp, _SGIAssignableConcept) __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
#endif #endif
__glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept) __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept)
typedef _Vector_base<_Tp, _Alloc> _Base; typedef _Vector_base<_Tp, _Alloc> _Base;
typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Alloc_traits; typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Alloc_traits;
public: public:
typedef _Tp value_type; typedef _Tp value_type;
typedef typename _Base::pointer pointer; typedef typename _Base::pointer pointer;
typedef typename _Alloc_traits::const_pointer const_pointer; typedef typename _Alloc_traits::const_pointer const_pointer;
typedef typename _Alloc_traits::reference reference; typedef typename _Alloc_traits::reference reference;
typedef typename _Alloc_traits::const_reference const_reference; typedef typename _Alloc_traits::const_reference const_reference;
typedef __gnu_cxx::__normal_iterator<pointer, vector> iterator; typedef __gnu_cxx::__normal_iterator<pointer, vector> iterator;
typedef __gnu_cxx::__normal_iterator<const_pointer, vector> typedef __gnu_cxx::__normal_iterator<const_pointer, vector>
const_iterator; const_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator; typedef std::reverse_iterator<iterator> reverse_iterator;
typedef size_t size_type; typedef size_t size_type;
typedef ptrdiff_t difference_type; typedef ptrdiff_t difference_type;
typedef _Alloc allocator_type; typedef _Alloc allocator_type;
protected: protected:
using _Base::_M_allocate; using _Base::_M_allocate;
...@@ -319,8 +319,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -319,8 +319,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*/ */
vector(const vector& __x) vector(const vector& __x)
: _Base(__x.size(), : _Base(__x.size(),
_Alloc_traits::_S_select_on_copy(__x._M_get_Tp_allocator())) _Alloc_traits::_S_select_on_copy(__x._M_get_Tp_allocator()))
{ this->_M_impl._M_finish = {
this->_M_impl._M_finish =
std::__uninitialized_copy_a(__x.begin(), __x.end(), std::__uninitialized_copy_a(__x.begin(), __x.end(),
this->_M_impl._M_start, this->_M_impl._M_start,
_M_get_Tp_allocator()); _M_get_Tp_allocator());
...@@ -340,7 +341,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -340,7 +341,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
/// Copy constructor with alternative allocator /// Copy constructor with alternative allocator
vector(const vector& __x, const allocator_type& __a) vector(const vector& __x, const allocator_type& __a)
: _Base(__x.size(), __a) : _Base(__x.size(), __a)
{ this->_M_impl._M_finish = {
this->_M_impl._M_finish =
std::__uninitialized_copy_a(__x.begin(), __x.end(), std::__uninitialized_copy_a(__x.begin(), __x.end(),
this->_M_impl._M_start, this->_M_impl._M_start,
_M_get_Tp_allocator()); _M_get_Tp_allocator());
...@@ -400,16 +402,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -400,16 +402,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
template<typename _InputIterator, template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>> typename = std::_RequireInputIter<_InputIterator>>
vector(_InputIterator __first, _InputIterator __last, vector(_InputIterator __first, _InputIterator __last,
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
: _Base(__a) : _Base(__a)
{ _M_initialize_dispatch(__first, __last, __false_type()); } { _M_initialize_dispatch(__first, __last, __false_type()); }
#else #else
template<typename _InputIterator> template<typename _InputIterator>
vector(_InputIterator __first, _InputIterator __last, vector(_InputIterator __first, _InputIterator __last,
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
: _Base(__a) : _Base(__a)
{ {
// Check whether it's an integral type. If so, it's not an iterator. // Check whether it's an integral type. If so, it's not an iterator.
typedef typename std::__is_integer<_InputIterator>::__type _Integral; typedef typename std::__is_integer<_InputIterator>::__type _Integral;
_M_initialize_dispatch(__first, __last, _Integral()); _M_initialize_dispatch(__first, __last, _Integral());
...@@ -449,10 +451,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -449,10 +451,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
vector& vector&
operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
{ {
constexpr bool __move_storage = constexpr bool __move_storage =
_Alloc_traits::_S_propagate_on_move_assign() _Alloc_traits::_S_propagate_on_move_assign()
|| _Alloc_traits::_S_always_equal(); || _Alloc_traits::_S_always_equal();
_M_move_assign(std::move(__x), __bool_constant<__move_storage>()); _M_move_assign(std::move(__x), __bool_constant<__move_storage>());
return *this; return *this;
} }
...@@ -470,7 +472,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -470,7 +472,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
vector& vector&
operator=(initializer_list<value_type> __l) operator=(initializer_list<value_type> __l)
{ {
this->assign(__l.begin(), __l.end()); this->_M_assign_aux(__l.begin(), __l.end(),
random_access_iterator_tag());
return *this; return *this;
} }
#endif #endif
...@@ -504,14 +507,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -504,14 +507,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
template<typename _InputIterator, template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>> typename = std::_RequireInputIter<_InputIterator>>
void void
assign(_InputIterator __first, _InputIterator __last) assign(_InputIterator __first, _InputIterator __last)
{ _M_assign_dispatch(__first, __last, __false_type()); } { _M_assign_dispatch(__first, __last, __false_type()); }
#else #else
template<typename _InputIterator> template<typename _InputIterator>
void void
assign(_InputIterator __first, _InputIterator __last) assign(_InputIterator __first, _InputIterator __last)
{ {
// Check whether it's an integral type. If so, it's not an iterator. // Check whether it's an integral type. If so, it's not an iterator.
typedef typename std::__is_integer<_InputIterator>::__type _Integral; typedef typename std::__is_integer<_InputIterator>::__type _Integral;
_M_assign_dispatch(__first, __last, _Integral()); _M_assign_dispatch(__first, __last, _Integral());
...@@ -532,7 +535,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -532,7 +535,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*/ */
void void
assign(initializer_list<value_type> __l) assign(initializer_list<value_type> __l)
{ this->assign(__l.begin(), __l.end()); } {
this->_M_assign_aux(__l.begin(), __l.end(),
random_access_iterator_tag());
}
#endif #endif
/// Get a copy of the memory allocation object. /// Get a copy of the memory allocation object.
...@@ -694,7 +700,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -694,7 +700,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
resize(size_type __new_size, const value_type& __x) resize(size_type __new_size, const value_type& __x)
{ {
if (__new_size > size()) if (__new_size > size())
insert(end(), __new_size - size(), __x); _M_fill_insert(end(), __new_size - size(), __x);
else if (__new_size < size()) else if (__new_size < size())
_M_erase_at_end(this->_M_impl._M_start + __new_size); _M_erase_at_end(this->_M_impl._M_start + __new_size);
} }
...@@ -714,7 +720,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -714,7 +720,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
resize(size_type __new_size, value_type __x = value_type()) resize(size_type __new_size, value_type __x = value_type())
{ {
if (__new_size > size()) if (__new_size > size())
insert(end(), __new_size - size(), __x); _M_fill_insert(end(), __new_size - size(), __x);
else if (__new_size < size()) else if (__new_size < size())
_M_erase_at_end(this->_M_impl._M_start + __new_size); _M_erase_at_end(this->_M_impl._M_start + __new_size);
} }
...@@ -916,7 +922,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -916,7 +922,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage) if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
{ {
_Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
__x); __x);
++this->_M_impl._M_finish; ++this->_M_impl._M_finish;
} }
else else
...@@ -933,8 +939,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -933,8 +939,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
{ emplace_back(std::move(__x)); } { emplace_back(std::move(__x)); }
template<typename... _Args> template<typename... _Args>
void void
emplace_back(_Args&&... __args); emplace_back(_Args&&... __args);
#endif #endif
/** /**
...@@ -967,8 +973,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -967,8 +973,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* std::list. * std::list.
*/ */
template<typename... _Args> template<typename... _Args>
iterator iterator
emplace(const_iterator __position, _Args&&... __args); emplace(const_iterator __position, _Args&&... __args);
/** /**
* @brief Inserts given value into %vector before specified iterator. * @brief Inserts given value into %vector before specified iterator.
...@@ -1030,7 +1036,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1030,7 +1036,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*/ */
iterator iterator
insert(const_iterator __position, initializer_list<value_type> __l) insert(const_iterator __position, initializer_list<value_type> __l)
{ return this->insert(__position, __l.begin(), __l.end()); } {
auto __offset = __position - cbegin();
_M_range_insert(begin() + __offset, __l.begin(), __l.end(),
std::random_access_iterator_tag());
return begin() + __offset;
}
#endif #endif
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
...@@ -1092,10 +1103,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1092,10 +1103,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*/ */
template<typename _InputIterator, template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>> typename = std::_RequireInputIter<_InputIterator>>
iterator iterator
insert(const_iterator __position, _InputIterator __first, insert(const_iterator __position, _InputIterator __first,
_InputIterator __last) _InputIterator __last)
{ {
difference_type __offset = __position - cbegin(); difference_type __offset = __position - cbegin();
_M_insert_dispatch(begin() + __offset, _M_insert_dispatch(begin() + __offset,
__first, __last, __false_type()); __first, __last, __false_type());
...@@ -1117,10 +1128,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1117,10 +1128,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* consider using std::list. * consider using std::list.
*/ */
template<typename _InputIterator> template<typename _InputIterator>
void void
insert(iterator __position, _InputIterator __first, insert(iterator __position, _InputIterator __first,
_InputIterator __last) _InputIterator __last)
{ {
// Check whether it's an integral type. If so, it's not an iterator. // Check whether it's an integral type. If so, it's not an iterator.
typedef typename std::__is_integer<_InputIterator>::__type _Integral; typedef typename std::__is_integer<_InputIterator>::__type _Integral;
_M_insert_dispatch(__position, __first, __last, _Integral()); _M_insert_dispatch(__position, __first, __last, _Integral());
...@@ -1196,7 +1207,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1196,7 +1207,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
{ {
this->_M_impl._M_swap_data(__x._M_impl); this->_M_impl._M_swap_data(__x._M_impl);
_Alloc_traits::_S_on_swap(_M_get_Tp_allocator(), _Alloc_traits::_S_on_swap(_M_get_Tp_allocator(),
__x._M_get_Tp_allocator()); __x._M_get_Tp_allocator());
} }
/** /**
...@@ -1215,10 +1226,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1215,10 +1226,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* obtain @a n bytes of memory, and then copies [first,last) into it. * obtain @a n bytes of memory, and then copies [first,last) into it.
*/ */
template<typename _ForwardIterator> template<typename _ForwardIterator>
pointer pointer
_M_allocate_and_copy(size_type __n, _M_allocate_and_copy(size_type __n,
_ForwardIterator __first, _ForwardIterator __last) _ForwardIterator __first, _ForwardIterator __last)
{ {
pointer __result = this->_M_allocate(__n); pointer __result = this->_M_allocate(__n);
__try __try
{ {
...@@ -1241,9 +1252,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1241,9 +1252,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// _GLIBCXX_RESOLVE_LIB_DEFECTS // _GLIBCXX_RESOLVE_LIB_DEFECTS
// 438. Ambiguity in the "do the right thing" clause // 438. Ambiguity in the "do the right thing" clause
template<typename _Integer> template<typename _Integer>
void void
_M_initialize_dispatch(_Integer __n, _Integer __value, __true_type) _M_initialize_dispatch(_Integer __n, _Integer __value, __true_type)
{ {
this->_M_impl._M_start = _M_allocate(static_cast<size_type>(__n)); this->_M_impl._M_start = _M_allocate(static_cast<size_type>(__n));
this->_M_impl._M_end_of_storage = this->_M_impl._M_end_of_storage =
this->_M_impl._M_start + static_cast<size_type>(__n); this->_M_impl._M_start + static_cast<size_type>(__n);
...@@ -1252,10 +1263,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1252,10 +1263,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// Called by the range constructor to implement [23.1.1]/9 // Called by the range constructor to implement [23.1.1]/9
template<typename _InputIterator> template<typename _InputIterator>
void void
_M_initialize_dispatch(_InputIterator __first, _InputIterator __last, _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
__false_type) __false_type)
{ {
typedef typename std::iterator_traits<_InputIterator>:: typedef typename std::iterator_traits<_InputIterator>::
iterator_category _IterCategory; iterator_category _IterCategory;
_M_range_initialize(__first, __last, _IterCategory()); _M_range_initialize(__first, __last, _IterCategory());
...@@ -1263,10 +1274,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1263,10 +1274,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// Called by the second initialize_dispatch above // Called by the second initialize_dispatch above
template<typename _InputIterator> template<typename _InputIterator>
void void
_M_range_initialize(_InputIterator __first, _M_range_initialize(_InputIterator __first,
_InputIterator __last, std::input_iterator_tag) _InputIterator __last, std::input_iterator_tag)
{ {
for (; __first != __last; ++__first) for (; __first != __last; ++__first)
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
emplace_back(*__first); emplace_back(*__first);
...@@ -1277,10 +1288,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1277,10 +1288,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// Called by the second initialize_dispatch above // Called by the second initialize_dispatch above
template<typename _ForwardIterator> template<typename _ForwardIterator>
void void
_M_range_initialize(_ForwardIterator __first, _M_range_initialize(_ForwardIterator __first,
_ForwardIterator __last, std::forward_iterator_tag) _ForwardIterator __last, std::forward_iterator_tag)
{ {
const size_type __n = std::distance(__first, __last); const size_type __n = std::distance(__first, __last);
this->_M_impl._M_start = this->_M_allocate(__n); this->_M_impl._M_start = this->_M_allocate(__n);
this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n; this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
...@@ -1319,31 +1330,27 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1319,31 +1330,27 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// _GLIBCXX_RESOLVE_LIB_DEFECTS // _GLIBCXX_RESOLVE_LIB_DEFECTS
// 438. Ambiguity in the "do the right thing" clause // 438. Ambiguity in the "do the right thing" clause
template<typename _Integer> template<typename _Integer>
void void
_M_assign_dispatch(_Integer __n, _Integer __val, __true_type) _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
{ _M_fill_assign(__n, __val); } { _M_fill_assign(__n, __val); }
// Called by the range assign to implement [23.1.1]/9 // Called by the range assign to implement [23.1.1]/9
template<typename _InputIterator> template<typename _InputIterator>
void void
_M_assign_dispatch(_InputIterator __first, _InputIterator __last, _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
__false_type) __false_type)
{ { _M_assign_aux(__first, __last, std::__iterator_category(__first)); }
typedef typename std::iterator_traits<_InputIterator>::
iterator_category _IterCategory;
_M_assign_aux(__first, __last, _IterCategory());
}
// Called by the second assign_dispatch above // Called by the second assign_dispatch above
template<typename _InputIterator> template<typename _InputIterator>
void void
_M_assign_aux(_InputIterator __first, _InputIterator __last, _M_assign_aux(_InputIterator __first, _InputIterator __last,
std::input_iterator_tag); std::input_iterator_tag);
// Called by the second assign_dispatch above // Called by the second assign_dispatch above
template<typename _ForwardIterator> template<typename _ForwardIterator>
void void
_M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
std::forward_iterator_tag); std::forward_iterator_tag);
// Called by assign(n,t), and the range assign when it turns out // Called by assign(n,t), and the range assign when it turns out
...@@ -1351,7 +1358,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1351,7 +1358,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
void void
_M_fill_assign(size_type __n, const value_type& __val); _M_fill_assign(size_type __n, const value_type& __val);
// Internal insert functions follow. // Internal insert functions follow.
// Called by the range insert to implement [23.1.1]/9 // Called by the range insert to implement [23.1.1]/9
...@@ -1359,32 +1365,31 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1359,32 +1365,31 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// _GLIBCXX_RESOLVE_LIB_DEFECTS // _GLIBCXX_RESOLVE_LIB_DEFECTS
// 438. Ambiguity in the "do the right thing" clause // 438. Ambiguity in the "do the right thing" clause
template<typename _Integer> template<typename _Integer>
void void
_M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val, _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
__true_type) __true_type)
{ _M_fill_insert(__pos, __n, __val); } { _M_fill_insert(__pos, __n, __val); }
// Called by the range insert to implement [23.1.1]/9 // Called by the range insert to implement [23.1.1]/9
template<typename _InputIterator> template<typename _InputIterator>
void void
_M_insert_dispatch(iterator __pos, _InputIterator __first, _M_insert_dispatch(iterator __pos, _InputIterator __first,
_InputIterator __last, __false_type) _InputIterator __last, __false_type)
{ {
typedef typename std::iterator_traits<_InputIterator>:: _M_range_insert(__pos, __first, __last,
iterator_category _IterCategory; std::__iterator_category(__first));
_M_range_insert(__pos, __first, __last, _IterCategory());
} }
// Called by the second insert_dispatch above // Called by the second insert_dispatch above
template<typename _InputIterator> template<typename _InputIterator>
void void
_M_range_insert(iterator __pos, _InputIterator __first, _M_range_insert(iterator __pos, _InputIterator __first,
_InputIterator __last, std::input_iterator_tag); _InputIterator __last, std::input_iterator_tag);
// Called by the second insert_dispatch above // Called by the second insert_dispatch above
template<typename _ForwardIterator> template<typename _ForwardIterator>
void void
_M_range_insert(iterator __pos, _ForwardIterator __first, _M_range_insert(iterator __pos, _ForwardIterator __first,
_ForwardIterator __last, std::forward_iterator_tag); _ForwardIterator __last, std::forward_iterator_tag);
// Called by insert(p,n,x), and the range insert when it turns out to be // Called by insert(p,n,x), and the range insert when it turns out to be
...@@ -1407,12 +1412,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -1407,12 +1412,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_M_insert_aux(iterator __position, const value_type& __x); _M_insert_aux(iterator __position, const value_type& __x);
#else #else
template<typename... _Args> template<typename... _Args>
void void
_M_insert_aux(iterator __position, _Args&&... __args); _M_insert_aux(iterator __position, _Args&&... __args);
template<typename... _Args> template<typename... _Args>
void void
_M_emplace_back_aux(_Args&&... __args); _M_emplace_back_aux(_Args&&... __args);
#endif #endif
// Called by the latter. // Called by the latter.
......
...@@ -256,7 +256,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ...@@ -256,7 +256,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
if (__first == __last) if (__first == __last)
_M_erase_at_end(__cur); _M_erase_at_end(__cur);
else else
insert(end(), __first, __last); _M_range_insert(end(), __first, __last,
std::__iterator_category(__first));
} }
template<typename _Tp, typename _Alloc> template<typename _Tp, typename _Alloc>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment