Commit fe62dd04 by François Dumont

stl_deque.h (deque): Access allocator value_type only if concept checks are enabled.

2017-03-20  François Dumont  <fdumont@gcc.gnu.org>

	* include/bits/stl_deque.h (deque): Access allocator value_type only if
	concept checks are enabled.
	* include/bits/stl_stack.h (stack): Likewise.
	* include/bits/stl_vector.h (vector): Likewise.
	* include/bits/stl_list.h (list): Likewise and check
	_SGIAssignableConcept only in C++03.
	* include/bits/stl_map.h (map): Likewise.
	* include/bits/stl_set.h (set): Likewise.
	* include/bits/stl_multimap.h (multimap): Likewise.
	* include/bits/stl_multiset.h (multiset): Likewise.
	* include/bits/stl_queue.h (queue, priority_queue): Likewise.

From-SVN: r246294
parent 92279d5f
2017-03-20 François Dumont <fdumont@gcc.gnu.org>
* include/bits/stl_deque.h (deque): Access allocator value_type only if
concept checks are enabled.
* include/bits/stl_stack.h (stack): Likewise.
* include/bits/stl_vector.h (vector): Likewise.
* include/bits/stl_list.h (list): Likewise and check
_SGIAssignableConcept only in C++03.
* include/bits/stl_map.h (map): Likewise.
* include/bits/stl_set.h (set): Likewise.
* include/bits/stl_multimap.h (multimap): Likewise.
* include/bits/stl_multiset.h (multiset): Likewise.
* include/bits/stl_queue.h (queue, priority_queue): Likewise.
2017-03-18 Gerald Pfeifer <gerald@pfeifer.com>
* doc/xml/manual/appendix_contributing.xml: Convert link to
......@@ -351,7 +365,7 @@
Tweak link description.
2017-02-18 Gerald Pfeifer <gerald@pfeifer.com>
* doc/xml/manual/profile_mode.xml: Fix link.
2017-02-16 Gerald Pfeifer <gerald@pfeifer.com>
......@@ -418,9 +432,9 @@
* include/bits/atomic_base.h: Re-indent.
2017-02-10 Gerald Pfeifer <gerald@pfeifer.com>
2017-02-10 Gerald Pfeifer <gerald@pfeifer.com>
* doc/xml/manual/profile_mode.xml: Update a paper reference.
* doc/xml/manual/profile_mode.xml: Update a paper reference.
2017-02-08 Gerald Pfeifer <gerald@pfeifer.com>
......@@ -440,16 +454,16 @@
* doc/html/*: Regenerate.
2017-02-08 Gerald Pfeifer <gerald@pfeifer.com>
* doc/xml/manual/profile_mode.xml: Unbreak link to
"Optimizing Sorting with Machine Learning Algorithms".
2017-02-08 Gerald Pfeifer <gerald@pfeifer.com>
* src/c++11/snprintf_lite.cc (__err): Update bug reporting URL.
2017-02-08 Gerald Pfeifer <gerald@pfeifer.com>
* doc/xml/manual/abi.xml: Update link to "Sun Studio 11: C++
Migration Guide".
......@@ -714,7 +728,7 @@
* doc/xml/manual/debug.xml: code.google.com uses https now.
2017-01-22 Gerald Pfeifer <gerald@pfeifer.com>
* doc/xml/manual/test.xml: Fix link into gccint online manual.
2017-01-21 Ville Voutilainen <ville.voutilainen@gmail.com>
......@@ -935,7 +949,7 @@
2017-01-17 Joshua Conner <joshconner@google.com>
* crossconfig.m4: Add fuchsia OS.
* configure: Regenerate.
* configure: Regenerate.
2017-01-17 Jonathan Wakely <jwakely@redhat.com>
......@@ -1415,7 +1429,7 @@
* doc/xml/faq.xml: Update address of C++ ABI link.
* doc/xml/manual/abi.xml: Ditto.
2017-01-01 Jakub Jelinek <jakub@redhat.com>
Update copyright years.
......
......@@ -108,10 +108,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
struct _Deque_iterator
{
#if __cplusplus < 201103L
typedef _Deque_iterator<_Tp, _Tp&, _Tp*> iterator;
typedef _Deque_iterator<_Tp, _Tp&, _Tp*> iterator;
typedef _Deque_iterator<_Tp, const _Tp&, const _Tp*> const_iterator;
typedef _Tp* _Elt_pointer;
typedef _Tp** _Map_pointer;
typedef _Tp* _Elt_pointer;
typedef _Tp** _Map_pointer;
#else
private:
template<typename _Up>
......@@ -128,13 +128,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
static size_t _S_buffer_size() _GLIBCXX_NOEXCEPT
{ return __deque_buf_size(sizeof(_Tp)); }
typedef std::random_access_iterator_tag iterator_category;
typedef _Tp value_type;
typedef _Ptr pointer;
typedef _Ref reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef _Deque_iterator _Self;
typedef std::random_access_iterator_tag iterator_category;
typedef _Tp value_type;
typedef _Ptr pointer;
typedef _Ref reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef _Deque_iterator _Self;
_Elt_pointer _M_cur;
_Elt_pointer _M_first;
......@@ -143,14 +143,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_Deque_iterator(_Elt_pointer __x, _Map_pointer __y) _GLIBCXX_NOEXCEPT
: _M_cur(__x), _M_first(*__y),
_M_last(*__y + _S_buffer_size()), _M_node(__y) { }
_M_last(*__y + _S_buffer_size()), _M_node(__y) { }
_Deque_iterator() _GLIBCXX_NOEXCEPT
: _M_cur(), _M_first(), _M_last(), _M_node() { }
_Deque_iterator(const iterator& __x) _GLIBCXX_NOEXCEPT
: _M_cur(__x._M_cur), _M_first(__x._M_first),
_M_last(__x._M_last), _M_node(__x._M_node) { }
_M_last(__x._M_last), _M_node(__x._M_node) { }
iterator
_M_const_cast() const _GLIBCXX_NOEXCEPT
......@@ -214,7 +214,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
{
const difference_type __node_offset =
__offset > 0 ? __offset / difference_type(_S_buffer_size())
: -difference_type((-__offset - 1)
: -difference_type((-__offset - 1)
/ _S_buffer_size()) - 1;
_M_set_node(_M_node + __node_offset);
_M_cur = _M_first + (__offset - __node_offset
......@@ -245,7 +245,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
operator[](difference_type __n) const _GLIBCXX_NOEXCEPT
{ return *(*this + __n); }
/**
/**
* Prepares to traverse new_node. Sets everything except
* _M_cur, which should therefore be set by the caller
* immediately afterwards, based on _M_first and _M_last.
......@@ -293,7 +293,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
operator<(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) _GLIBCXX_NOEXCEPT
{ return (__x._M_node == __y._M_node) ? (__x._M_cur < __y._M_cur)
: (__x._M_node < __y._M_node); }
: (__x._M_node < __y._M_node); }
template<typename _Tp, typename _RefL, typename _PtrL,
typename _RefR, typename _PtrR>
......@@ -301,7 +301,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
operator<(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT
{ return (__x._M_node == __y._M_node) ? (__x._M_cur < __y._M_cur)
: (__x._M_node < __y._M_node); }
: (__x._M_node < __y._M_node); }
template<typename _Tp, typename _Ref, typename _Ptr>
inline bool
......@@ -477,14 +477,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
typedef __gnu_cxx::__alloc_traits<_Map_alloc_type> _Map_alloc_traits;
public:
typedef _Alloc allocator_type;
typedef _Alloc allocator_type;
typedef typename _Alloc_traits::size_type size_type;
allocator_type
get_allocator() const _GLIBCXX_NOEXCEPT
{ return allocator_type(_M_get_Tp_allocator()); }
typedef _Deque_iterator<_Tp, _Tp&, _Ptr> iterator;
typedef _Deque_iterator<_Tp, _Tp&, _Ptr> iterator;
typedef _Deque_iterator<_Tp, const _Tp&, _Ptr_const> const_iterator;
_Deque_base()
......@@ -597,7 +597,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_Ptr
_M_allocate_node()
{
{
typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Traits;
return _Traits::allocate(_M_impl, __deque_buf_size(sizeof(_Tp)));
}
......@@ -830,12 +830,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
class deque : protected _Deque_base<_Tp, _Alloc>
{
#ifdef _GLIBCXX_CONCEPT_CHECKS
// concept requirements
typedef typename _Alloc::value_type _Alloc_value_type;
#if __cplusplus < 201103L
typedef typename _Alloc::value_type _Alloc_value_type;
# if __cplusplus < 201103L
__glibcxx_class_requires(_Tp, _SGIAssignableConcept)
#endif
# endif
__glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept)
#endif
typedef _Deque_base<_Tp, _Alloc> _Base;
typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
......@@ -843,18 +845,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
typedef typename _Base::_Map_pointer _Map_pointer;
public:
typedef _Tp value_type;
typedef typename _Alloc_traits::pointer pointer;
typedef typename _Alloc_traits::const_pointer const_pointer;
typedef typename _Alloc_traits::reference reference;
typedef typename _Alloc_traits::const_reference const_reference;
typedef typename _Base::iterator iterator;
typedef typename _Base::const_iterator const_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef _Alloc allocator_type;
typedef _Tp value_type;
typedef typename _Alloc_traits::pointer pointer;
typedef typename _Alloc_traits::const_pointer const_pointer;
typedef typename _Alloc_traits::reference reference;
typedef typename _Alloc_traits::const_reference const_reference;
typedef typename _Base::iterator iterator;
typedef typename _Base::const_iterator const_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef _Alloc allocator_type;
protected:
static size_t _S_buffer_size() _GLIBCXX_NOEXCEPT
......@@ -870,7 +872,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
using _Base::_M_deallocate_map;
using _Base::_M_get_Tp_allocator;
/**
/**
* A total of four data members accumulated down the hierarchy.
* May be accessed via _M_impl.*
*/
......@@ -945,7 +947,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
deque(const deque& __x)
: _Base(_Alloc_traits::_S_select_on_copy(__x._M_get_Tp_allocator()),
__x.size())
{ std::__uninitialized_copy_a(__x.begin(), __x.end(),
{ std::__uninitialized_copy_a(__x.begin(), __x.end(),
this->_M_impl._M_start,
_M_get_Tp_allocator()); }
......@@ -1018,16 +1020,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
deque(_InputIterator __first, _InputIterator __last,
deque(_InputIterator __first, _InputIterator __last,
const allocator_type& __a = allocator_type())
: _Base(__a)
{ _M_initialize_dispatch(__first, __last, __false_type()); }
{ _M_initialize_dispatch(__first, __last, __false_type()); }
#else
template<typename _InputIterator>
deque(_InputIterator __first, _InputIterator __last,
deque(_InputIterator __first, _InputIterator __last,
const allocator_type& __a = allocator_type())
: _Base(__a)
{
{
// Check whether it's an integral type. If so, it's not an iterator.
typedef typename std::__is_integer<_InputIterator>::__type _Integral;
_M_initialize_dispatch(__first, __last, _Integral());
......@@ -1120,14 +1122,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
void
assign(_InputIterator __first, _InputIterator __last)
{ _M_assign_dispatch(__first, __last, __false_type()); }
void
assign(_InputIterator __first, _InputIterator __last)
{ _M_assign_dispatch(__first, __last, __false_type()); }
#else
template<typename _InputIterator>
void
assign(_InputIterator __first, _InputIterator __last)
{
void
assign(_InputIterator __first, _InputIterator __last)
{
typedef typename std::__is_integer<_InputIterator>::__type _Integral;
_M_assign_dispatch(__first, __last, _Integral());
}
......@@ -1505,8 +1507,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
if (this->_M_impl._M_start._M_cur != this->_M_impl._M_start._M_first)
{
_Alloc_traits::construct(this->_M_impl,
this->_M_impl._M_start._M_cur - 1,
__x);
this->_M_impl._M_start._M_cur - 1,
__x);
--this->_M_impl._M_start._M_cur;
}
else
......@@ -1524,7 +1526,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#else
void
#endif
emplace_front(_Args&&... __args);
emplace_front(_Args&&... __args);
#endif
/**
......@@ -1543,7 +1545,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
!= this->_M_impl._M_finish._M_last - 1)
{
_Alloc_traits::construct(this->_M_impl,
this->_M_impl._M_finish._M_cur, __x);
this->_M_impl._M_finish._M_cur, __x);
++this->_M_impl._M_finish._M_cur;
}
else
......@@ -1561,7 +1563,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#else
void
#endif
emplace_back(_Args&&... __args);
emplace_back(_Args&&... __args);
#endif
/**
......@@ -1580,7 +1582,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
!= this->_M_impl._M_start._M_last - 1)
{
_Alloc_traits::destroy(this->_M_impl,
this->_M_impl._M_start._M_cur);
this->_M_impl._M_start._M_cur);
++this->_M_impl._M_start._M_cur;
}
else
......@@ -1604,7 +1606,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
{
--this->_M_impl._M_finish._M_cur;
_Alloc_traits::destroy(this->_M_impl,
this->_M_impl._M_finish._M_cur);
this->_M_impl._M_finish._M_cur);
}
else
_M_pop_back_aux();
......@@ -1621,8 +1623,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* with T(std::forward<Args>(args)...) before the specified location.
*/
template<typename... _Args>
iterator
emplace(const_iterator __position, _Args&&... __args);
iterator
emplace(const_iterator __position, _Args&&... __args);
/**
* @brief Inserts given value into %deque before specified iterator.
......@@ -1729,10 +1731,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*/
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
iterator
insert(const_iterator __position, _InputIterator __first,
iterator
insert(const_iterator __position, _InputIterator __first,
_InputIterator __last)
{
{
difference_type __offset = __position - cbegin();
_M_insert_dispatch(__position._M_const_cast(),
__first, __last, __false_type());
......@@ -1750,10 +1752,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* by @a __position. This is known as <em>range insert</em>.
*/
template<typename _InputIterator>
void
insert(iterator __position, _InputIterator __first,
void
insert(iterator __position, _InputIterator __first,
_InputIterator __last)
{
{
// Check whether it's an integral type. If so, it's not an iterator.
typedef typename std::__is_integer<_InputIterator>::__type _Integral;
_M_insert_dispatch(__position, __first, __last, _Integral());
......@@ -1846,19 +1848,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 438. Ambiguity in the "do the right thing" clause
template<typename _Integer>
void
_M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
{
void
_M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
{
_M_initialize_map(static_cast<size_type>(__n));
_M_fill_initialize(__x);
}
// called by the range constructor to implement [23.1.1]/9
template<typename _InputIterator>
void
_M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
void
_M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
__false_type)
{
{
_M_range_initialize(__first, __last,
std::__iterator_category(__first));
}
......@@ -1876,14 +1878,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* push_back on each value from the iterator.
*/
template<typename _InputIterator>
void
_M_range_initialize(_InputIterator __first, _InputIterator __last,
void
_M_range_initialize(_InputIterator __first, _InputIterator __last,
std::input_iterator_tag);
// called by the second initialize_dispatch above
template<typename _ForwardIterator>
void
_M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
void
_M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
std::forward_iterator_tag);
//@}
......@@ -1914,29 +1916,29 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 438. Ambiguity in the "do the right thing" clause
template<typename _Integer>
void
_M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
{ _M_fill_assign(__n, __val); }
void
_M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
{ _M_fill_assign(__n, __val); }
// called by the range assign to implement [23.1.1]/9
template<typename _InputIterator>
void
_M_assign_dispatch(_InputIterator __first, _InputIterator __last,
void
_M_assign_dispatch(_InputIterator __first, _InputIterator __last,
__false_type)
{ _M_assign_aux(__first, __last, std::__iterator_category(__first)); }
// called by the second assign_dispatch above
template<typename _InputIterator>
void
_M_assign_aux(_InputIterator __first, _InputIterator __last,
void
_M_assign_aux(_InputIterator __first, _InputIterator __last,
std::input_iterator_tag);
// called by the second assign_dispatch above
template<typename _ForwardIterator>
void
_M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
void
_M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
std::forward_iterator_tag)
{
{
const size_type __len = std::distance(__first, __last);
if (__len > size())
{
......@@ -1975,10 +1977,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
void _M_push_front_aux(const value_type&);
#else
template<typename... _Args>
void _M_push_back_aux(_Args&&... __args);
void _M_push_back_aux(_Args&&... __args);
template<typename... _Args>
void _M_push_front_aux(_Args&&... __args);
void _M_push_front_aux(_Args&&... __args);
#endif
void _M_pop_back_aux();
......@@ -1994,32 +1996,32 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 438. Ambiguity in the "do the right thing" clause
template<typename _Integer>
void
_M_insert_dispatch(iterator __pos,
void
_M_insert_dispatch(iterator __pos,
_Integer __n, _Integer __x, __true_type)
{ _M_fill_insert(__pos, __n, __x); }
{ _M_fill_insert(__pos, __n, __x); }
// called by the range insert to implement [23.1.1]/9
template<typename _InputIterator>
void
_M_insert_dispatch(iterator __pos,
void
_M_insert_dispatch(iterator __pos,
_InputIterator __first, _InputIterator __last,
__false_type)
{
_M_range_insert_aux(__pos, __first, __last,
{
_M_range_insert_aux(__pos, __first, __last,
std::__iterator_category(__first));
}
// called by the second insert_dispatch above
template<typename _InputIterator>
void
_M_range_insert_aux(iterator __pos, _InputIterator __first,
void
_M_range_insert_aux(iterator __pos, _InputIterator __first,
_InputIterator __last, std::input_iterator_tag);
// called by the second insert_dispatch above
template<typename _ForwardIterator>
void
_M_range_insert_aux(iterator __pos, _ForwardIterator __first,
void
_M_range_insert_aux(iterator __pos, _ForwardIterator __first,
_ForwardIterator __last, std::forward_iterator_tag);
// Called by insert(p,n,x), and the range insert when it turns out to be
......@@ -2034,8 +2036,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_M_insert_aux(iterator __pos, const value_type& __x);
#else
template<typename... _Args>
iterator
_M_insert_aux(iterator __pos, _Args&&... __args);
iterator
_M_insert_aux(iterator __pos, _Args&&... __args);
#endif
// called by insert(p,n,x) via fill_insert
......@@ -2044,8 +2046,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// called by range_insert_aux for forward iterators
template<typename _ForwardIterator>
void
_M_insert_aux(iterator __pos,
void
_M_insert_aux(iterator __pos,
_ForwardIterator __first, _ForwardIterator __last,
size_type __n);
......@@ -2058,9 +2060,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// Called by ~deque().
// NB: Doesn't deallocate the nodes.
template<typename _Alloc1>
void
_M_destroy_data(iterator __first, iterator __last, const _Alloc1&)
{ _M_destroy_data_aux(__first, __last); }
void
_M_destroy_data(iterator __first, iterator __last, const _Alloc1&)
{ _M_destroy_data_aux(__first, __last); }
void
_M_destroy_data(iterator __first, iterator __last,
......@@ -2111,7 +2113,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_M_reserve_elements_at_front(size_type __n)
{
const size_type __vacancies = this->_M_impl._M_start._M_cur
- this->_M_impl._M_start._M_first;
- this->_M_impl._M_start._M_first;
if (__n > __vacancies)
_M_new_elements_at_front(__n - __vacancies);
return this->_M_impl._M_start - difference_type(__n);
......@@ -2256,7 +2258,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
operator==(const deque<_Tp, _Alloc>& __x,
const deque<_Tp, _Alloc>& __y)
{ return __x.size() == __y.size()
&& std::equal(__x.begin(), __x.end(), __y.begin()); }
&& std::equal(__x.begin(), __x.end(), __y.begin()); }
/**
* @brief Deque ordering relation.
......
......@@ -76,7 +76,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
// "needless" static_cast'ing later on, but it's all safe
// downcasting.
/// Common part of a node in the %list.
/// Common part of a node in the %list.
struct _List_node_base
{
_List_node_base* _M_next;
......@@ -127,14 +127,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Tp>
struct _List_iterator
{
typedef _List_iterator<_Tp> _Self;
typedef _List_node<_Tp> _Node;
typedef _List_iterator<_Tp> _Self;
typedef _List_node<_Tp> _Node;
typedef ptrdiff_t difference_type;
typedef std::bidirectional_iterator_tag iterator_category;
typedef _Tp value_type;
typedef _Tp* pointer;
typedef _Tp& reference;
typedef ptrdiff_t difference_type;
typedef std::bidirectional_iterator_tag iterator_category;
typedef _Tp value_type;
typedef _Tp* pointer;
typedef _Tp& reference;
_List_iterator() _GLIBCXX_NOEXCEPT
: _M_node() { }
......@@ -206,15 +206,15 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Tp>
struct _List_const_iterator
{
typedef _List_const_iterator<_Tp> _Self;
typedef const _List_node<_Tp> _Node;
typedef _List_iterator<_Tp> iterator;
typedef _List_const_iterator<_Tp> _Self;
typedef const _List_node<_Tp> _Node;
typedef _List_iterator<_Tp> iterator;
typedef ptrdiff_t difference_type;
typedef std::bidirectional_iterator_tag iterator_category;
typedef _Tp value_type;
typedef const _Tp* pointer;
typedef const _Tp& reference;
typedef ptrdiff_t difference_type;
typedef std::bidirectional_iterator_tag iterator_category;
typedef _Tp value_type;
typedef const _Tp* pointer;
typedef const _Tp& reference;
_List_const_iterator() _GLIBCXX_NOEXCEPT
: _M_node() { }
......@@ -291,7 +291,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Val>
inline bool
operator!=(const _List_iterator<_Val>& __x,
const _List_const_iterator<_Val>& __y) _GLIBCXX_NOEXCEPT
const _List_const_iterator<_Val>& __y) _GLIBCXX_NOEXCEPT
{ return __x._M_node != __y._M_node; }
_GLIBCXX_BEGIN_NAMESPACE_CXX11
......@@ -447,8 +447,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
void
_M_init() _GLIBCXX_NOEXCEPT
{
this->_M_impl._M_node._M_next = &this->_M_impl._M_node;
this->_M_impl._M_node._M_prev = &this->_M_impl._M_node;
this->_M_impl._M_node._M_next = &this->_M_impl._M_node;
this->_M_impl._M_node._M_prev = &this->_M_impl._M_node;
_M_set_size(0);
}
};
......@@ -497,35 +497,39 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
* pointing to @e D, not to @e A! To get to the head of the %list,
* we start at the tail and move forward by one. When this member
* iterator's next/previous pointers refer to itself, the %list is
* %empty.
* %empty.
*/
template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
class list : protected _List_base<_Tp, _Alloc>
{
#ifdef _GLIBCXX_CONCEPT_CHECKS
// concept requirements
typedef typename _Alloc::value_type _Alloc_value_type;
typedef typename _Alloc::value_type _Alloc_value_type;
# if __cplusplus < 201103L
__glibcxx_class_requires(_Tp, _SGIAssignableConcept)
# endif
__glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept)
#endif
typedef _List_base<_Tp, _Alloc> _Base;
typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
typedef typename _Base::_Tp_alloc_traits _Tp_alloc_traits;
typedef typename _Base::_Node_alloc_type _Node_alloc_type;
typedef typename _Base::_Node_alloc_traits _Node_alloc_traits;
typedef _List_base<_Tp, _Alloc> _Base;
typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
typedef typename _Base::_Tp_alloc_traits _Tp_alloc_traits;
typedef typename _Base::_Node_alloc_type _Node_alloc_type;
typedef typename _Base::_Node_alloc_traits _Node_alloc_traits;
public:
typedef _Tp value_type;
typedef _Tp value_type;
typedef typename _Tp_alloc_traits::pointer pointer;
typedef typename _Tp_alloc_traits::const_pointer const_pointer;
typedef typename _Tp_alloc_traits::reference reference;
typedef typename _Tp_alloc_traits::const_reference const_reference;
typedef _List_iterator<_Tp> iterator;
typedef _List_const_iterator<_Tp> const_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef _Alloc allocator_type;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef _Alloc allocator_type;
protected:
// Note that pointers-to-_Node's can be ctor-converted to
......@@ -562,8 +566,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
}
#else
template<typename... _Args>
_Node*
_M_create_node(_Args&&... __args)
_Node*
_M_create_node(_Args&&... __args)
{
auto __p = this->_M_get_node();
auto& __alloc = _M_get_Node_allocator();
......@@ -670,7 +674,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
* initializer_list @a __l. This is linear in __l.size().
*/
list(initializer_list<value_type> __l,
const allocator_type& __a = allocator_type())
const allocator_type& __a = allocator_type())
: _Base(_Node_alloc_type(__a))
{ _M_initialize_dispatch(__l.begin(), __l.end(), __false_type()); }
......@@ -702,16 +706,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
list(_InputIterator __first, _InputIterator __last,
list(_InputIterator __first, _InputIterator __last,
const allocator_type& __a = allocator_type())
: _Base(_Node_alloc_type(__a))
{ _M_initialize_dispatch(__first, __last, __false_type()); }
{ _M_initialize_dispatch(__first, __last, __false_type()); }
#else
template<typename _InputIterator>
list(_InputIterator __first, _InputIterator __last,
list(_InputIterator __first, _InputIterator __last,
const allocator_type& __a = allocator_type())
: _Base(_Node_alloc_type(__a))
{
{
// Check whether it's an integral type. If so, it's not an iterator.
typedef typename std::__is_integer<_InputIterator>::__type _Integral;
_M_initialize_dispatch(__first, __last, _Integral());
......@@ -756,9 +760,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
noexcept(_Node_alloc_traits::_S_nothrow_move())
{
constexpr bool __move_storage =
_Node_alloc_traits::_S_propagate_on_move_assign()
|| _Node_alloc_traits::_S_always_equal();
_M_move_assign(std::move(__x), __bool_constant<__move_storage>());
_Node_alloc_traits::_S_propagate_on_move_assign()
|| _Node_alloc_traits::_S_always_equal();
_M_move_assign(std::move(__x), __bool_constant<__move_storage>());
return *this;
}
......@@ -806,14 +810,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
void
assign(_InputIterator __first, _InputIterator __last)
{ _M_assign_dispatch(__first, __last, __false_type()); }
void
assign(_InputIterator __first, _InputIterator __last)
{ _M_assign_dispatch(__first, __last, __false_type()); }
#else
template<typename _InputIterator>
void
assign(_InputIterator __first, _InputIterator __last)
{
void
assign(_InputIterator __first, _InputIterator __last)
{
// Check whether it's an integral type. If so, it's not an iterator.
typedef typename std::__is_integer<_InputIterator>::__type _Integral;
_M_assign_dispatch(__first, __last, _Integral());
......@@ -1030,7 +1034,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
*/
reference
back() _GLIBCXX_NOEXCEPT
{
{
iterator __tmp = end();
--__tmp;
return *__tmp;
......@@ -1042,7 +1046,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
*/
const_reference
back() const _GLIBCXX_NOEXCEPT
{
{
const_iterator __tmp = end();
--__tmp;
return *__tmp;
......@@ -1070,12 +1074,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
template<typename... _Args>
#if __cplusplus > 201402L
reference
reference
#else
void
#endif
emplace_front(_Args&&... __args)
{
emplace_front(_Args&&... __args)
{
this->_M_insert(begin(), std::forward<_Args>(__args)...);
#if __cplusplus > 201402L
return front();
......@@ -1120,15 +1124,15 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
template<typename... _Args>
#if __cplusplus > 201402L
reference
reference
#else
void
#endif
emplace_back(_Args&&... __args)
{
emplace_back(_Args&&... __args)
{
this->_M_insert(end(), std::forward<_Args>(__args)...);
#if __cplusplus > 201402L
return back();
return back();
#endif
}
#endif
......@@ -1162,8 +1166,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
* and references.
*/
template<typename... _Args>
iterator
emplace(const_iterator __position, _Args&&... __args);
iterator
emplace(const_iterator __position, _Args&&... __args);
/**
* @brief Inserts given value into %list before specified iterator.
......@@ -1205,7 +1209,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
* the specified location. Due to the nature of a %list this
* operation can be done in constant time, and does not
* invalidate iterators and references.
*/
*/
iterator
insert(const_iterator __position, value_type&& __x)
{ return emplace(__position, std::move(__x)); }
......@@ -1304,10 +1308,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
* does not invalidate iterators and references.
*/
template<typename _InputIterator>
void
insert(iterator __position, _InputIterator __first,
void
insert(iterator __position, _InputIterator __first,
_InputIterator __last)
{
{
list __tmp(__first, __last, get_allocator());
splice(__position, __tmp);
}
......@@ -1380,14 +1384,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
swap(list& __x) _GLIBCXX_NOEXCEPT
{
__detail::_List_node_base::swap(this->_M_impl._M_node,
__x._M_impl._M_node);
__x._M_impl._M_node);
size_t __xsize = __x._M_get_size();
__x._M_set_size(this->_M_get_size());
this->_M_set_size(__xsize);
_Node_alloc_traits::_S_on_swap(this->_M_get_Node_allocator(),
__x._M_get_Node_allocator());
__x._M_get_Node_allocator());
}
/**
......@@ -1399,8 +1403,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
void
clear() _GLIBCXX_NOEXCEPT
{
_Base::_M_clear();
_Base::_M_init();
_Base::_M_clear();
_Base::_M_init();
}
// [23.2.2.4] list operations
......@@ -1594,8 +1598,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
* responsibility.
*/
template<typename _Predicate>
void
remove_if(_Predicate);
void
remove_if(_Predicate);
/**
* @brief Remove consecutive duplicate elements.
......@@ -1623,8 +1627,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
* Managing the pointer is the user's responsibility.
*/
template<typename _BinaryPredicate>
void
unique(_BinaryPredicate);
void
unique(_BinaryPredicate);
/**
* @brief Merge sorted lists.
......@@ -1662,17 +1666,17 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
*/
#if __cplusplus >= 201103L
template<typename _StrictWeakOrdering>
void
merge(list&& __x, _StrictWeakOrdering __comp);
void
merge(list&& __x, _StrictWeakOrdering __comp);
template<typename _StrictWeakOrdering>
void
merge(list& __x, _StrictWeakOrdering __comp)
{ merge(std::move(__x), __comp); }
void
merge(list& __x, _StrictWeakOrdering __comp)
{ merge(std::move(__x), __comp); }
#else
template<typename _StrictWeakOrdering>
void
merge(list& __x, _StrictWeakOrdering __comp);
void
merge(list& __x, _StrictWeakOrdering __comp);
#endif
/**
......@@ -1700,8 +1704,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
* elements remain in list order.
*/
template<typename _StrictWeakOrdering>
void
sort(_StrictWeakOrdering);
void
sort(_StrictWeakOrdering);
protected:
// Internal constructor functions follow.
......@@ -1711,16 +1715,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 438. Ambiguity in the "do the right thing" clause
template<typename _Integer>
void
_M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
{ _M_fill_initialize(static_cast<size_type>(__n), __x); }
void
_M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
{ _M_fill_initialize(static_cast<size_type>(__n), __x); }
// Called by the range constructor to implement [23.1.1]/9
template<typename _InputIterator>
void
_M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
void
_M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
__false_type)
{
{
for (; __first != __last; ++__first)
#if __cplusplus >= 201103L
emplace_back(*__first);
......@@ -1759,14 +1763,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 438. Ambiguity in the "do the right thing" clause
template<typename _Integer>
void
_M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
{ _M_fill_assign(__n, __val); }
void
_M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
{ _M_fill_assign(__n, __val); }
// Called by the range assign to implement [23.1.1]/9
template<typename _InputIterator>
void
_M_assign_dispatch(_InputIterator __first, _InputIterator __last,
void
_M_assign_dispatch(_InputIterator __first, _InputIterator __last,
__false_type);
// Called by assign(n,t), and the range assign when it turns out
......@@ -1785,8 +1789,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
void
_M_insert(iterator __position, const value_type& __x)
{
_Node* __tmp = _M_create_node(__x);
__tmp->_M_hook(__position._M_node);
_Node* __tmp = _M_create_node(__x);
__tmp->_M_hook(__position._M_node);
this->_M_inc_size(1);
}
#else
......@@ -1805,15 +1809,15 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
_M_erase(iterator __position) _GLIBCXX_NOEXCEPT
{
this->_M_dec_size(1);
__position._M_node->_M_unhook();
_Node* __n = static_cast<_Node*>(__position._M_node);
__position._M_node->_M_unhook();
_Node* __n = static_cast<_Node*>(__position._M_node);
#if __cplusplus >= 201103L
_Node_alloc_traits::destroy(_M_get_Node_allocator(), __n->_M_valptr());
#else
_Tp_alloc_type(_M_get_Node_allocator()).destroy(__n->_M_valptr());
#endif
_M_put_node(__n);
_M_put_node(__n);
}
// To implement the splice (and merge) bits of N1599.
......@@ -1845,16 +1849,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
this->_M_set_size(__x._M_get_size());
__x._M_init();
}
std::__alloc_on_move(this->_M_get_Node_allocator(),
__x._M_get_Node_allocator());
std::__alloc_on_move(this->_M_get_Node_allocator(),
__x._M_get_Node_allocator());
}
void
_M_move_assign(list&& __x, false_type)
{
if (__x._M_get_Node_allocator() == this->_M_get_Node_allocator())
_M_move_assign(std::move(__x), true_type{});
else
_M_move_assign(std::move(__x), true_type{});
else
// The rvalue's allocator cannot be moved, or is not equal,
// so we need to individually move each element.
_M_assign_dispatch(std::__make_move_if_noexcept_iterator(__x.begin()),
......
......@@ -79,7 +79,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* @tparam _Key Type of key objects.
* @tparam _Tp Type of mapped objects.
* @tparam _Compare Comparison function object type, defaults to less<_Key>.
* @tparam _Alloc Allocator type, defaults to
* @tparam _Alloc Allocator type, defaults to
* allocator<pair<const _Key, _Tp>.
*
* Meets the requirements of a <a href="tables.html#65">container</a>, a
......@@ -95,23 +95,27 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* called (*_unique versus *_equal, same as the standard).
*/
template <typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
class map
{
public:
typedef _Key key_type;
typedef _Tp mapped_type;
typedef std::pair<const _Key, _Tp> value_type;
typedef _Compare key_compare;
typedef _Alloc allocator_type;
typedef _Key key_type;
typedef _Tp mapped_type;
typedef std::pair<const _Key, _Tp> value_type;
typedef _Compare key_compare;
typedef _Alloc allocator_type;
private:
#ifdef _GLIBCXX_CONCEPT_CHECKS
// concept requirements
typedef typename _Alloc::value_type _Alloc_value_type;
typedef typename _Alloc::value_type _Alloc_value_type;
# if __cplusplus < 201103L
__glibcxx_class_requires(_Tp, _SGIAssignableConcept)
# endif
__glibcxx_class_requires4(_Compare, bool, _Key, _Key,
_BinaryFunctionConcept)
__glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept)
#endif
public:
class value_compare
......@@ -130,7 +134,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
};
private:
/// This turns a red-black tree into a [multi]map.
/// This turns a red-black tree into a [multi]map.
typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template
rebind<value_type>::other _Pair_alloc_type;
......@@ -145,15 +149,15 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
public:
// many of these are specified differently in ISO, but the following are
// "functionally equivalent"
typedef typename _Alloc_traits::pointer pointer;
typedef typename _Alloc_traits::const_pointer const_pointer;
typedef typename _Alloc_traits::reference reference;
typedef typename _Alloc_traits::const_reference const_reference;
typedef typename _Rep_type::iterator iterator;
typedef typename _Rep_type::const_iterator const_iterator;
typedef typename _Rep_type::size_type size_type;
typedef typename _Rep_type::difference_type difference_type;
typedef typename _Rep_type::reverse_iterator reverse_iterator;
typedef typename _Alloc_traits::pointer pointer;
typedef typename _Alloc_traits::const_pointer const_pointer;
typedef typename _Alloc_traits::reference reference;
typedef typename _Alloc_traits::const_reference const_reference;
typedef typename _Rep_type::iterator iterator;
typedef typename _Rep_type::const_iterator const_iterator;
typedef typename _Rep_type::size_type size_type;
typedef typename _Rep_type::difference_type difference_type;
typedef typename _Rep_type::reverse_iterator reverse_iterator;
typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
#if __cplusplus > 201402L
......@@ -241,10 +245,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
/// Allocator-extended range constructor.
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last,
map(_InputIterator __first, _InputIterator __last,
const allocator_type& __a)
: _M_t(_Compare(), _Pair_alloc_type(__a))
{ _M_t._M_insert_unique(__first, __last); }
{ _M_t._M_insert_unique(__first, __last); }
#endif
/**
......@@ -258,9 +262,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* distance(__first,__last)).
*/
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last)
map(_InputIterator __first, _InputIterator __last)
: _M_t()
{ _M_t._M_insert_unique(__first, __last); }
{ _M_t._M_insert_unique(__first, __last); }
/**
* @brief Builds a %map from a range.
......@@ -275,11 +279,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* distance(__first,__last)).
*/
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last,
map(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const allocator_type& __a = allocator_type())
: _M_t(__comp, _Pair_alloc_type(__a))
{ _M_t._M_insert_unique(__first, __last); }
{ _M_t._M_insert_unique(__first, __last); }
#if __cplusplus >= 201103L
/**
......@@ -490,7 +494,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
std::tuple<const key_type&>(__k),
std::tuple<>());
#else
__i = insert(__i, value_type(__k, mapped_type()));
__i = insert(__i, value_type(__k, mapped_type()));
#endif
return (*__i).second;
}
......@@ -659,7 +663,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*
* @param __k Key to use for finding a possibly existing pair in
* the map.
* @param __args Arguments used to generate the .second for a new pair
* @param __args Arguments used to generate the .second for a new pair
* instance.
*
* @return A pair, of which the first element is an iterator that points
......@@ -675,37 +679,37 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* Insertion requires logarithmic time.
*/
template <typename... _Args>
pair<iterator, bool>
try_emplace(const key_type& __k, _Args&&... __args)
{
iterator __i = lower_bound(__k);
if (__i == end() || key_comp()(__k, (*__i).first))
{
__i = emplace_hint(__i, std::piecewise_construct,
std::forward_as_tuple(__k),
std::forward_as_tuple(
std::forward<_Args>(__args)...));
return {__i, true};
}
return {__i, false};
}
pair<iterator, bool>
try_emplace(const key_type& __k, _Args&&... __args)
{
iterator __i = lower_bound(__k);
if (__i == end() || key_comp()(__k, (*__i).first))
{
__i = emplace_hint(__i, std::piecewise_construct,
std::forward_as_tuple(__k),
std::forward_as_tuple(
std::forward<_Args>(__args)...));
return {__i, true};
}
return {__i, false};
}
// move-capable overload
template <typename... _Args>
pair<iterator, bool>
try_emplace(key_type&& __k, _Args&&... __args)
{
iterator __i = lower_bound(__k);
if (__i == end() || key_comp()(__k, (*__i).first))
{
__i = emplace_hint(__i, std::piecewise_construct,
std::forward_as_tuple(std::move(__k)),
std::forward_as_tuple(
std::forward<_Args>(__args)...));
return {__i, true};
}
return {__i, false};
}
pair<iterator, bool>
try_emplace(key_type&& __k, _Args&&... __args)
{
iterator __i = lower_bound(__k);
if (__i == end() || key_comp()(__k, (*__i).first))
{
__i = emplace_hint(__i, std::piecewise_construct,
std::forward_as_tuple(std::move(__k)),
std::forward_as_tuple(
std::forward<_Args>(__args)...));
return {__i, true};
}
return {__i, false};
}
/**
* @brief Attempts to build and insert a std::pair into the %map.
......@@ -714,14 +718,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* pair should be inserted.
* @param __k Key to use for finding a possibly existing pair in
* the map.
* @param __args Arguments used to generate the .second for a new pair
* @param __args Arguments used to generate the .second for a new pair
* instance.
* @return An iterator that points to the element with key of the
* std::pair built from @a __args (may or may not be that
* std::pair).
*
* This function is not concerned about whether the insertion took place,
* and thus does not return a boolean like the single-argument
* and thus does not return a boolean like the single-argument
* try_emplace() does. However, if insertion did not take place,
* this function has no effect.
* Note that the first parameter is only a hint and can potentially
......@@ -735,40 +739,40 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* Insertion requires logarithmic time (if the hint is not taken).
*/
template <typename... _Args>
iterator
try_emplace(const_iterator __hint, const key_type& __k,
_Args&&... __args)
{
iterator __i;
auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k);
if (__true_hint.second)
__i = emplace_hint(iterator(__true_hint.second),
std::piecewise_construct,
std::forward_as_tuple(__k),
std::forward_as_tuple(
std::forward<_Args>(__args)...));
else
__i = iterator(__true_hint.first);
return __i;
}
iterator
try_emplace(const_iterator __hint, const key_type& __k,
_Args&&... __args)
{
iterator __i;
auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k);
if (__true_hint.second)
__i = emplace_hint(iterator(__true_hint.second),
std::piecewise_construct,
std::forward_as_tuple(__k),
std::forward_as_tuple(
std::forward<_Args>(__args)...));
else
__i = iterator(__true_hint.first);
return __i;
}
// move-capable overload
template <typename... _Args>
iterator
try_emplace(const_iterator __hint, key_type&& __k, _Args&&... __args)
{
iterator __i;
auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k);
if (__true_hint.second)
__i = emplace_hint(iterator(__true_hint.second),
std::piecewise_construct,
std::forward_as_tuple(std::move(__k)),
std::forward_as_tuple(
std::forward<_Args>(__args)...));
else
__i = iterator(__true_hint.first);
return __i;
}
iterator
try_emplace(const_iterator __hint, key_type&& __k, _Args&&... __args)
{
iterator __i;
auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k);
if (__true_hint.second)
__i = emplace_hint(iterator(__true_hint.second),
std::piecewise_construct,
std::forward_as_tuple(std::move(__k)),
std::forward_as_tuple(
std::forward<_Args>(__args)...));
else
__i = iterator(__true_hint.first);
return __i;
}
#endif
/**
......@@ -777,8 +781,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* @param __x Pair to be inserted (see std::make_pair for easy
* creation of pairs).
*
* @return A pair, of which the first element is an iterator that
* points to the possibly inserted pair, and the second is
* @return A pair, of which the first element is an iterator that
* points to the possibly inserted pair, and the second is
* a bool that is true if the pair was actually inserted.
*
* This function attempts to insert a (key, value) %pair into the %map.
......@@ -795,9 +799,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Pair, typename = typename
std::enable_if<std::is_constructible<value_type,
_Pair&&>::value>::type>
std::pair<iterator, bool>
insert(_Pair&& __x)
{ return _M_t._M_insert_unique(std::forward<_Pair>(__x)); }
std::pair<iterator, bool>
insert(_Pair&& __x)
{ return _M_t._M_insert_unique(std::forward<_Pair>(__x)); }
#endif
#if __cplusplus >= 201103L
......@@ -848,9 +852,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Pair, typename = typename
std::enable_if<std::is_constructible<value_type,
_Pair&&>::value>::type>
iterator
insert(const_iterator __position, _Pair&& __x)
{ return _M_t._M_insert_unique_(__position,
iterator
insert(const_iterator __position, _Pair&& __x)
{ return _M_t._M_insert_unique_(__position,
std::forward<_Pair>(__x)); }
#endif
......@@ -863,9 +867,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* Complexity similar to that of the range constructor.
*/
template<typename _InputIterator>
void
insert(_InputIterator __first, _InputIterator __last)
{ _M_t._M_insert_unique(__first, __last); }
void
insert(_InputIterator __first, _InputIterator __last)
{ _M_t._M_insert_unique(__first, __last); }
#if __cplusplus > 201402L
#define __cpp_lib_map_insertion 201411
......@@ -873,11 +877,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* @brief Attempts to insert or assign a std::pair into the %map.
* @param __k Key to use for finding a possibly existing pair in
* the map.
* @param __obj Argument used to generate the .second for a pair
* @param __obj Argument used to generate the .second for a pair
* instance.
*
* @return A pair, of which the first element is an iterator that
* points to the possibly inserted pair, and the second is
* @return A pair, of which the first element is an iterator that
* points to the possibly inserted pair, and the second is
* a bool that is true if the pair was actually inserted.
*
* This function attempts to insert a (key, value) %pair into the %map.
......@@ -889,39 +893,39 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* Insertion requires logarithmic time.
*/
template <typename _Obj>
pair<iterator, bool>
insert_or_assign(const key_type& __k, _Obj&& __obj)
{
iterator __i = lower_bound(__k);
if (__i == end() || key_comp()(__k, (*__i).first))
{
__i = emplace_hint(__i, std::piecewise_construct,
std::forward_as_tuple(__k),
std::forward_as_tuple(
std::forward<_Obj>(__obj)));
return {__i, true};
}
(*__i).second = std::forward<_Obj>(__obj);
return {__i, false};
}
pair<iterator, bool>
insert_or_assign(const key_type& __k, _Obj&& __obj)
{
iterator __i = lower_bound(__k);
if (__i == end() || key_comp()(__k, (*__i).first))
{
__i = emplace_hint(__i, std::piecewise_construct,
std::forward_as_tuple(__k),
std::forward_as_tuple(
std::forward<_Obj>(__obj)));
return {__i, true};
}
(*__i).second = std::forward<_Obj>(__obj);
return {__i, false};
}
// move-capable overload
template <typename _Obj>
pair<iterator, bool>
insert_or_assign(key_type&& __k, _Obj&& __obj)
{
iterator __i = lower_bound(__k);
if (__i == end() || key_comp()(__k, (*__i).first))
{
__i = emplace_hint(__i, std::piecewise_construct,
std::forward_as_tuple(std::move(__k)),
std::forward_as_tuple(
std::forward<_Obj>(__obj)));
return {__i, true};
}
(*__i).second = std::forward<_Obj>(__obj);
return {__i, false};
}
pair<iterator, bool>
insert_or_assign(key_type&& __k, _Obj&& __obj)
{
iterator __i = lower_bound(__k);
if (__i == end() || key_comp()(__k, (*__i).first))
{
__i = emplace_hint(__i, std::piecewise_construct,
std::forward_as_tuple(std::move(__k)),
std::forward_as_tuple(
std::forward<_Obj>(__obj)));
return {__i, true};
}
(*__i).second = std::forward<_Obj>(__obj);
return {__i, false};
}
/**
* @brief Attempts to insert or assign a std::pair into the %map.
......@@ -929,7 +933,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* pair should be inserted.
* @param __k Key to use for finding a possibly existing pair in
* the map.
* @param __obj Argument used to generate the .second for a pair
* @param __obj Argument used to generate the .second for a pair
* instance.
*
* @return An iterator that points to the element with key of
......@@ -944,44 +948,44 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* Insertion requires logarithmic time.
*/
template <typename _Obj>
iterator
insert_or_assign(const_iterator __hint,
const key_type& __k, _Obj&& __obj)
{
iterator __i;
auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k);
if (__true_hint.second)
{
return emplace_hint(iterator(__true_hint.second),
std::piecewise_construct,
std::forward_as_tuple(__k),
std::forward_as_tuple(
std::forward<_Obj>(__obj)));
}
__i = iterator(__true_hint.first);
(*__i).second = std::forward<_Obj>(__obj);
return __i;
}
iterator
insert_or_assign(const_iterator __hint,
const key_type& __k, _Obj&& __obj)
{
iterator __i;
auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k);
if (__true_hint.second)
{
return emplace_hint(iterator(__true_hint.second),
std::piecewise_construct,
std::forward_as_tuple(__k),
std::forward_as_tuple(
std::forward<_Obj>(__obj)));
}
__i = iterator(__true_hint.first);
(*__i).second = std::forward<_Obj>(__obj);
return __i;
}
// move-capable overload
template <typename _Obj>
iterator
insert_or_assign(const_iterator __hint, key_type&& __k, _Obj&& __obj)
{
iterator __i;
auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k);
if (__true_hint.second)
{
return emplace_hint(iterator(__true_hint.second),
std::piecewise_construct,
std::forward_as_tuple(std::move(__k)),
std::forward_as_tuple(
std::forward<_Obj>(__obj)));
}
__i = iterator(__true_hint.first);
(*__i).second = std::forward<_Obj>(__obj);
return __i;
}
iterator
insert_or_assign(const_iterator __hint, key_type&& __k, _Obj&& __obj)
{
iterator __i;
auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k);
if (__true_hint.second)
{
return emplace_hint(iterator(__true_hint.second),
std::piecewise_construct,
std::forward_as_tuple(std::move(__k)),
std::forward_as_tuple(
std::forward<_Obj>(__obj)));
}
__i = iterator(__true_hint.first);
(*__i).second = std::forward<_Obj>(__obj);
return __i;
}
#endif
#if __cplusplus >= 201103L
......@@ -991,7 +995,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* @brief Erases an element from a %map.
* @param __position An iterator pointing to the element to be erased.
* @return An iterator pointing to the element immediately following
* @a position prior to the element being erased. If no such
* @a position prior to the element being erased. If no such
* element exists, end() is returned.
*
* This function erases an element, pointed to by the given
......@@ -1351,13 +1355,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
//@}
template<typename _K1, typename _T1, typename _C1, typename _A1>
friend bool
operator==(const map<_K1, _T1, _C1, _A1>&,
friend bool
operator==(const map<_K1, _T1, _C1, _A1>&,
const map<_K1, _T1, _C1, _A1>&);
template<typename _K1, typename _T1, typename _C1, typename _A1>
friend bool
operator<(const map<_K1, _T1, _C1, _A1>&,
friend bool
operator<(const map<_K1, _T1, _C1, _A1>&,
const map<_K1, _T1, _C1, _A1>&);
};
......@@ -1374,7 +1378,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool
operator==(const map<_Key, _Tp, _Compare, _Alloc>& __x,
const map<_Key, _Tp, _Compare, _Alloc>& __y)
const map<_Key, _Tp, _Compare, _Alloc>& __y)
{ return __x._M_t == __y._M_t; }
/**
......@@ -1391,35 +1395,35 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool
operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x,
const map<_Key, _Tp, _Compare, _Alloc>& __y)
const map<_Key, _Tp, _Compare, _Alloc>& __y)
{ return __x._M_t < __y._M_t; }
/// Based on operator==
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool
operator!=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
const map<_Key, _Tp, _Compare, _Alloc>& __y)
const map<_Key, _Tp, _Compare, _Alloc>& __y)
{ return !(__x == __y); }
/// Based on operator<
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool
operator>(const map<_Key, _Tp, _Compare, _Alloc>& __x,
const map<_Key, _Tp, _Compare, _Alloc>& __y)
const map<_Key, _Tp, _Compare, _Alloc>& __y)
{ return __y < __x; }
/// Based on operator<
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool
operator<=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
const map<_Key, _Tp, _Compare, _Alloc>& __y)
const map<_Key, _Tp, _Compare, _Alloc>& __y)
{ return !(__y < __x); }
/// Based on operator<
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool
operator>=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
const map<_Key, _Tp, _Compare, _Alloc>& __y)
const map<_Key, _Tp, _Compare, _Alloc>& __y)
{ return !(__x < __y); }
/// See std::map::swap().
......
......@@ -77,7 +77,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* @tparam _Key Type of key objects.
* @tparam _Tp Type of mapped objects.
* @tparam _Compare Comparison function object type, defaults to less<_Key>.
* @tparam _Alloc Allocator type, defaults to
* @tparam _Alloc Allocator type, defaults to
* allocator<pair<const _Key, _Tp>.
*
* Meets the requirements of a <a href="tables.html#65">container</a>, a
......@@ -98,19 +98,23 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
class multimap
{
public:
typedef _Key key_type;
typedef _Tp mapped_type;
typedef std::pair<const _Key, _Tp> value_type;
typedef _Compare key_compare;
typedef _Alloc allocator_type;
typedef _Key key_type;
typedef _Tp mapped_type;
typedef std::pair<const _Key, _Tp> value_type;
typedef _Compare key_compare;
typedef _Alloc allocator_type;
private:
#ifdef _GLIBCXX_CONCEPT_CHECKS
// concept requirements
typedef typename _Alloc::value_type _Alloc_value_type;
typedef typename _Alloc::value_type _Alloc_value_type;
# if __cplusplus < 201103L
__glibcxx_class_requires(_Tp, _SGIAssignableConcept)
# endif
__glibcxx_class_requires4(_Compare, bool, _Key, _Key,
_BinaryFunctionConcept)
__glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept)
#endif
public:
class value_compare
......@@ -143,15 +147,15 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
public:
// many of these are specified differently in ISO, but the following are
// "functionally equivalent"
typedef typename _Alloc_traits::pointer pointer;
typedef typename _Alloc_traits::const_pointer const_pointer;
typedef typename _Alloc_traits::reference reference;
typedef typename _Alloc_traits::const_reference const_reference;
typedef typename _Rep_type::iterator iterator;
typedef typename _Rep_type::const_iterator const_iterator;
typedef typename _Rep_type::size_type size_type;
typedef typename _Rep_type::difference_type difference_type;
typedef typename _Rep_type::reverse_iterator reverse_iterator;
typedef typename _Alloc_traits::pointer pointer;
typedef typename _Alloc_traits::const_pointer const_pointer;
typedef typename _Alloc_traits::reference reference;
typedef typename _Alloc_traits::const_reference const_reference;
typedef typename _Rep_type::iterator iterator;
typedef typename _Rep_type::const_iterator const_iterator;
typedef typename _Rep_type::size_type size_type;
typedef typename _Rep_type::difference_type difference_type;
typedef typename _Rep_type::reverse_iterator reverse_iterator;
typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
#if __cplusplus > 201402L
......@@ -238,10 +242,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
/// Allocator-extended range constructor.
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last,
multimap(_InputIterator __first, _InputIterator __last,
const allocator_type& __a)
: _M_t(_Compare(), _Pair_alloc_type(__a))
{ _M_t._M_insert_equal(__first, __last); }
{ _M_t._M_insert_equal(__first, __last); }
#endif
/**
......@@ -254,9 +258,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* and NlogN otherwise (where N is distance(__first,__last)).
*/
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last)
multimap(_InputIterator __first, _InputIterator __last)
: _M_t()
{ _M_t._M_insert_equal(__first, __last); }
{ _M_t._M_insert_equal(__first, __last); }
/**
* @brief Builds a %multimap from a range.
......@@ -270,11 +274,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* and NlogN otherwise (where N is distance(__first,__last)).
*/
template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last,
multimap(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const allocator_type& __a = allocator_type())
: _M_t(__comp, _Pair_alloc_type(__a))
{ _M_t._M_insert_equal(__first, __last); }
{ _M_t._M_insert_equal(__first, __last); }
#if __cplusplus >= 201103L
/**
......@@ -326,7 +330,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
/// Get a copy of the memory allocation object.
allocator_type
get_allocator() const _GLIBCXX_NOEXCEPT
get_allocator() const _GLIBCXX_NOEXCEPT
{ return allocator_type(_M_t.get_allocator()); }
// iterators
......@@ -530,9 +534,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Pair, typename = typename
std::enable_if<std::is_constructible<value_type,
_Pair&&>::value>::type>
iterator
insert(_Pair&& __x)
{ return _M_t._M_insert_equal(std::forward<_Pair>(__x)); }
iterator
insert(_Pair&& __x)
{ return _M_t._M_insert_equal(std::forward<_Pair>(__x)); }
#endif
/**
......@@ -567,9 +571,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Pair, typename = typename
std::enable_if<std::is_constructible<value_type,
_Pair&&>::value>::type>
iterator
insert(const_iterator __position, _Pair&& __x)
{ return _M_t._M_insert_equal_(__position,
iterator
insert(const_iterator __position, _Pair&& __x)
{ return _M_t._M_insert_equal_(__position,
std::forward<_Pair>(__x)); }
#endif
......@@ -583,9 +587,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* Complexity similar to that of the range constructor.
*/
template<typename _InputIterator>
void
insert(_InputIterator __first, _InputIterator __last)
{ _M_t._M_insert_equal(__first, __last); }
void
insert(_InputIterator __first, _InputIterator __last)
{ _M_t._M_insert_equal(__first, __last); }
#if __cplusplus >= 201103L
/**
......@@ -661,7 +665,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* @brief Erases an element from a %multimap.
* @param __position An iterator pointing to the element to be erased.
* @return An iterator pointing to the element immediately following
* @a position prior to the element being erased. If no such
* @a position prior to the element being erased. If no such
* element exists, end() is returned.
*
* This function erases an element, pointed to by the given iterator,
......@@ -1016,13 +1020,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
//@}
template<typename _K1, typename _T1, typename _C1, typename _A1>
friend bool
operator==(const multimap<_K1, _T1, _C1, _A1>&,
friend bool
operator==(const multimap<_K1, _T1, _C1, _A1>&,
const multimap<_K1, _T1, _C1, _A1>&);
template<typename _K1, typename _T1, typename _C1, typename _A1>
friend bool
operator<(const multimap<_K1, _T1, _C1, _A1>&,
friend bool
operator<(const multimap<_K1, _T1, _C1, _A1>&,
const multimap<_K1, _T1, _C1, _A1>&);
};
......@@ -1039,7 +1043,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool
operator==(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
{ return __x._M_t == __y._M_t; }
/**
......@@ -1056,42 +1060,42 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool
operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
{ return __x._M_t < __y._M_t; }
/// Based on operator==
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool
operator!=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
{ return !(__x == __y); }
/// Based on operator<
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool
operator>(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
{ return __y < __x; }
/// Based on operator<
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool
operator<=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
{ return !(__y < __x); }
/// Based on operator<
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool
operator>=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
{ return !(__x < __y); }
/// See std::multimap::swap().
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline void
swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x,
multimap<_Key, _Tp, _Compare, _Alloc>& __y)
multimap<_Key, _Tp, _Compare, _Alloc>& __y)
_GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
{ __x.swap(__y); }
......
......@@ -94,12 +94,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
typename _Alloc = std::allocator<_Key> >
class multiset
{
#ifdef _GLIBCXX_CONCEPT_CHECKS
// concept requirements
typedef typename _Alloc::value_type _Alloc_value_type;
typedef typename _Alloc::value_type _Alloc_value_type;
# if __cplusplus < 201103L
__glibcxx_class_requires(_Key, _SGIAssignableConcept)
# endif
__glibcxx_class_requires4(_Compare, bool, _Key, _Key,
_BinaryFunctionConcept)
__glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept)
__glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept)
#endif
public:
// typedefs:
......@@ -122,19 +126,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
typedef __gnu_cxx::__alloc_traits<_Key_alloc_type> _Alloc_traits;
public:
typedef typename _Alloc_traits::pointer pointer;
typedef typename _Alloc_traits::const_pointer const_pointer;
typedef typename _Alloc_traits::reference reference;
typedef typename _Alloc_traits::const_reference const_reference;
typedef typename _Alloc_traits::pointer pointer;
typedef typename _Alloc_traits::const_pointer const_pointer;
typedef typename _Alloc_traits::reference reference;
typedef typename _Alloc_traits::const_reference const_reference;
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 103. set::iterator is required to be modifiable,
// but this allows modification of keys.
typedef typename _Rep_type::const_iterator iterator;
typedef typename _Rep_type::const_iterator const_iterator;
typedef typename _Rep_type::const_reverse_iterator reverse_iterator;
typedef typename _Rep_type::const_iterator iterator;
typedef typename _Rep_type::const_iterator const_iterator;
typedef typename _Rep_type::const_reverse_iterator reverse_iterator;
typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
typedef typename _Rep_type::size_type size_type;
typedef typename _Rep_type::difference_type difference_type;
typedef typename _Rep_type::size_type size_type;
typedef typename _Rep_type::difference_type difference_type;
#if __cplusplus > 201402L
using node_type = typename _Rep_type::node_type;
......@@ -170,9 +174,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* and NlogN otherwise (where N is distance(__first,__last)).
*/
template<typename _InputIterator>
multiset(_InputIterator __first, _InputIterator __last)
multiset(_InputIterator __first, _InputIterator __last)
: _M_t()
{ _M_t._M_insert_equal(__first, __last); }
{ _M_t._M_insert_equal(__first, __last); }
/**
* @brief Builds a %multiset from a range.
......@@ -186,11 +190,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* and NlogN otherwise (where N is distance(__first,__last)).
*/
template<typename _InputIterator>
multiset(_InputIterator __first, _InputIterator __last,
multiset(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const allocator_type& __a = allocator_type())
: _M_t(__comp, _Key_alloc_type(__a))
{ _M_t._M_insert_equal(__first, __last); }
{ _M_t._M_insert_equal(__first, __last); }
/**
* @brief %Multiset copy constructor.
......@@ -250,10 +254,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
/// Allocator-extended range constructor.
template<typename _InputIterator>
multiset(_InputIterator __first, _InputIterator __last,
multiset(_InputIterator __first, _InputIterator __last,
const allocator_type& __a)
: _M_t(_Compare(), _Key_alloc_type(__a))
{ _M_t._M_insert_equal(__first, __last); }
{ _M_t._M_insert_equal(__first, __last); }
/**
* The dtor only erases the elements, and note that if the elements
......@@ -533,9 +537,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* Complexity similar to that of the range constructor.
*/
template<typename _InputIterator>
void
insert(_InputIterator __first, _InputIterator __last)
{ _M_t._M_insert_equal(__first, __last); }
void
insert(_InputIterator __first, _InputIterator __last)
{ _M_t._M_insert_equal(__first, __last); }
#if __cplusplus >= 201103L
/**
......@@ -611,7 +615,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* @brief Erases an element from a %multiset.
* @param __position An iterator pointing to the element to be erased.
* @return An iterator pointing to the element immediately following
* @a position prior to the element being erased. If no such
* @a position prior to the element being erased. If no such
* element exists, end() is returned.
*
* This function erases an element, pointed to by the given iterator,
......@@ -866,13 +870,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
//@}
template<typename _K1, typename _C1, typename _A1>
friend bool
operator==(const multiset<_K1, _C1, _A1>&,
friend bool
operator==(const multiset<_K1, _C1, _A1>&,
const multiset<_K1, _C1, _A1>&);
template<typename _K1, typename _C1, typename _A1>
friend bool
operator< (const multiset<_K1, _C1, _A1>&,
friend bool
operator< (const multiset<_K1, _C1, _A1>&,
const multiset<_K1, _C1, _A1>&);
};
......
......@@ -95,20 +95,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp, typename _Sequence = deque<_Tp> >
class queue
{
#ifdef _GLIBCXX_CONCEPT_CHECKS
// concept requirements
typedef typename _Sequence::value_type _Sequence_value_type;
# if __cplusplus < 201103L
__glibcxx_class_requires(_Tp, _SGIAssignableConcept)
# endif
__glibcxx_class_requires(_Sequence, _FrontInsertionSequenceConcept)
__glibcxx_class_requires(_Sequence, _BackInsertionSequenceConcept)
__glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
#endif
template<typename _Tp1, typename _Seq1>
friend bool
operator==(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&);
friend bool
operator==(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&);
template<typename _Tp1, typename _Seq1>
friend bool
operator<(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&);
friend bool
operator<(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&);
#if __cplusplus >= 201103L
template<typename _Alloc>
......@@ -117,11 +121,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif
public:
typedef typename _Sequence::value_type value_type;
typedef typename _Sequence::reference reference;
typedef typename _Sequence::const_reference const_reference;
typedef typename _Sequence::size_type size_type;
typedef _Sequence container_type;
typedef typename _Sequence::value_type value_type;
typedef typename _Sequence::reference reference;
typedef typename _Sequence::const_reference const_reference;
typedef typename _Sequence::size_type size_type;
typedef _Sequence container_type;
protected:
/* Maintainers wondering why this isn't uglified as per style
......@@ -259,8 +263,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return c.emplace_back(std::forward<_Args>(__args)...); }
#else
template<typename... _Args>
void
emplace(_Args&&... __args)
void
emplace(_Args&&... __args)
{ c.emplace_back(std::forward<_Args>(__args)...); }
#endif
#endif
......@@ -381,12 +385,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*
* @tparam _Tp Type of element.
* @tparam _Sequence Type of underlying sequence, defaults to vector<_Tp>.
* @tparam _Compare Comparison function object type, defaults to
* @tparam _Compare Comparison function object type, defaults to
* less<_Sequence::value_type>.
*
* This is not a true container, but an @e adaptor. It holds
* another container, and provides a wrapper interface to that
* container. The wrapper is what enforces priority-based sorting
* container. The wrapper is what enforces priority-based sorting
* and %queue behavior. Very few of the standard container/sequence
* interface requirements are met (e.g., iterators).
*
......@@ -418,14 +422,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typename _Compare = less<typename _Sequence::value_type> >
class priority_queue
{
#ifdef _GLIBCXX_CONCEPT_CHECKS
// concept requirements
typedef typename _Sequence::value_type _Sequence_value_type;
# if __cplusplus < 201103L
__glibcxx_class_requires(_Tp, _SGIAssignableConcept)
# endif
__glibcxx_class_requires(_Sequence, _SequenceConcept)
__glibcxx_class_requires(_Sequence, _RandomAccessContainerConcept)
__glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
__glibcxx_class_requires4(_Compare, bool, _Tp, _Tp,
_BinaryFunctionConcept)
#endif
#if __cplusplus >= 201103L
template<typename _Alloc>
......@@ -434,11 +442,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif
public:
typedef typename _Sequence::value_type value_type;
typedef typename _Sequence::reference reference;
typedef typename _Sequence::const_reference const_reference;
typedef typename _Sequence::size_type size_type;
typedef _Sequence container_type;
typedef typename _Sequence::value_type value_type;
typedef typename _Sequence::reference reference;
typedef typename _Sequence::const_reference const_reference;
typedef typename _Sequence::size_type size_type;
typedef _Sequence container_type;
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 2684. priority_queue lacking comparator typedef
typedef _Compare value_compare;
......@@ -461,7 +469,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#else
template<typename _Seq = _Sequence, typename _Requires = typename
enable_if<__and_<is_default_constructible<_Compare>,
is_default_constructible<_Seq>>::value>::type>
is_default_constructible<_Seq>>::value>::type>
priority_queue()
: c(), comp() { }
......@@ -519,33 +527,33 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
#if __cplusplus < 201103L
template<typename _InputIterator>
priority_queue(_InputIterator __first, _InputIterator __last,
priority_queue(_InputIterator __first, _InputIterator __last,
const _Compare& __x = _Compare(),
const _Sequence& __s = _Sequence())
: c(__s), comp(__x)
{
{
__glibcxx_requires_valid_range(__first, __last);
c.insert(c.end(), __first, __last);
std::make_heap(c.begin(), c.end(), comp);
}
#else
template<typename _InputIterator>
priority_queue(_InputIterator __first, _InputIterator __last,
priority_queue(_InputIterator __first, _InputIterator __last,
const _Compare& __x,
const _Sequence& __s)
: c(__s), comp(__x)
{
{
__glibcxx_requires_valid_range(__first, __last);
c.insert(c.end(), __first, __last);
std::make_heap(c.begin(), c.end(), comp);
}
template<typename _InputIterator>
priority_queue(_InputIterator __first, _InputIterator __last,
priority_queue(_InputIterator __first, _InputIterator __last,
const _Compare& __x = _Compare(),
_Sequence&& __s = _Sequence())
: c(std::move(__s)), comp(__x)
{
{
__glibcxx_requires_valid_range(__first, __last);
c.insert(c.end(), __first, __last);
std::make_heap(c.begin(), c.end(), comp);
......@@ -599,8 +607,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename... _Args>
void
emplace(_Args&&... __args)
void
emplace(_Args&&... __args)
{
c.emplace_back(std::forward<_Args>(__args)...);
std::push_heap(c.begin(), c.end(), comp);
......@@ -631,12 +639,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
swap(priority_queue& __pq)
noexcept(__and_<
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
__is_nothrow_swappable<_Sequence>,
__is_nothrow_swappable<_Sequence>,
#else
__is_nothrow_swappable<_Tp>,
__is_nothrow_swappable<_Tp>,
#endif
__is_nothrow_swappable<_Compare>
>::value)
__is_nothrow_swappable<_Compare>
>::value)
{
using std::swap;
swap(c, __pq.c);
......@@ -653,7 +661,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
// Constrained free swap overload, see p0185r1
typename enable_if<__and_<__is_swappable<_Sequence>,
__is_swappable<_Compare>>::value>::type
__is_swappable<_Compare>>::value>::type
#else
void
#endif
......
......@@ -92,12 +92,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
typename _Alloc = std::allocator<_Key> >
class set
{
#ifdef _GLIBCXX_CONCEPT_CHECKS
// concept requirements
typedef typename _Alloc::value_type _Alloc_value_type;
typedef typename _Alloc::value_type _Alloc_value_type;
# if __cplusplus < 201103L
__glibcxx_class_requires(_Key, _SGIAssignableConcept)
# endif
__glibcxx_class_requires4(_Compare, bool, _Key, _Key,
_BinaryFunctionConcept)
__glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept)
#endif
public:
// typedefs:
......@@ -123,19 +127,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
public:
//@{
/// Iterator-related typedefs.
typedef typename _Alloc_traits::pointer pointer;
typedef typename _Alloc_traits::const_pointer const_pointer;
typedef typename _Alloc_traits::reference reference;
typedef typename _Alloc_traits::const_reference const_reference;
typedef typename _Alloc_traits::pointer pointer;
typedef typename _Alloc_traits::const_pointer const_pointer;
typedef typename _Alloc_traits::reference reference;
typedef typename _Alloc_traits::const_reference const_reference;
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 103. set::iterator is required to be modifiable,
// but this allows modification of keys.
typedef typename _Rep_type::const_iterator iterator;
typedef typename _Rep_type::const_iterator const_iterator;
typedef typename _Rep_type::const_reverse_iterator reverse_iterator;
typedef typename _Rep_type::const_iterator iterator;
typedef typename _Rep_type::const_iterator const_iterator;
typedef typename _Rep_type::const_reverse_iterator reverse_iterator;
typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
typedef typename _Rep_type::size_type size_type;
typedef typename _Rep_type::difference_type difference_type;
typedef typename _Rep_type::size_type size_type;
typedef typename _Rep_type::difference_type difference_type;
//@}
#if __cplusplus > 201402L
......@@ -195,7 +199,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
const _Compare& __comp,
const allocator_type& __a = allocator_type())
: _M_t(__comp, _Key_alloc_type(__a))
{ _M_t._M_insert_unique(__first, __last); }
{ _M_t._M_insert_unique(__first, __last); }
/**
* @brief %Set copy constructor.
......@@ -254,10 +258,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
/// Allocator-extended range constructor.
template<typename _InputIterator>
set(_InputIterator __first, _InputIterator __last,
set(_InputIterator __first, _InputIterator __last,
const allocator_type& __a)
: _M_t(_Compare(), _Key_alloc_type(__a))
{ _M_t._M_insert_unique(__first, __last); }
{ _M_t._M_insert_unique(__first, __last); }
/**
* The dtor only erases the elements, and note that if the elements
......
......@@ -98,21 +98,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp, typename _Sequence = deque<_Tp> >
class stack
{
#ifdef _GLIBCXX_CONCEPT_CHECKS
// concept requirements
typedef typename _Sequence::value_type _Sequence_value_type;
#if __cplusplus < 201103L
# if __cplusplus < 201103L
__glibcxx_class_requires(_Tp, _SGIAssignableConcept)
__glibcxx_class_requires(_Sequence, _BackInsertionSequenceConcept)
#endif
# endif
__glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
#endif
template<typename _Tp1, typename _Seq1>
friend bool
operator==(const stack<_Tp1, _Seq1>&, const stack<_Tp1, _Seq1>&);
friend bool
operator==(const stack<_Tp1, _Seq1>&, const stack<_Tp1, _Seq1>&);
template<typename _Tp1, typename _Seq1>
friend bool
operator<(const stack<_Tp1, _Seq1>&, const stack<_Tp1, _Seq1>&);
friend bool
operator<(const stack<_Tp1, _Seq1>&, const stack<_Tp1, _Seq1>&);
#if __cplusplus >= 201103L
template<typename _Alloc>
......@@ -121,11 +123,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif
public:
typedef typename _Sequence::value_type value_type;
typedef typename _Sequence::reference reference;
typedef typename _Sequence::const_reference const_reference;
typedef typename _Sequence::size_type size_type;
typedef _Sequence container_type;
typedef typename _Sequence::value_type value_type;
typedef typename _Sequence::reference reference;
typedef typename _Sequence::const_reference const_reference;
typedef typename _Sequence::size_type size_type;
typedef _Sequence container_type;
protected:
// See queue::c for notes on this name.
......@@ -235,8 +237,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return c.emplace_back(std::forward<_Args>(__args)...); }
#else
template<typename... _Args>
void
emplace(_Args&&... __args)
void
emplace(_Args&&... __args)
{ c.emplace_back(std::forward<_Args>(__args)...); }
#endif
#endif
......
......@@ -78,7 +78,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>::pointer
pointer;
struct _Vector_impl
struct _Vector_impl
: public _Tp_alloc_type
{
pointer _M_start;
......@@ -107,7 +107,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
std::swap(_M_end_of_storage, __x._M_end_of_storage);
}
};
public:
typedef _Alloc allocator_type;
......@@ -215,13 +215,15 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
class vector : protected _Vector_base<_Tp, _Alloc>
{
#ifdef _GLIBCXX_CONCEPT_CHECKS
// Concept requirements.
typedef typename _Alloc::value_type _Alloc_value_type;
#if __cplusplus < 201103L
# if __cplusplus < 201103L
__glibcxx_class_requires(_Tp, _SGIAssignableConcept)
#endif
# endif
__glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept)
#endif
typedef _Vector_base<_Tp, _Alloc> _Base;
typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Alloc_traits;
......@@ -842,7 +844,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
at(size_type __n)
{
_M_range_check(__n);
return (*this)[__n];
return (*this)[__n];
}
/**
......@@ -895,7 +897,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
__glibcxx_requires_nonempty();
return *(end() - 1);
}
/**
* Returns a read-only (constant) reference to the data at the
* last element of the %vector.
......@@ -953,7 +955,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename... _Args>
#if __cplusplus > 201402L
reference
reference
#else
void
#endif
......@@ -1045,7 +1047,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* @param __position An iterator into the %vector.
* @param __l An initializer_list.
*
* This function will insert copies of the data in the
* This function will insert copies of the data in the
* initializer_list @a l into the %vector before the location
* specified by @a position.
*
......
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