2012-03-27 23:13:14 +00:00
|
|
|
// Profiling list implementation -*- C++ -*-
|
|
|
|
|
2017-10-07 00:16:47 +00:00
|
|
|
// Copyright (C) 2009-2017 Free Software Foundation, Inc.
|
2012-03-27 23:13:14 +00:00
|
|
|
//
|
|
|
|
// This file is part of the GNU ISO C++ Library. This library is free
|
|
|
|
// software; you can redistribute it and/or modify it under the
|
|
|
|
// terms of the GNU General Public License as published by the
|
|
|
|
// Free Software Foundation; either version 3, or (at your option)
|
|
|
|
// any later version.
|
|
|
|
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
// permissions described in the GCC Runtime Library Exception, version
|
|
|
|
// 3.1, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License and
|
|
|
|
// a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
// <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
/** @file profile/list
|
|
|
|
* This file is a GNU profile extension to the Standard C++ Library.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _GLIBCXX_PROFILE_LIST
|
|
|
|
#define _GLIBCXX_PROFILE_LIST 1
|
|
|
|
|
|
|
|
#include <list>
|
2015-08-28 15:33:40 +00:00
|
|
|
#include <profile/base.h>
|
|
|
|
#include <profile/iterator_tracker.h>
|
2012-03-27 23:13:14 +00:00
|
|
|
|
|
|
|
namespace std _GLIBCXX_VISIBILITY(default)
|
|
|
|
{
|
|
|
|
namespace __profile
|
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
template<typename _List>
|
|
|
|
class _List_profile
|
|
|
|
{
|
|
|
|
_List&
|
|
|
|
_M_conjure()
|
|
|
|
{ return *static_cast<_List*>(this); }
|
|
|
|
|
|
|
|
public:
|
|
|
|
__gnu_profile::__list2slist_info* _M_list2slist_info;
|
|
|
|
__gnu_profile::__list2vector_info* _M_list2vector_info;
|
|
|
|
|
|
|
|
_List_profile() _GLIBCXX_NOEXCEPT
|
|
|
|
{ _M_profile_construct(); }
|
|
|
|
|
|
|
|
void
|
|
|
|
_M_profile_construct() _GLIBCXX_NOEXCEPT
|
|
|
|
{
|
|
|
|
_M_list2slist_info = __profcxx_list2slist_construct();
|
|
|
|
_M_list2vector_info = __profcxx_list2vector_construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_M_profile_destruct() _GLIBCXX_NOEXCEPT
|
|
|
|
{
|
|
|
|
__profcxx_list2vector_destruct(_M_list2vector_info);
|
|
|
|
_M_list2vector_info = 0;
|
|
|
|
__profcxx_list2slist_destruct(_M_list2slist_info);
|
|
|
|
_M_list2slist_info = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_M_swap(_List_profile& __other)
|
|
|
|
{
|
|
|
|
std::swap(_M_list2slist_info, __other._M_list2slist_info);
|
|
|
|
std::swap(_M_list2vector_info, __other._M_list2vector_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if __cplusplus >= 201103L
|
|
|
|
_List_profile(const _List_profile&) noexcept
|
|
|
|
: _List_profile() { }
|
|
|
|
_List_profile(_List_profile&& __other) noexcept
|
|
|
|
: _List_profile()
|
|
|
|
{ _M_swap(__other); }
|
|
|
|
|
|
|
|
_List_profile&
|
|
|
|
operator=(const _List_profile&) noexcept
|
|
|
|
{
|
|
|
|
_M_profile_destruct();
|
|
|
|
_M_profile_construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
_List_profile&
|
|
|
|
operator=(_List_profile&& __other) noexcept
|
|
|
|
{
|
|
|
|
_M_swap(__other);
|
|
|
|
__other._M_profile_destruct();
|
|
|
|
__other._M_profile_construct();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
~_List_profile()
|
|
|
|
{ _M_profile_destruct(); }
|
|
|
|
};
|
|
|
|
|
2012-03-27 23:13:14 +00:00
|
|
|
/** @brief List wrapper with performance instrumentation. */
|
2015-08-28 15:33:40 +00:00
|
|
|
template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
2012-03-27 23:13:14 +00:00
|
|
|
class list
|
2015-08-28 15:33:40 +00:00
|
|
|
: public _GLIBCXX_STD_C::list<_Tp, _Allocator>,
|
|
|
|
public _List_profile<list<_Tp, _Allocator> >
|
2012-03-27 23:13:14 +00:00
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
typedef _GLIBCXX_STD_C::list<_Tp, _Allocator> _Base;
|
2012-03-27 23:13:14 +00:00
|
|
|
|
|
|
|
public:
|
2015-08-28 15:33:40 +00:00
|
|
|
typedef typename _Base::reference reference;
|
|
|
|
typedef typename _Base::const_reference const_reference;
|
2012-03-27 23:13:14 +00:00
|
|
|
|
2015-08-28 15:33:40 +00:00
|
|
|
typedef __iterator_tracker<typename _Base::iterator, list>
|
|
|
|
iterator;
|
|
|
|
typedef __iterator_tracker<typename _Base::const_iterator, list>
|
|
|
|
const_iterator;
|
2012-03-27 23:13:14 +00:00
|
|
|
|
2015-08-28 15:33:40 +00:00
|
|
|
typedef typename _Base::size_type size_type;
|
|
|
|
typedef typename _Base::difference_type difference_type;
|
2012-03-27 23:13:14 +00:00
|
|
|
|
2015-08-28 15:33:40 +00:00
|
|
|
typedef _Tp value_type;
|
|
|
|
typedef _Allocator allocator_type;
|
|
|
|
typedef typename _Base::pointer pointer;
|
|
|
|
typedef typename _Base::const_pointer const_pointer;
|
|
|
|
typedef std::reverse_iterator<iterator> reverse_iterator;
|
|
|
|
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
2012-03-27 23:13:14 +00:00
|
|
|
|
|
|
|
// 23.2.2.1 construct/copy/destroy:
|
2014-09-21 17:33:12 +00:00
|
|
|
|
2015-08-28 15:33:40 +00:00
|
|
|
#if __cplusplus < 201103L
|
|
|
|
list() { }
|
|
|
|
list(const list& __x)
|
|
|
|
: _Base(__x) { }
|
|
|
|
|
|
|
|
~list() { }
|
|
|
|
#else
|
|
|
|
list() = default;
|
|
|
|
list(const list&) = default;
|
|
|
|
list(list&&) = default;
|
|
|
|
~list() = default;
|
|
|
|
|
|
|
|
list(initializer_list<value_type> __l,
|
|
|
|
const allocator_type& __a = allocator_type())
|
|
|
|
: _Base(__l, __a) { }
|
2017-04-10 11:32:00 +00:00
|
|
|
|
|
|
|
list(const list& __x, const allocator_type& __a)
|
|
|
|
: _Base(__x, __a) { }
|
|
|
|
|
|
|
|
list(list&& __x, const allocator_type& __a)
|
|
|
|
: _Base(std::move(__x), __a) { }
|
2015-08-28 15:33:40 +00:00
|
|
|
#endif
|
2014-09-21 17:33:12 +00:00
|
|
|
|
2012-03-27 23:13:14 +00:00
|
|
|
explicit
|
2014-09-21 17:33:12 +00:00
|
|
|
list(const _Allocator& __a) _GLIBCXX_NOEXCEPT
|
2015-08-28 15:33:40 +00:00
|
|
|
: _Base(__a) { }
|
2012-03-27 23:13:14 +00:00
|
|
|
|
2014-09-21 17:33:12 +00:00
|
|
|
#if __cplusplus >= 201103L
|
2012-03-27 23:13:14 +00:00
|
|
|
explicit
|
2017-04-10 11:32:00 +00:00
|
|
|
list(size_type __n, const allocator_type& __a = allocator_type())
|
|
|
|
: _Base(__n, __a) { }
|
2012-03-27 23:13:14 +00:00
|
|
|
|
|
|
|
list(size_type __n, const _Tp& __value,
|
|
|
|
const _Allocator& __a = _Allocator())
|
2015-08-28 15:33:40 +00:00
|
|
|
: _Base(__n, __value, __a) { }
|
2012-03-27 23:13:14 +00:00
|
|
|
#else
|
|
|
|
explicit
|
|
|
|
list(size_type __n, const _Tp& __value = _Tp(),
|
|
|
|
const _Allocator& __a = _Allocator())
|
2015-08-28 15:33:40 +00:00
|
|
|
: _Base(__n, __value, __a) { }
|
2012-03-27 23:13:14 +00:00
|
|
|
#endif
|
|
|
|
|
2014-09-21 17:33:12 +00:00
|
|
|
#if __cplusplus >= 201103L
|
|
|
|
template<typename _InputIterator,
|
|
|
|
typename = std::_RequireInputIter<_InputIterator>>
|
|
|
|
#else
|
2012-03-27 23:13:14 +00:00
|
|
|
template<class _InputIterator>
|
2014-09-21 17:33:12 +00:00
|
|
|
#endif
|
2012-03-27 23:13:14 +00:00
|
|
|
list(_InputIterator __first, _InputIterator __last,
|
|
|
|
const _Allocator& __a = _Allocator())
|
2015-08-28 15:33:40 +00:00
|
|
|
: _Base(__first, __last, __a) { }
|
2012-03-27 23:13:14 +00:00
|
|
|
|
|
|
|
list(const _Base& __x)
|
2015-08-28 15:33:40 +00:00
|
|
|
: _Base(__x) { }
|
2012-03-27 23:13:14 +00:00
|
|
|
|
2015-08-28 15:33:40 +00:00
|
|
|
#if __cplusplus < 201103L
|
2012-03-27 23:13:14 +00:00
|
|
|
list&
|
|
|
|
operator=(const list& __x)
|
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
this->_M_profile_destruct();
|
|
|
|
_M_base() = __x;
|
|
|
|
this->_M_profile_construct();
|
2012-03-27 23:13:14 +00:00
|
|
|
return *this;
|
|
|
|
}
|
2015-08-28 15:33:40 +00:00
|
|
|
#else
|
|
|
|
list&
|
|
|
|
operator=(const list&) = default;
|
2012-03-27 23:13:14 +00:00
|
|
|
|
|
|
|
list&
|
2015-08-28 15:33:40 +00:00
|
|
|
operator=(list&&) = default;
|
2012-03-27 23:13:14 +00:00
|
|
|
|
|
|
|
list&
|
|
|
|
operator=(initializer_list<value_type> __l)
|
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
this->_M_profile_destruct();
|
|
|
|
_M_base() = __l;
|
|
|
|
this->_M_profile_construct();
|
2012-03-27 23:13:14 +00:00
|
|
|
return *this;
|
|
|
|
}
|
2014-09-21 17:33:12 +00:00
|
|
|
#endif
|
2012-03-27 23:13:14 +00:00
|
|
|
|
|
|
|
// iterators:
|
|
|
|
iterator
|
|
|
|
begin() _GLIBCXX_NOEXCEPT
|
|
|
|
{ return iterator(_Base::begin(), this); }
|
|
|
|
|
|
|
|
const_iterator
|
|
|
|
begin() const _GLIBCXX_NOEXCEPT
|
|
|
|
{ return const_iterator(_Base::begin(), this); }
|
|
|
|
|
|
|
|
iterator
|
|
|
|
end() _GLIBCXX_NOEXCEPT
|
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
__profcxx_list2slist_rewind(this->_M_list2slist_info);
|
|
|
|
return iterator(_Base::end(), this);
|
2012-03-27 23:13:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const_iterator
|
|
|
|
end() const _GLIBCXX_NOEXCEPT
|
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
__profcxx_list2slist_rewind(this->_M_list2slist_info);
|
|
|
|
return const_iterator(_Base::end(), this);
|
2012-03-27 23:13:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
reverse_iterator
|
|
|
|
rbegin() _GLIBCXX_NOEXCEPT
|
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
__profcxx_list2slist_rewind(this->_M_list2slist_info);
|
|
|
|
return reverse_iterator(end());
|
2012-03-27 23:13:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const_reverse_iterator
|
|
|
|
rbegin() const _GLIBCXX_NOEXCEPT
|
2015-08-28 15:33:40 +00:00
|
|
|
{
|
|
|
|
__profcxx_list2slist_rewind(this->_M_list2slist_info);
|
|
|
|
return const_reverse_iterator(end());
|
2012-03-27 23:13:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
reverse_iterator
|
|
|
|
rend() _GLIBCXX_NOEXCEPT
|
|
|
|
{ return reverse_iterator(begin()); }
|
|
|
|
|
|
|
|
const_reverse_iterator
|
|
|
|
rend() const _GLIBCXX_NOEXCEPT
|
|
|
|
{ return const_reverse_iterator(begin()); }
|
|
|
|
|
2014-09-21 17:33:12 +00:00
|
|
|
#if __cplusplus >= 201103L
|
2012-03-27 23:13:14 +00:00
|
|
|
const_iterator
|
|
|
|
cbegin() const noexcept
|
2015-08-28 15:33:40 +00:00
|
|
|
{ return const_iterator(_Base::cbegin(), this); }
|
2012-03-27 23:13:14 +00:00
|
|
|
|
|
|
|
const_iterator
|
|
|
|
cend() const noexcept
|
2015-08-28 15:33:40 +00:00
|
|
|
{ return const_iterator(_Base::cend(), this); }
|
2012-03-27 23:13:14 +00:00
|
|
|
|
|
|
|
const_reverse_iterator
|
|
|
|
crbegin() const noexcept
|
|
|
|
{ return const_reverse_iterator(end()); }
|
|
|
|
|
|
|
|
const_reverse_iterator
|
|
|
|
crend() const noexcept
|
|
|
|
{ return const_reverse_iterator(begin()); }
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// 23.2.2.2 capacity:
|
|
|
|
reference
|
2014-09-21 17:33:12 +00:00
|
|
|
back() _GLIBCXX_NOEXCEPT
|
2012-03-27 23:13:14 +00:00
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
__profcxx_list2slist_rewind(this->_M_list2slist_info);
|
2012-03-27 23:13:14 +00:00
|
|
|
return _Base::back();
|
|
|
|
}
|
|
|
|
|
|
|
|
const_reference
|
2014-09-21 17:33:12 +00:00
|
|
|
back() const _GLIBCXX_NOEXCEPT
|
2012-03-27 23:13:14 +00:00
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
__profcxx_list2slist_rewind(this->_M_list2slist_info);
|
2012-03-27 23:13:14 +00:00
|
|
|
return _Base::back();
|
|
|
|
}
|
|
|
|
|
|
|
|
// 23.2.2.3 modifiers:
|
|
|
|
void
|
|
|
|
push_front(const value_type& __x)
|
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
__profcxx_list2vector_invalid_operator(this->_M_list2vector_info);
|
|
|
|
__profcxx_list2slist_operation(this->_M_list2slist_info);
|
|
|
|
_Base::push_front(__x);
|
2012-03-27 23:13:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-09-21 17:33:12 +00:00
|
|
|
pop_front() _GLIBCXX_NOEXCEPT
|
2012-03-27 23:13:14 +00:00
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
__profcxx_list2slist_operation(this->_M_list2slist_info);
|
2012-03-27 23:13:14 +00:00
|
|
|
_Base::pop_front();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-09-21 17:33:12 +00:00
|
|
|
pop_back() _GLIBCXX_NOEXCEPT
|
2012-03-27 23:13:14 +00:00
|
|
|
{
|
|
|
|
_Base::pop_back();
|
2015-08-28 15:33:40 +00:00
|
|
|
__profcxx_list2slist_rewind(this->_M_list2slist_info);
|
2012-03-27 23:13:14 +00:00
|
|
|
}
|
|
|
|
|
2014-09-21 17:33:12 +00:00
|
|
|
#if __cplusplus >= 201103L
|
2012-03-27 23:13:14 +00:00
|
|
|
template<typename... _Args>
|
2015-08-28 15:33:40 +00:00
|
|
|
iterator
|
|
|
|
emplace(const_iterator __position, _Args&&... __args)
|
2012-03-27 23:13:14 +00:00
|
|
|
{
|
|
|
|
return iterator(_Base::emplace(__position.base(),
|
2015-08-28 15:33:40 +00:00
|
|
|
std::forward<_Args>(__args)...),
|
2014-09-21 17:33:12 +00:00
|
|
|
this);
|
2012-03-27 23:13:14 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
iterator
|
2014-09-21 17:33:12 +00:00
|
|
|
#if __cplusplus >= 201103L
|
2015-08-28 15:33:40 +00:00
|
|
|
insert(const_iterator __pos, const _Tp& __x)
|
2014-09-21 17:33:12 +00:00
|
|
|
#else
|
2015-08-28 15:33:40 +00:00
|
|
|
insert(iterator __pos, const _Tp& __x)
|
2014-09-21 17:33:12 +00:00
|
|
|
#endif
|
2012-03-27 23:13:14 +00:00
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
_M_profile_insert(__pos, this->size());
|
|
|
|
return iterator(_Base::insert(__pos.base(), __x), this);
|
2012-03-27 23:13:14 +00:00
|
|
|
}
|
|
|
|
|
2014-09-21 17:33:12 +00:00
|
|
|
#if __cplusplus >= 201103L
|
2012-03-27 23:13:14 +00:00
|
|
|
iterator
|
2015-08-28 15:33:40 +00:00
|
|
|
insert(const_iterator __pos, _Tp&& __x)
|
2014-09-21 17:33:12 +00:00
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
_M_profile_insert(__pos, this->size());
|
|
|
|
return iterator(_Base::emplace(__pos.base(), std::move(__x)),
|
|
|
|
this);
|
2012-03-27 23:13:14 +00:00
|
|
|
}
|
|
|
|
|
2014-09-21 17:33:12 +00:00
|
|
|
iterator
|
2015-08-28 15:33:40 +00:00
|
|
|
insert(const_iterator __pos, initializer_list<value_type> __l)
|
2012-03-27 23:13:14 +00:00
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
_M_profile_insert(__pos, this->size());
|
|
|
|
return iterator(_Base::insert(__pos.base(), __l), this);
|
2012-03-27 23:13:14 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-09-21 17:33:12 +00:00
|
|
|
#if __cplusplus >= 201103L
|
|
|
|
iterator
|
2015-08-28 15:33:40 +00:00
|
|
|
insert(const_iterator __pos, size_type __n, const _Tp& __x)
|
2014-09-21 17:33:12 +00:00
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
_M_profile_insert(__pos, this->size());
|
|
|
|
return iterator(_Base::insert(__pos.base(), __n, __x), this);
|
2014-09-21 17:33:12 +00:00
|
|
|
}
|
|
|
|
#else
|
2012-03-27 23:13:14 +00:00
|
|
|
void
|
2015-08-28 15:33:40 +00:00
|
|
|
insert(iterator __pos, size_type __n, const _Tp& __x)
|
2012-03-27 23:13:14 +00:00
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
_M_profile_insert(__pos, this->size());
|
|
|
|
_Base::insert(__pos.base(), __n, __x);
|
2012-03-27 23:13:14 +00:00
|
|
|
}
|
2014-09-21 17:33:12 +00:00
|
|
|
#endif
|
2012-03-27 23:13:14 +00:00
|
|
|
|
2014-09-21 17:33:12 +00:00
|
|
|
#if __cplusplus >= 201103L
|
|
|
|
template<typename _InputIterator,
|
|
|
|
typename = std::_RequireInputIter<_InputIterator>>
|
|
|
|
iterator
|
2015-08-28 15:33:40 +00:00
|
|
|
insert(const_iterator __pos, _InputIterator __first,
|
2014-09-21 17:33:12 +00:00
|
|
|
_InputIterator __last)
|
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
_M_profile_insert(__pos, this->size());
|
|
|
|
return iterator(_Base::insert(__pos.base(), __first, __last),
|
2014-09-21 17:33:12 +00:00
|
|
|
this);
|
|
|
|
}
|
|
|
|
#else
|
2012-03-27 23:13:14 +00:00
|
|
|
template<class _InputIterator>
|
2015-08-28 15:33:40 +00:00
|
|
|
void
|
|
|
|
insert(iterator __pos, _InputIterator __first,
|
2012-03-27 23:13:14 +00:00
|
|
|
_InputIterator __last)
|
2014-09-21 17:33:12 +00:00
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
_M_profile_insert(__pos, this->size());
|
|
|
|
_Base::insert(__pos.base(), __first, __last);
|
2014-09-21 17:33:12 +00:00
|
|
|
}
|
|
|
|
#endif
|
2012-03-27 23:13:14 +00:00
|
|
|
|
|
|
|
iterator
|
2014-09-21 17:33:12 +00:00
|
|
|
#if __cplusplus >= 201103L
|
2015-08-28 15:33:40 +00:00
|
|
|
erase(const_iterator __pos) noexcept
|
2014-09-21 17:33:12 +00:00
|
|
|
#else
|
2015-08-28 15:33:40 +00:00
|
|
|
erase(iterator __pos)
|
2014-09-21 17:33:12 +00:00
|
|
|
#endif
|
2015-08-28 15:33:40 +00:00
|
|
|
{ return iterator(_Base::erase(__pos.base()), this); }
|
2012-03-27 23:13:14 +00:00
|
|
|
|
|
|
|
iterator
|
2014-09-21 17:33:12 +00:00
|
|
|
#if __cplusplus >= 201103L
|
2015-08-28 15:33:40 +00:00
|
|
|
erase(const_iterator __pos, const_iterator __last) noexcept
|
2014-09-21 17:33:12 +00:00
|
|
|
#else
|
2015-08-28 15:33:40 +00:00
|
|
|
erase(iterator __pos, iterator __last)
|
2014-09-21 17:33:12 +00:00
|
|
|
#endif
|
2012-03-27 23:13:14 +00:00
|
|
|
{
|
|
|
|
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
|
|
// 151. can't currently clear() empty container
|
2015-08-28 15:33:40 +00:00
|
|
|
return iterator(_Base::erase(__pos.base(), __last.base()), this);
|
2012-03-27 23:13:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
swap(list& __x)
|
2017-04-10 11:32:00 +00:00
|
|
|
_GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
|
2015-08-28 15:33:40 +00:00
|
|
|
{
|
|
|
|
_Base::swap(__x);
|
|
|
|
this->_M_swap(__x);
|
|
|
|
}
|
2012-03-27 23:13:14 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
clear() _GLIBCXX_NOEXCEPT
|
2015-08-28 15:33:40 +00:00
|
|
|
{
|
|
|
|
this->_M_profile_destruct();
|
|
|
|
_Base::clear();
|
|
|
|
this->_M_profile_construct();
|
|
|
|
}
|
2012-03-27 23:13:14 +00:00
|
|
|
|
|
|
|
// 23.2.2.4 list operations:
|
|
|
|
void
|
2014-09-21 17:33:12 +00:00
|
|
|
#if __cplusplus >= 201103L
|
2015-08-28 15:33:40 +00:00
|
|
|
splice(const_iterator __pos, list&& __x) noexcept
|
2012-03-27 23:13:14 +00:00
|
|
|
#else
|
2015-08-28 15:33:40 +00:00
|
|
|
splice(iterator __pos, list& __x)
|
2012-03-27 23:13:14 +00:00
|
|
|
#endif
|
2015-08-28 15:33:40 +00:00
|
|
|
{ this->splice(__pos, _GLIBCXX_MOVE(__x), __x.begin(), __x.end()); }
|
2012-03-27 23:13:14 +00:00
|
|
|
|
2014-09-21 17:33:12 +00:00
|
|
|
#if __cplusplus >= 201103L
|
2012-03-27 23:13:14 +00:00
|
|
|
void
|
2015-08-28 15:33:40 +00:00
|
|
|
splice(const_iterator __pos, list& __x) noexcept
|
|
|
|
{ this->splice(__pos, std::move(__x)); }
|
2012-03-27 23:13:14 +00:00
|
|
|
|
|
|
|
void
|
2015-08-28 15:33:40 +00:00
|
|
|
splice(const_iterator __pos, list& __x, const_iterator __i)
|
|
|
|
{ this->splice(__pos, std::move(__x), __i); }
|
2012-03-27 23:13:14 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
void
|
2014-09-21 17:33:12 +00:00
|
|
|
#if __cplusplus >= 201103L
|
2015-08-28 15:33:40 +00:00
|
|
|
splice(const_iterator __pos, list&& __x, const_iterator __i) noexcept
|
2012-03-27 23:13:14 +00:00
|
|
|
#else
|
2015-08-28 15:33:40 +00:00
|
|
|
splice(iterator __pos, list& __x, iterator __i)
|
2012-03-27 23:13:14 +00:00
|
|
|
#endif
|
|
|
|
{
|
|
|
|
// We used to perform the splice_alloc check: not anymore, redundant
|
|
|
|
// after implementing the relevant bits of N1599.
|
|
|
|
|
|
|
|
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
2015-08-28 15:33:40 +00:00
|
|
|
_Base::splice(__pos.base(), _GLIBCXX_MOVE(__x._M_base()),
|
2012-03-27 23:13:14 +00:00
|
|
|
__i.base());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-09-21 17:33:12 +00:00
|
|
|
#if __cplusplus >= 201103L
|
2015-08-28 15:33:40 +00:00
|
|
|
splice(const_iterator __pos, list&& __x, const_iterator __first,
|
2014-09-21 17:33:12 +00:00
|
|
|
const_iterator __last) noexcept
|
2012-03-27 23:13:14 +00:00
|
|
|
#else
|
2015-08-28 15:33:40 +00:00
|
|
|
splice(iterator __pos, list& __x, iterator __first,
|
2012-03-27 23:13:14 +00:00
|
|
|
iterator __last)
|
|
|
|
#endif
|
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
_Base::splice(__pos.base(), _GLIBCXX_MOVE(__x._M_base()),
|
2012-03-27 23:13:14 +00:00
|
|
|
__first.base(), __last.base());
|
|
|
|
}
|
|
|
|
|
2014-09-21 17:33:12 +00:00
|
|
|
#if __cplusplus >= 201103L
|
2012-03-27 23:13:14 +00:00
|
|
|
void
|
2015-08-28 15:33:40 +00:00
|
|
|
splice(const_iterator __pos, list& __x,
|
2014-09-21 17:33:12 +00:00
|
|
|
const_iterator __first, const_iterator __last) noexcept
|
2015-08-28 15:33:40 +00:00
|
|
|
{ this->splice(__pos, std::move(__x), __first, __last); }
|
2012-03-27 23:13:14 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
void
|
|
|
|
remove(const _Tp& __value)
|
|
|
|
{
|
|
|
|
for (iterator __x = begin(); __x != end(); )
|
|
|
|
{
|
|
|
|
if (*__x == __value)
|
|
|
|
__x = erase(__x);
|
|
|
|
else
|
|
|
|
++__x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class _Predicate>
|
2015-08-28 15:33:40 +00:00
|
|
|
void
|
|
|
|
remove_if(_Predicate __pred)
|
|
|
|
{
|
2012-03-27 23:13:14 +00:00
|
|
|
for (iterator __x = begin(); __x != end(); )
|
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
__profcxx_list2slist_operation(this->_M_list2slist_info);
|
2012-03-27 23:13:14 +00:00
|
|
|
if (__pred(*__x))
|
|
|
|
__x = erase(__x);
|
|
|
|
else
|
|
|
|
++__x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
unique()
|
|
|
|
{
|
|
|
|
iterator __first = begin();
|
|
|
|
iterator __last = end();
|
|
|
|
if (__first == __last)
|
|
|
|
return;
|
|
|
|
iterator __next = __first;
|
|
|
|
while (++__next != __last)
|
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
__profcxx_list2slist_operation(this->_M_list2slist_info);
|
2012-03-27 23:13:14 +00:00
|
|
|
if (*__first == *__next)
|
|
|
|
erase(__next);
|
|
|
|
else
|
|
|
|
__first = __next;
|
|
|
|
__next = __first;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class _BinaryPredicate>
|
2015-08-28 15:33:40 +00:00
|
|
|
void
|
|
|
|
unique(_BinaryPredicate __binary_pred)
|
|
|
|
{
|
2012-03-27 23:13:14 +00:00
|
|
|
iterator __first = begin();
|
|
|
|
iterator __last = end();
|
|
|
|
if (__first == __last)
|
|
|
|
return;
|
|
|
|
iterator __next = __first;
|
|
|
|
while (++__next != __last)
|
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
__profcxx_list2slist_operation(this->_M_list2slist_info);
|
2012-03-27 23:13:14 +00:00
|
|
|
if (__binary_pred(*__first, *__next))
|
|
|
|
erase(__next);
|
|
|
|
else
|
|
|
|
__first = __next;
|
|
|
|
__next = __first;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-09-21 17:33:12 +00:00
|
|
|
#if __cplusplus >= 201103L
|
2012-03-27 23:13:14 +00:00
|
|
|
merge(list&& __x)
|
|
|
|
#else
|
|
|
|
merge(list& __x)
|
|
|
|
#endif
|
2015-08-28 15:33:40 +00:00
|
|
|
{ _Base::merge(_GLIBCXX_MOVE(__x._M_base())); }
|
2012-03-27 23:13:14 +00:00
|
|
|
|
2014-09-21 17:33:12 +00:00
|
|
|
#if __cplusplus >= 201103L
|
2012-03-27 23:13:14 +00:00
|
|
|
void
|
|
|
|
merge(list& __x)
|
|
|
|
{ this->merge(std::move(__x)); }
|
|
|
|
#endif
|
|
|
|
|
|
|
|
template<class _Compare>
|
2015-08-28 15:33:40 +00:00
|
|
|
void
|
2014-09-21 17:33:12 +00:00
|
|
|
#if __cplusplus >= 201103L
|
2015-08-28 15:33:40 +00:00
|
|
|
merge(list&& __x, _Compare __comp)
|
2012-03-27 23:13:14 +00:00
|
|
|
#else
|
2015-08-28 15:33:40 +00:00
|
|
|
merge(list& __x, _Compare __comp)
|
2012-03-27 23:13:14 +00:00
|
|
|
#endif
|
2015-08-28 15:33:40 +00:00
|
|
|
{ _Base::merge(_GLIBCXX_MOVE(__x._M_base()), __comp); }
|
2012-03-27 23:13:14 +00:00
|
|
|
|
2014-09-21 17:33:12 +00:00
|
|
|
#if __cplusplus >= 201103L
|
2012-03-27 23:13:14 +00:00
|
|
|
template<typename _Compare>
|
2015-08-28 15:33:40 +00:00
|
|
|
void
|
|
|
|
merge(list& __x, _Compare __comp)
|
|
|
|
{ this->merge(std::move(__x), __comp); }
|
2012-03-27 23:13:14 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
_Base&
|
2015-08-28 15:33:40 +00:00
|
|
|
_M_base() _GLIBCXX_NOEXCEPT { return *this; }
|
2012-03-27 23:13:14 +00:00
|
|
|
|
|
|
|
const _Base&
|
2015-08-28 15:33:40 +00:00
|
|
|
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
|
2012-03-27 23:13:14 +00:00
|
|
|
|
2015-08-28 15:33:40 +00:00
|
|
|
void _M_profile_iterate(int __rewind = 0) const
|
2012-03-27 23:13:14 +00:00
|
|
|
{
|
2015-08-28 15:33:40 +00:00
|
|
|
__profcxx_list2slist_operation(this->_M_list2slist_info);
|
|
|
|
__profcxx_list2vector_iterate(this->_M_list2vector_info, __rewind);
|
|
|
|
if (__rewind)
|
|
|
|
__profcxx_list2slist_rewind(this->_M_list2slist_info);
|
2012-03-27 23:13:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2014-09-21 17:33:12 +00:00
|
|
|
size_type
|
2015-08-28 15:33:40 +00:00
|
|
|
_M_profile_insert(const_iterator __pos, size_type __size)
|
|
|
|
{
|
|
|
|
size_type __shift = 0;
|
|
|
|
typename _Base::const_iterator __it = __pos.base();
|
|
|
|
for (; __it != _Base::end(); ++__it)
|
|
|
|
__shift++;
|
|
|
|
__profcxx_list2slist_rewind(this->_M_list2slist_info);
|
|
|
|
__profcxx_list2slist_operation(this->_M_list2slist_info);
|
|
|
|
__profcxx_list2vector_insert(this->_M_list2vector_info, __shift, __size);
|
2012-03-27 23:13:14 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename _Tp, typename _Alloc>
|
|
|
|
inline bool
|
|
|
|
operator==(const list<_Tp, _Alloc>& __lhs,
|
|
|
|
const list<_Tp, _Alloc>& __rhs)
|
|
|
|
{ return __lhs._M_base() == __rhs._M_base(); }
|
|
|
|
|
|
|
|
template<typename _Tp, typename _Alloc>
|
|
|
|
inline bool
|
|
|
|
operator!=(const list<_Tp, _Alloc>& __lhs,
|
|
|
|
const list<_Tp, _Alloc>& __rhs)
|
|
|
|
{ return __lhs._M_base() != __rhs._M_base(); }
|
|
|
|
|
|
|
|
template<typename _Tp, typename _Alloc>
|
|
|
|
inline bool
|
|
|
|
operator<(const list<_Tp, _Alloc>& __lhs,
|
|
|
|
const list<_Tp, _Alloc>& __rhs)
|
|
|
|
{ return __lhs._M_base() < __rhs._M_base(); }
|
|
|
|
|
|
|
|
template<typename _Tp, typename _Alloc>
|
|
|
|
inline bool
|
|
|
|
operator<=(const list<_Tp, _Alloc>& __lhs,
|
|
|
|
const list<_Tp, _Alloc>& __rhs)
|
|
|
|
{ return __lhs._M_base() <= __rhs._M_base(); }
|
|
|
|
|
|
|
|
template<typename _Tp, typename _Alloc>
|
|
|
|
inline bool
|
|
|
|
operator>=(const list<_Tp, _Alloc>& __lhs,
|
|
|
|
const list<_Tp, _Alloc>& __rhs)
|
|
|
|
{ return __lhs._M_base() >= __rhs._M_base(); }
|
|
|
|
|
|
|
|
template<typename _Tp, typename _Alloc>
|
|
|
|
inline bool
|
|
|
|
operator>(const list<_Tp, _Alloc>& __lhs,
|
|
|
|
const list<_Tp, _Alloc>& __rhs)
|
|
|
|
{ return __lhs._M_base() > __rhs._M_base(); }
|
|
|
|
|
|
|
|
template<typename _Tp, typename _Alloc>
|
|
|
|
inline void
|
|
|
|
swap(list<_Tp, _Alloc>& __lhs, list<_Tp, _Alloc>& __rhs)
|
2017-04-10 11:32:00 +00:00
|
|
|
_GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
|
2012-03-27 23:13:14 +00:00
|
|
|
{ __lhs.swap(__rhs); }
|
|
|
|
|
|
|
|
} // namespace __profile
|
|
|
|
} // namespace std
|
|
|
|
|
|
|
|
#endif
|