xref: /aosp_15_r20/external/libcxx/include/list (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1*58b9f456SAndroid Build Coastguard Worker// -*- C++ -*-
2*58b9f456SAndroid Build Coastguard Worker//===---------------------------- list ------------------------------------===//
3*58b9f456SAndroid Build Coastguard Worker//
4*58b9f456SAndroid Build Coastguard Worker//                     The LLVM Compiler Infrastructure
5*58b9f456SAndroid Build Coastguard Worker//
6*58b9f456SAndroid Build Coastguard Worker// This file is dual licensed under the MIT and the University of Illinois Open
7*58b9f456SAndroid Build Coastguard Worker// Source Licenses. See LICENSE.TXT for details.
8*58b9f456SAndroid Build Coastguard Worker//
9*58b9f456SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
10*58b9f456SAndroid Build Coastguard Worker
11*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_LIST
12*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP_LIST
13*58b9f456SAndroid Build Coastguard Worker
14*58b9f456SAndroid Build Coastguard Worker/*
15*58b9f456SAndroid Build Coastguard Worker    list synopsis
16*58b9f456SAndroid Build Coastguard Worker
17*58b9f456SAndroid Build Coastguard Workernamespace std
18*58b9f456SAndroid Build Coastguard Worker{
19*58b9f456SAndroid Build Coastguard Worker
20*58b9f456SAndroid Build Coastguard Workertemplate <class T, class Alloc = allocator<T> >
21*58b9f456SAndroid Build Coastguard Workerclass list
22*58b9f456SAndroid Build Coastguard Worker{
23*58b9f456SAndroid Build Coastguard Workerpublic:
24*58b9f456SAndroid Build Coastguard Worker
25*58b9f456SAndroid Build Coastguard Worker    // types:
26*58b9f456SAndroid Build Coastguard Worker    typedef T value_type;
27*58b9f456SAndroid Build Coastguard Worker    typedef Alloc allocator_type;
28*58b9f456SAndroid Build Coastguard Worker    typedef typename allocator_type::reference reference;
29*58b9f456SAndroid Build Coastguard Worker    typedef typename allocator_type::const_reference const_reference;
30*58b9f456SAndroid Build Coastguard Worker    typedef typename allocator_type::pointer pointer;
31*58b9f456SAndroid Build Coastguard Worker    typedef typename allocator_type::const_pointer const_pointer;
32*58b9f456SAndroid Build Coastguard Worker    typedef implementation-defined iterator;
33*58b9f456SAndroid Build Coastguard Worker    typedef implementation-defined const_iterator;
34*58b9f456SAndroid Build Coastguard Worker    typedef implementation-defined size_type;
35*58b9f456SAndroid Build Coastguard Worker    typedef implementation-defined difference_type;
36*58b9f456SAndroid Build Coastguard Worker    typedef reverse_iterator<iterator> reverse_iterator;
37*58b9f456SAndroid Build Coastguard Worker    typedef reverse_iterator<const_iterator> const_reverse_iterator;
38*58b9f456SAndroid Build Coastguard Worker
39*58b9f456SAndroid Build Coastguard Worker    list()
40*58b9f456SAndroid Build Coastguard Worker        noexcept(is_nothrow_default_constructible<allocator_type>::value);
41*58b9f456SAndroid Build Coastguard Worker    explicit list(const allocator_type& a);
42*58b9f456SAndroid Build Coastguard Worker    explicit list(size_type n);
43*58b9f456SAndroid Build Coastguard Worker    explicit list(size_type n, const allocator_type& a); // C++14
44*58b9f456SAndroid Build Coastguard Worker    list(size_type n, const value_type& value);
45*58b9f456SAndroid Build Coastguard Worker    list(size_type n, const value_type& value, const allocator_type& a);
46*58b9f456SAndroid Build Coastguard Worker    template <class Iter>
47*58b9f456SAndroid Build Coastguard Worker        list(Iter first, Iter last);
48*58b9f456SAndroid Build Coastguard Worker    template <class Iter>
49*58b9f456SAndroid Build Coastguard Worker        list(Iter first, Iter last, const allocator_type& a);
50*58b9f456SAndroid Build Coastguard Worker    list(const list& x);
51*58b9f456SAndroid Build Coastguard Worker    list(const list&, const allocator_type& a);
52*58b9f456SAndroid Build Coastguard Worker    list(list&& x)
53*58b9f456SAndroid Build Coastguard Worker        noexcept(is_nothrow_move_constructible<allocator_type>::value);
54*58b9f456SAndroid Build Coastguard Worker    list(list&&, const allocator_type& a);
55*58b9f456SAndroid Build Coastguard Worker    list(initializer_list<value_type>);
56*58b9f456SAndroid Build Coastguard Worker    list(initializer_list<value_type>, const allocator_type& a);
57*58b9f456SAndroid Build Coastguard Worker
58*58b9f456SAndroid Build Coastguard Worker    ~list();
59*58b9f456SAndroid Build Coastguard Worker
60*58b9f456SAndroid Build Coastguard Worker    list& operator=(const list& x);
61*58b9f456SAndroid Build Coastguard Worker    list& operator=(list&& x)
62*58b9f456SAndroid Build Coastguard Worker        noexcept(
63*58b9f456SAndroid Build Coastguard Worker             allocator_type::propagate_on_container_move_assignment::value &&
64*58b9f456SAndroid Build Coastguard Worker             is_nothrow_move_assignable<allocator_type>::value);
65*58b9f456SAndroid Build Coastguard Worker    list& operator=(initializer_list<value_type>);
66*58b9f456SAndroid Build Coastguard Worker    template <class Iter>
67*58b9f456SAndroid Build Coastguard Worker        void assign(Iter first, Iter last);
68*58b9f456SAndroid Build Coastguard Worker    void assign(size_type n, const value_type& t);
69*58b9f456SAndroid Build Coastguard Worker    void assign(initializer_list<value_type>);
70*58b9f456SAndroid Build Coastguard Worker
71*58b9f456SAndroid Build Coastguard Worker    allocator_type get_allocator() const noexcept;
72*58b9f456SAndroid Build Coastguard Worker
73*58b9f456SAndroid Build Coastguard Worker    iterator begin() noexcept;
74*58b9f456SAndroid Build Coastguard Worker    const_iterator begin() const noexcept;
75*58b9f456SAndroid Build Coastguard Worker    iterator end() noexcept;
76*58b9f456SAndroid Build Coastguard Worker    const_iterator end() const noexcept;
77*58b9f456SAndroid Build Coastguard Worker    reverse_iterator rbegin() noexcept;
78*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator rbegin() const noexcept;
79*58b9f456SAndroid Build Coastguard Worker    reverse_iterator rend() noexcept;
80*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator rend() const noexcept;
81*58b9f456SAndroid Build Coastguard Worker    const_iterator cbegin() const noexcept;
82*58b9f456SAndroid Build Coastguard Worker    const_iterator cend() const noexcept;
83*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator crbegin() const noexcept;
84*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator crend() const noexcept;
85*58b9f456SAndroid Build Coastguard Worker
86*58b9f456SAndroid Build Coastguard Worker    reference front();
87*58b9f456SAndroid Build Coastguard Worker    const_reference front() const;
88*58b9f456SAndroid Build Coastguard Worker    reference back();
89*58b9f456SAndroid Build Coastguard Worker    const_reference back() const;
90*58b9f456SAndroid Build Coastguard Worker
91*58b9f456SAndroid Build Coastguard Worker    bool empty() const noexcept;
92*58b9f456SAndroid Build Coastguard Worker    size_type size() const noexcept;
93*58b9f456SAndroid Build Coastguard Worker    size_type max_size() const noexcept;
94*58b9f456SAndroid Build Coastguard Worker
95*58b9f456SAndroid Build Coastguard Worker    template <class... Args>
96*58b9f456SAndroid Build Coastguard Worker        reference emplace_front(Args&&... args); // reference in C++17
97*58b9f456SAndroid Build Coastguard Worker    void pop_front();
98*58b9f456SAndroid Build Coastguard Worker    template <class... Args>
99*58b9f456SAndroid Build Coastguard Worker        reference emplace_back(Args&&... args);  // reference in C++17
100*58b9f456SAndroid Build Coastguard Worker    void pop_back();
101*58b9f456SAndroid Build Coastguard Worker    void push_front(const value_type& x);
102*58b9f456SAndroid Build Coastguard Worker    void push_front(value_type&& x);
103*58b9f456SAndroid Build Coastguard Worker    void push_back(const value_type& x);
104*58b9f456SAndroid Build Coastguard Worker    void push_back(value_type&& x);
105*58b9f456SAndroid Build Coastguard Worker    template <class... Args>
106*58b9f456SAndroid Build Coastguard Worker        iterator emplace(const_iterator position, Args&&... args);
107*58b9f456SAndroid Build Coastguard Worker    iterator insert(const_iterator position, const value_type& x);
108*58b9f456SAndroid Build Coastguard Worker    iterator insert(const_iterator position, value_type&& x);
109*58b9f456SAndroid Build Coastguard Worker    iterator insert(const_iterator position, size_type n, const value_type& x);
110*58b9f456SAndroid Build Coastguard Worker    template <class Iter>
111*58b9f456SAndroid Build Coastguard Worker        iterator insert(const_iterator position, Iter first, Iter last);
112*58b9f456SAndroid Build Coastguard Worker    iterator insert(const_iterator position, initializer_list<value_type> il);
113*58b9f456SAndroid Build Coastguard Worker
114*58b9f456SAndroid Build Coastguard Worker    iterator erase(const_iterator position);
115*58b9f456SAndroid Build Coastguard Worker    iterator erase(const_iterator position, const_iterator last);
116*58b9f456SAndroid Build Coastguard Worker
117*58b9f456SAndroid Build Coastguard Worker    void resize(size_type sz);
118*58b9f456SAndroid Build Coastguard Worker    void resize(size_type sz, const value_type& c);
119*58b9f456SAndroid Build Coastguard Worker
120*58b9f456SAndroid Build Coastguard Worker    void swap(list&)
121*58b9f456SAndroid Build Coastguard Worker        noexcept(allocator_traits<allocator_type>::is_always_equal::value);  // C++17
122*58b9f456SAndroid Build Coastguard Worker    void clear() noexcept;
123*58b9f456SAndroid Build Coastguard Worker
124*58b9f456SAndroid Build Coastguard Worker    void splice(const_iterator position, list& x);
125*58b9f456SAndroid Build Coastguard Worker    void splice(const_iterator position, list&& x);
126*58b9f456SAndroid Build Coastguard Worker    void splice(const_iterator position, list& x, const_iterator i);
127*58b9f456SAndroid Build Coastguard Worker    void splice(const_iterator position, list&& x, const_iterator i);
128*58b9f456SAndroid Build Coastguard Worker    void splice(const_iterator position, list& x, const_iterator first,
129*58b9f456SAndroid Build Coastguard Worker                                                  const_iterator last);
130*58b9f456SAndroid Build Coastguard Worker    void splice(const_iterator position, list&& x, const_iterator first,
131*58b9f456SAndroid Build Coastguard Worker                                                  const_iterator last);
132*58b9f456SAndroid Build Coastguard Worker
133*58b9f456SAndroid Build Coastguard Worker    void remove(const value_type& value);
134*58b9f456SAndroid Build Coastguard Worker    template <class Pred> void remove_if(Pred pred);
135*58b9f456SAndroid Build Coastguard Worker    void unique();
136*58b9f456SAndroid Build Coastguard Worker    template <class BinaryPredicate>
137*58b9f456SAndroid Build Coastguard Worker        void unique(BinaryPredicate binary_pred);
138*58b9f456SAndroid Build Coastguard Worker    void merge(list& x);
139*58b9f456SAndroid Build Coastguard Worker    void merge(list&& x);
140*58b9f456SAndroid Build Coastguard Worker    template <class Compare>
141*58b9f456SAndroid Build Coastguard Worker        void merge(list& x, Compare comp);
142*58b9f456SAndroid Build Coastguard Worker    template <class Compare>
143*58b9f456SAndroid Build Coastguard Worker        void merge(list&& x, Compare comp);
144*58b9f456SAndroid Build Coastguard Worker    void sort();
145*58b9f456SAndroid Build Coastguard Worker    template <class Compare>
146*58b9f456SAndroid Build Coastguard Worker        void sort(Compare comp);
147*58b9f456SAndroid Build Coastguard Worker    void reverse() noexcept;
148*58b9f456SAndroid Build Coastguard Worker};
149*58b9f456SAndroid Build Coastguard Worker
150*58b9f456SAndroid Build Coastguard Worker
151*58b9f456SAndroid Build Coastguard Workertemplate <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
152*58b9f456SAndroid Build Coastguard Worker    list(InputIterator, InputIterator, Allocator = Allocator())
153*58b9f456SAndroid Build Coastguard Worker    -> list<typename iterator_traits<InputIterator>::value_type, Allocator>;  // C++17
154*58b9f456SAndroid Build Coastguard Worker
155*58b9f456SAndroid Build Coastguard Workertemplate <class T, class Alloc>
156*58b9f456SAndroid Build Coastguard Worker    bool operator==(const list<T,Alloc>& x, const list<T,Alloc>& y);
157*58b9f456SAndroid Build Coastguard Workertemplate <class T, class Alloc>
158*58b9f456SAndroid Build Coastguard Worker    bool operator< (const list<T,Alloc>& x, const list<T,Alloc>& y);
159*58b9f456SAndroid Build Coastguard Workertemplate <class T, class Alloc>
160*58b9f456SAndroid Build Coastguard Worker    bool operator!=(const list<T,Alloc>& x, const list<T,Alloc>& y);
161*58b9f456SAndroid Build Coastguard Workertemplate <class T, class Alloc>
162*58b9f456SAndroid Build Coastguard Worker    bool operator> (const list<T,Alloc>& x, const list<T,Alloc>& y);
163*58b9f456SAndroid Build Coastguard Workertemplate <class T, class Alloc>
164*58b9f456SAndroid Build Coastguard Worker    bool operator>=(const list<T,Alloc>& x, const list<T,Alloc>& y);
165*58b9f456SAndroid Build Coastguard Workertemplate <class T, class Alloc>
166*58b9f456SAndroid Build Coastguard Worker    bool operator<=(const list<T,Alloc>& x, const list<T,Alloc>& y);
167*58b9f456SAndroid Build Coastguard Worker
168*58b9f456SAndroid Build Coastguard Workertemplate <class T, class Alloc>
169*58b9f456SAndroid Build Coastguard Worker    void swap(list<T,Alloc>& x, list<T,Alloc>& y)
170*58b9f456SAndroid Build Coastguard Worker         noexcept(noexcept(x.swap(y)));
171*58b9f456SAndroid Build Coastguard Worker
172*58b9f456SAndroid Build Coastguard Workertemplate <class T, class Allocator, class U>
173*58b9f456SAndroid Build Coastguard Worker    void erase(list<T, Allocator>& c, const U& value);       // C++20
174*58b9f456SAndroid Build Coastguard Workertemplate <class T, class Allocator, class Predicate>
175*58b9f456SAndroid Build Coastguard Worker    void erase_if(list<T, Allocator>& c, Predicate pred);    // C++20
176*58b9f456SAndroid Build Coastguard Worker
177*58b9f456SAndroid Build Coastguard Worker}  // std
178*58b9f456SAndroid Build Coastguard Worker
179*58b9f456SAndroid Build Coastguard Worker*/
180*58b9f456SAndroid Build Coastguard Worker
181*58b9f456SAndroid Build Coastguard Worker#include <__config>
182*58b9f456SAndroid Build Coastguard Worker
183*58b9f456SAndroid Build Coastguard Worker#include <memory>
184*58b9f456SAndroid Build Coastguard Worker#include <limits>
185*58b9f456SAndroid Build Coastguard Worker#include <initializer_list>
186*58b9f456SAndroid Build Coastguard Worker#include <iterator>
187*58b9f456SAndroid Build Coastguard Worker#include <algorithm>
188*58b9f456SAndroid Build Coastguard Worker#include <type_traits>
189*58b9f456SAndroid Build Coastguard Worker#include <version>
190*58b9f456SAndroid Build Coastguard Worker
191*58b9f456SAndroid Build Coastguard Worker#include <__debug>
192*58b9f456SAndroid Build Coastguard Worker
193*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
194*58b9f456SAndroid Build Coastguard Worker#pragma GCC system_header
195*58b9f456SAndroid Build Coastguard Worker#endif
196*58b9f456SAndroid Build Coastguard Worker
197*58b9f456SAndroid Build Coastguard Worker_LIBCPP_PUSH_MACROS
198*58b9f456SAndroid Build Coastguard Worker#include <__undef_macros>
199*58b9f456SAndroid Build Coastguard Worker
200*58b9f456SAndroid Build Coastguard Worker
201*58b9f456SAndroid Build Coastguard Worker_LIBCPP_BEGIN_NAMESPACE_STD
202*58b9f456SAndroid Build Coastguard Worker
203*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _VoidPtr> struct __list_node;
204*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _VoidPtr> struct __list_node_base;
205*58b9f456SAndroid Build Coastguard Worker
206*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _VoidPtr>
207*58b9f456SAndroid Build Coastguard Workerstruct __list_node_pointer_traits {
208*58b9f456SAndroid Build Coastguard Worker  typedef typename __rebind_pointer<_VoidPtr, __list_node<_Tp, _VoidPtr> >::type
209*58b9f456SAndroid Build Coastguard Worker        __node_pointer;
210*58b9f456SAndroid Build Coastguard Worker  typedef typename __rebind_pointer<_VoidPtr, __list_node_base<_Tp, _VoidPtr> >::type
211*58b9f456SAndroid Build Coastguard Worker        __base_pointer;
212*58b9f456SAndroid Build Coastguard Worker
213*58b9f456SAndroid Build Coastguard Worker#if defined(_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB)
214*58b9f456SAndroid Build Coastguard Worker  typedef __base_pointer __link_pointer;
215*58b9f456SAndroid Build Coastguard Worker#else
216*58b9f456SAndroid Build Coastguard Worker  typedef typename conditional<
217*58b9f456SAndroid Build Coastguard Worker          is_pointer<_VoidPtr>::value,
218*58b9f456SAndroid Build Coastguard Worker          __base_pointer,
219*58b9f456SAndroid Build Coastguard Worker          __node_pointer
220*58b9f456SAndroid Build Coastguard Worker  >::type __link_pointer;
221*58b9f456SAndroid Build Coastguard Worker#endif
222*58b9f456SAndroid Build Coastguard Worker
223*58b9f456SAndroid Build Coastguard Worker  typedef typename conditional<
224*58b9f456SAndroid Build Coastguard Worker          is_same<__link_pointer, __node_pointer>::value,
225*58b9f456SAndroid Build Coastguard Worker          __base_pointer,
226*58b9f456SAndroid Build Coastguard Worker          __node_pointer
227*58b9f456SAndroid Build Coastguard Worker  >::type __non_link_pointer;
228*58b9f456SAndroid Build Coastguard Worker
229*58b9f456SAndroid Build Coastguard Worker  static _LIBCPP_INLINE_VISIBILITY
230*58b9f456SAndroid Build Coastguard Worker  __link_pointer __unsafe_link_pointer_cast(__link_pointer __p) {
231*58b9f456SAndroid Build Coastguard Worker      return __p;
232*58b9f456SAndroid Build Coastguard Worker  }
233*58b9f456SAndroid Build Coastguard Worker
234*58b9f456SAndroid Build Coastguard Worker  static _LIBCPP_INLINE_VISIBILITY
235*58b9f456SAndroid Build Coastguard Worker  __link_pointer __unsafe_link_pointer_cast(__non_link_pointer __p) {
236*58b9f456SAndroid Build Coastguard Worker      return static_cast<__link_pointer>(static_cast<_VoidPtr>(__p));
237*58b9f456SAndroid Build Coastguard Worker  }
238*58b9f456SAndroid Build Coastguard Worker
239*58b9f456SAndroid Build Coastguard Worker};
240*58b9f456SAndroid Build Coastguard Worker
241*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _VoidPtr>
242*58b9f456SAndroid Build Coastguard Workerstruct __list_node_base
243*58b9f456SAndroid Build Coastguard Worker{
244*58b9f456SAndroid Build Coastguard Worker    typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;
245*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTraits::__node_pointer __node_pointer;
246*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTraits::__base_pointer __base_pointer;
247*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTraits::__link_pointer __link_pointer;
248*58b9f456SAndroid Build Coastguard Worker
249*58b9f456SAndroid Build Coastguard Worker    __link_pointer __prev_;
250*58b9f456SAndroid Build Coastguard Worker    __link_pointer __next_;
251*58b9f456SAndroid Build Coastguard Worker
252*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
253*58b9f456SAndroid Build Coastguard Worker    __list_node_base() : __prev_(_NodeTraits::__unsafe_link_pointer_cast(__self())),
254*58b9f456SAndroid Build Coastguard Worker                         __next_(_NodeTraits::__unsafe_link_pointer_cast(__self())) {}
255*58b9f456SAndroid Build Coastguard Worker
256*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
257*58b9f456SAndroid Build Coastguard Worker    __base_pointer __self() {
258*58b9f456SAndroid Build Coastguard Worker        return pointer_traits<__base_pointer>::pointer_to(*this);
259*58b9f456SAndroid Build Coastguard Worker    }
260*58b9f456SAndroid Build Coastguard Worker
261*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
262*58b9f456SAndroid Build Coastguard Worker    __node_pointer __as_node() {
263*58b9f456SAndroid Build Coastguard Worker        return static_cast<__node_pointer>(__self());
264*58b9f456SAndroid Build Coastguard Worker    }
265*58b9f456SAndroid Build Coastguard Worker};
266*58b9f456SAndroid Build Coastguard Worker
267*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _VoidPtr>
268*58b9f456SAndroid Build Coastguard Workerstruct __list_node
269*58b9f456SAndroid Build Coastguard Worker    : public __list_node_base<_Tp, _VoidPtr>
270*58b9f456SAndroid Build Coastguard Worker{
271*58b9f456SAndroid Build Coastguard Worker    _Tp __value_;
272*58b9f456SAndroid Build Coastguard Worker
273*58b9f456SAndroid Build Coastguard Worker    typedef __list_node_base<_Tp, _VoidPtr> __base;
274*58b9f456SAndroid Build Coastguard Worker    typedef typename __base::__link_pointer __link_pointer;
275*58b9f456SAndroid Build Coastguard Worker
276*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
277*58b9f456SAndroid Build Coastguard Worker    __link_pointer __as_link() {
278*58b9f456SAndroid Build Coastguard Worker        return static_cast<__link_pointer>(__base::__self());
279*58b9f456SAndroid Build Coastguard Worker    }
280*58b9f456SAndroid Build Coastguard Worker};
281*58b9f456SAndroid Build Coastguard Worker
282*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc = allocator<_Tp> > class _LIBCPP_TEMPLATE_VIS list;
283*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc> class __list_imp;
284*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _VoidPtr> class _LIBCPP_TEMPLATE_VIS __list_const_iterator;
285*58b9f456SAndroid Build Coastguard Worker
286*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _VoidPtr>
287*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS __list_iterator
288*58b9f456SAndroid Build Coastguard Worker{
289*58b9f456SAndroid Build Coastguard Worker    typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;
290*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTraits::__link_pointer __link_pointer;
291*58b9f456SAndroid Build Coastguard Worker
292*58b9f456SAndroid Build Coastguard Worker    __link_pointer __ptr_;
293*58b9f456SAndroid Build Coastguard Worker
294*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
295*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
296*58b9f456SAndroid Build Coastguard Worker    explicit __list_iterator(__link_pointer __p, const void* __c) _NOEXCEPT
297*58b9f456SAndroid Build Coastguard Worker        : __ptr_(__p)
298*58b9f456SAndroid Build Coastguard Worker    {
299*58b9f456SAndroid Build Coastguard Worker        __get_db()->__insert_ic(this, __c);
300*58b9f456SAndroid Build Coastguard Worker    }
301*58b9f456SAndroid Build Coastguard Worker#else
302*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
303*58b9f456SAndroid Build Coastguard Worker    explicit __list_iterator(__link_pointer __p) _NOEXCEPT : __ptr_(__p) {}
304*58b9f456SAndroid Build Coastguard Worker#endif
305*58b9f456SAndroid Build Coastguard Worker
306*58b9f456SAndroid Build Coastguard Worker
307*58b9f456SAndroid Build Coastguard Worker
308*58b9f456SAndroid Build Coastguard Worker    template<class, class> friend class list;
309*58b9f456SAndroid Build Coastguard Worker    template<class, class> friend class __list_imp;
310*58b9f456SAndroid Build Coastguard Worker    template<class, class> friend class __list_const_iterator;
311*58b9f456SAndroid Build Coastguard Workerpublic:
312*58b9f456SAndroid Build Coastguard Worker    typedef bidirectional_iterator_tag       iterator_category;
313*58b9f456SAndroid Build Coastguard Worker    typedef _Tp                              value_type;
314*58b9f456SAndroid Build Coastguard Worker    typedef value_type&                      reference;
315*58b9f456SAndroid Build Coastguard Worker    typedef typename __rebind_pointer<_VoidPtr, value_type>::type pointer;
316*58b9f456SAndroid Build Coastguard Worker    typedef typename pointer_traits<pointer>::difference_type difference_type;
317*58b9f456SAndroid Build Coastguard Worker
318*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
319*58b9f456SAndroid Build Coastguard Worker    __list_iterator() _NOEXCEPT : __ptr_(nullptr)
320*58b9f456SAndroid Build Coastguard Worker    {
321*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
322*58b9f456SAndroid Build Coastguard Worker        __get_db()->__insert_i(this);
323*58b9f456SAndroid Build Coastguard Worker#endif
324*58b9f456SAndroid Build Coastguard Worker    }
325*58b9f456SAndroid Build Coastguard Worker
326*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
327*58b9f456SAndroid Build Coastguard Worker
328*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
329*58b9f456SAndroid Build Coastguard Worker    __list_iterator(const __list_iterator& __p)
330*58b9f456SAndroid Build Coastguard Worker        : __ptr_(__p.__ptr_)
331*58b9f456SAndroid Build Coastguard Worker    {
332*58b9f456SAndroid Build Coastguard Worker        __get_db()->__iterator_copy(this, &__p);
333*58b9f456SAndroid Build Coastguard Worker    }
334*58b9f456SAndroid Build Coastguard Worker
335*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
336*58b9f456SAndroid Build Coastguard Worker    ~__list_iterator()
337*58b9f456SAndroid Build Coastguard Worker    {
338*58b9f456SAndroid Build Coastguard Worker        __get_db()->__erase_i(this);
339*58b9f456SAndroid Build Coastguard Worker    }
340*58b9f456SAndroid Build Coastguard Worker
341*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
342*58b9f456SAndroid Build Coastguard Worker    __list_iterator& operator=(const __list_iterator& __p)
343*58b9f456SAndroid Build Coastguard Worker    {
344*58b9f456SAndroid Build Coastguard Worker        if (this != &__p)
345*58b9f456SAndroid Build Coastguard Worker        {
346*58b9f456SAndroid Build Coastguard Worker            __get_db()->__iterator_copy(this, &__p);
347*58b9f456SAndroid Build Coastguard Worker            __ptr_ = __p.__ptr_;
348*58b9f456SAndroid Build Coastguard Worker        }
349*58b9f456SAndroid Build Coastguard Worker        return *this;
350*58b9f456SAndroid Build Coastguard Worker    }
351*58b9f456SAndroid Build Coastguard Worker
352*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_DEBUG_LEVEL >= 2
353*58b9f456SAndroid Build Coastguard Worker
354*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
355*58b9f456SAndroid Build Coastguard Worker    reference operator*() const
356*58b9f456SAndroid Build Coastguard Worker    {
357*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
358*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
359*58b9f456SAndroid Build Coastguard Worker                       "Attempted to dereference a non-dereferenceable list::iterator");
360*58b9f456SAndroid Build Coastguard Worker#endif
361*58b9f456SAndroid Build Coastguard Worker        return __ptr_->__as_node()->__value_;
362*58b9f456SAndroid Build Coastguard Worker    }
363*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
364*58b9f456SAndroid Build Coastguard Worker    pointer operator->() const
365*58b9f456SAndroid Build Coastguard Worker    {
366*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
367*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
368*58b9f456SAndroid Build Coastguard Worker                       "Attempted to dereference a non-dereferenceable list::iterator");
369*58b9f456SAndroid Build Coastguard Worker#endif
370*58b9f456SAndroid Build Coastguard Worker        return pointer_traits<pointer>::pointer_to(__ptr_->__as_node()->__value_);
371*58b9f456SAndroid Build Coastguard Worker    }
372*58b9f456SAndroid Build Coastguard Worker
373*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
374*58b9f456SAndroid Build Coastguard Worker    __list_iterator& operator++()
375*58b9f456SAndroid Build Coastguard Worker    {
376*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
377*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
378*58b9f456SAndroid Build Coastguard Worker                       "Attempted to increment non-incrementable list::iterator");
379*58b9f456SAndroid Build Coastguard Worker#endif
380*58b9f456SAndroid Build Coastguard Worker        __ptr_ = __ptr_->__next_;
381*58b9f456SAndroid Build Coastguard Worker        return *this;
382*58b9f456SAndroid Build Coastguard Worker    }
383*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
384*58b9f456SAndroid Build Coastguard Worker    __list_iterator operator++(int) {__list_iterator __t(*this); ++(*this); return __t;}
385*58b9f456SAndroid Build Coastguard Worker
386*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
387*58b9f456SAndroid Build Coastguard Worker    __list_iterator& operator--()
388*58b9f456SAndroid Build Coastguard Worker    {
389*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
390*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_ASSERT(__get_const_db()->__decrementable(this),
391*58b9f456SAndroid Build Coastguard Worker                       "Attempted to decrement non-decrementable list::iterator");
392*58b9f456SAndroid Build Coastguard Worker#endif
393*58b9f456SAndroid Build Coastguard Worker        __ptr_ = __ptr_->__prev_;
394*58b9f456SAndroid Build Coastguard Worker        return *this;
395*58b9f456SAndroid Build Coastguard Worker    }
396*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
397*58b9f456SAndroid Build Coastguard Worker    __list_iterator operator--(int) {__list_iterator __t(*this); --(*this); return __t;}
398*58b9f456SAndroid Build Coastguard Worker
399*58b9f456SAndroid Build Coastguard Worker    friend _LIBCPP_INLINE_VISIBILITY
400*58b9f456SAndroid Build Coastguard Worker    bool operator==(const __list_iterator& __x, const __list_iterator& __y)
401*58b9f456SAndroid Build Coastguard Worker    {
402*58b9f456SAndroid Build Coastguard Worker        return __x.__ptr_ == __y.__ptr_;
403*58b9f456SAndroid Build Coastguard Worker    }
404*58b9f456SAndroid Build Coastguard Worker    friend _LIBCPP_INLINE_VISIBILITY
405*58b9f456SAndroid Build Coastguard Worker     bool operator!=(const __list_iterator& __x, const __list_iterator& __y)
406*58b9f456SAndroid Build Coastguard Worker        {return !(__x == __y);}
407*58b9f456SAndroid Build Coastguard Worker};
408*58b9f456SAndroid Build Coastguard Worker
409*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _VoidPtr>
410*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS __list_const_iterator
411*58b9f456SAndroid Build Coastguard Worker{
412*58b9f456SAndroid Build Coastguard Worker    typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;
413*58b9f456SAndroid Build Coastguard Worker    typedef typename _NodeTraits::__link_pointer __link_pointer;
414*58b9f456SAndroid Build Coastguard Worker
415*58b9f456SAndroid Build Coastguard Worker    __link_pointer __ptr_;
416*58b9f456SAndroid Build Coastguard Worker
417*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
418*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
419*58b9f456SAndroid Build Coastguard Worker    explicit __list_const_iterator(__link_pointer __p, const void* __c) _NOEXCEPT
420*58b9f456SAndroid Build Coastguard Worker        : __ptr_(__p)
421*58b9f456SAndroid Build Coastguard Worker    {
422*58b9f456SAndroid Build Coastguard Worker        __get_db()->__insert_ic(this, __c);
423*58b9f456SAndroid Build Coastguard Worker    }
424*58b9f456SAndroid Build Coastguard Worker#else
425*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
426*58b9f456SAndroid Build Coastguard Worker    explicit __list_const_iterator(__link_pointer __p) _NOEXCEPT : __ptr_(__p) {}
427*58b9f456SAndroid Build Coastguard Worker#endif
428*58b9f456SAndroid Build Coastguard Worker
429*58b9f456SAndroid Build Coastguard Worker    template<class, class> friend class list;
430*58b9f456SAndroid Build Coastguard Worker    template<class, class> friend class __list_imp;
431*58b9f456SAndroid Build Coastguard Workerpublic:
432*58b9f456SAndroid Build Coastguard Worker    typedef bidirectional_iterator_tag       iterator_category;
433*58b9f456SAndroid Build Coastguard Worker    typedef _Tp                              value_type;
434*58b9f456SAndroid Build Coastguard Worker    typedef const value_type&                reference;
435*58b9f456SAndroid Build Coastguard Worker    typedef typename __rebind_pointer<_VoidPtr, const value_type>::type pointer;
436*58b9f456SAndroid Build Coastguard Worker    typedef typename pointer_traits<pointer>::difference_type difference_type;
437*58b9f456SAndroid Build Coastguard Worker
438*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
439*58b9f456SAndroid Build Coastguard Worker    __list_const_iterator() _NOEXCEPT : __ptr_(nullptr)
440*58b9f456SAndroid Build Coastguard Worker    {
441*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
442*58b9f456SAndroid Build Coastguard Worker        __get_db()->__insert_i(this);
443*58b9f456SAndroid Build Coastguard Worker#endif
444*58b9f456SAndroid Build Coastguard Worker    }
445*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
446*58b9f456SAndroid Build Coastguard Worker    __list_const_iterator(const __list_iterator<_Tp, _VoidPtr>& __p) _NOEXCEPT
447*58b9f456SAndroid Build Coastguard Worker        : __ptr_(__p.__ptr_)
448*58b9f456SAndroid Build Coastguard Worker    {
449*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
450*58b9f456SAndroid Build Coastguard Worker        __get_db()->__iterator_copy(this, &__p);
451*58b9f456SAndroid Build Coastguard Worker#endif
452*58b9f456SAndroid Build Coastguard Worker    }
453*58b9f456SAndroid Build Coastguard Worker
454*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
455*58b9f456SAndroid Build Coastguard Worker
456*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
457*58b9f456SAndroid Build Coastguard Worker    __list_const_iterator(const __list_const_iterator& __p)
458*58b9f456SAndroid Build Coastguard Worker        : __ptr_(__p.__ptr_)
459*58b9f456SAndroid Build Coastguard Worker    {
460*58b9f456SAndroid Build Coastguard Worker        __get_db()->__iterator_copy(this, &__p);
461*58b9f456SAndroid Build Coastguard Worker    }
462*58b9f456SAndroid Build Coastguard Worker
463*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
464*58b9f456SAndroid Build Coastguard Worker    ~__list_const_iterator()
465*58b9f456SAndroid Build Coastguard Worker    {
466*58b9f456SAndroid Build Coastguard Worker        __get_db()->__erase_i(this);
467*58b9f456SAndroid Build Coastguard Worker    }
468*58b9f456SAndroid Build Coastguard Worker
469*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
470*58b9f456SAndroid Build Coastguard Worker    __list_const_iterator& operator=(const __list_const_iterator& __p)
471*58b9f456SAndroid Build Coastguard Worker    {
472*58b9f456SAndroid Build Coastguard Worker        if (this != &__p)
473*58b9f456SAndroid Build Coastguard Worker        {
474*58b9f456SAndroid Build Coastguard Worker            __get_db()->__iterator_copy(this, &__p);
475*58b9f456SAndroid Build Coastguard Worker            __ptr_ = __p.__ptr_;
476*58b9f456SAndroid Build Coastguard Worker        }
477*58b9f456SAndroid Build Coastguard Worker        return *this;
478*58b9f456SAndroid Build Coastguard Worker    }
479*58b9f456SAndroid Build Coastguard Worker
480*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_DEBUG_LEVEL >= 2
481*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
482*58b9f456SAndroid Build Coastguard Worker    reference operator*() const
483*58b9f456SAndroid Build Coastguard Worker    {
484*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
485*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
486*58b9f456SAndroid Build Coastguard Worker                       "Attempted to dereference a non-dereferenceable list::const_iterator");
487*58b9f456SAndroid Build Coastguard Worker#endif
488*58b9f456SAndroid Build Coastguard Worker        return __ptr_->__as_node()->__value_;
489*58b9f456SAndroid Build Coastguard Worker    }
490*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
491*58b9f456SAndroid Build Coastguard Worker    pointer operator->() const
492*58b9f456SAndroid Build Coastguard Worker    {
493*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
494*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
495*58b9f456SAndroid Build Coastguard Worker                       "Attempted to dereference a non-dereferenceable list::const_iterator");
496*58b9f456SAndroid Build Coastguard Worker#endif
497*58b9f456SAndroid Build Coastguard Worker        return pointer_traits<pointer>::pointer_to(__ptr_->__as_node()->__value_);
498*58b9f456SAndroid Build Coastguard Worker    }
499*58b9f456SAndroid Build Coastguard Worker
500*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
501*58b9f456SAndroid Build Coastguard Worker    __list_const_iterator& operator++()
502*58b9f456SAndroid Build Coastguard Worker    {
503*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
504*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
505*58b9f456SAndroid Build Coastguard Worker                       "Attempted to increment non-incrementable list::const_iterator");
506*58b9f456SAndroid Build Coastguard Worker#endif
507*58b9f456SAndroid Build Coastguard Worker        __ptr_ = __ptr_->__next_;
508*58b9f456SAndroid Build Coastguard Worker        return *this;
509*58b9f456SAndroid Build Coastguard Worker    }
510*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
511*58b9f456SAndroid Build Coastguard Worker    __list_const_iterator operator++(int) {__list_const_iterator __t(*this); ++(*this); return __t;}
512*58b9f456SAndroid Build Coastguard Worker
513*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
514*58b9f456SAndroid Build Coastguard Worker    __list_const_iterator& operator--()
515*58b9f456SAndroid Build Coastguard Worker    {
516*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
517*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_ASSERT(__get_const_db()->__decrementable(this),
518*58b9f456SAndroid Build Coastguard Worker                       "Attempted to decrement non-decrementable list::const_iterator");
519*58b9f456SAndroid Build Coastguard Worker#endif
520*58b9f456SAndroid Build Coastguard Worker        __ptr_ = __ptr_->__prev_;
521*58b9f456SAndroid Build Coastguard Worker        return *this;
522*58b9f456SAndroid Build Coastguard Worker    }
523*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
524*58b9f456SAndroid Build Coastguard Worker    __list_const_iterator operator--(int) {__list_const_iterator __t(*this); --(*this); return __t;}
525*58b9f456SAndroid Build Coastguard Worker
526*58b9f456SAndroid Build Coastguard Worker    friend _LIBCPP_INLINE_VISIBILITY
527*58b9f456SAndroid Build Coastguard Worker    bool operator==(const __list_const_iterator& __x, const __list_const_iterator& __y)
528*58b9f456SAndroid Build Coastguard Worker    {
529*58b9f456SAndroid Build Coastguard Worker        return __x.__ptr_ == __y.__ptr_;
530*58b9f456SAndroid Build Coastguard Worker    }
531*58b9f456SAndroid Build Coastguard Worker    friend _LIBCPP_INLINE_VISIBILITY
532*58b9f456SAndroid Build Coastguard Worker    bool operator!=(const __list_const_iterator& __x, const __list_const_iterator& __y)
533*58b9f456SAndroid Build Coastguard Worker        {return !(__x == __y);}
534*58b9f456SAndroid Build Coastguard Worker};
535*58b9f456SAndroid Build Coastguard Worker
536*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
537*58b9f456SAndroid Build Coastguard Workerclass __list_imp
538*58b9f456SAndroid Build Coastguard Worker{
539*58b9f456SAndroid Build Coastguard Worker    __list_imp(const __list_imp&);
540*58b9f456SAndroid Build Coastguard Worker    __list_imp& operator=(const __list_imp&);
541*58b9f456SAndroid Build Coastguard Workerpublic:
542*58b9f456SAndroid Build Coastguard Worker    typedef _Alloc                                                  allocator_type;
543*58b9f456SAndroid Build Coastguard Worker    typedef allocator_traits<allocator_type>                        __alloc_traits;
544*58b9f456SAndroid Build Coastguard Worker    typedef typename __alloc_traits::size_type                      size_type;
545*58b9f456SAndroid Build Coastguard Workerprotected:
546*58b9f456SAndroid Build Coastguard Worker    typedef _Tp                                                     value_type;
547*58b9f456SAndroid Build Coastguard Worker    typedef typename __alloc_traits::void_pointer                   __void_pointer;
548*58b9f456SAndroid Build Coastguard Worker    typedef __list_iterator<value_type, __void_pointer>             iterator;
549*58b9f456SAndroid Build Coastguard Worker    typedef __list_const_iterator<value_type, __void_pointer>       const_iterator;
550*58b9f456SAndroid Build Coastguard Worker    typedef __list_node_base<value_type, __void_pointer>            __node_base;
551*58b9f456SAndroid Build Coastguard Worker    typedef __list_node<value_type, __void_pointer>                 __node;
552*58b9f456SAndroid Build Coastguard Worker    typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator;
553*58b9f456SAndroid Build Coastguard Worker    typedef allocator_traits<__node_allocator>                       __node_alloc_traits;
554*58b9f456SAndroid Build Coastguard Worker    typedef typename __node_alloc_traits::pointer                    __node_pointer;
555*58b9f456SAndroid Build Coastguard Worker    typedef typename __node_alloc_traits::pointer                    __node_const_pointer;
556*58b9f456SAndroid Build Coastguard Worker    typedef __list_node_pointer_traits<value_type, __void_pointer> __node_pointer_traits;
557*58b9f456SAndroid Build Coastguard Worker    typedef typename __node_pointer_traits::__link_pointer __link_pointer;
558*58b9f456SAndroid Build Coastguard Worker    typedef __link_pointer __link_const_pointer;
559*58b9f456SAndroid Build Coastguard Worker    typedef typename __alloc_traits::pointer                         pointer;
560*58b9f456SAndroid Build Coastguard Worker    typedef typename __alloc_traits::const_pointer                   const_pointer;
561*58b9f456SAndroid Build Coastguard Worker    typedef typename __alloc_traits::difference_type                 difference_type;
562*58b9f456SAndroid Build Coastguard Worker
563*58b9f456SAndroid Build Coastguard Worker    typedef typename __rebind_alloc_helper<__alloc_traits, __node_base>::type __node_base_allocator;
564*58b9f456SAndroid Build Coastguard Worker    typedef typename allocator_traits<__node_base_allocator>::pointer __node_base_pointer;
565*58b9f456SAndroid Build Coastguard Worker    static_assert((!is_same<allocator_type, __node_allocator>::value),
566*58b9f456SAndroid Build Coastguard Worker                  "internal allocator type must differ from user-specified "
567*58b9f456SAndroid Build Coastguard Worker                  "type; otherwise overload resolution breaks");
568*58b9f456SAndroid Build Coastguard Worker
569*58b9f456SAndroid Build Coastguard Worker    __node_base __end_;
570*58b9f456SAndroid Build Coastguard Worker    __compressed_pair<size_type, __node_allocator> __size_alloc_;
571*58b9f456SAndroid Build Coastguard Worker
572*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
573*58b9f456SAndroid Build Coastguard Worker    __link_pointer __end_as_link() const _NOEXCEPT {
574*58b9f456SAndroid Build Coastguard Worker        return __node_pointer_traits::__unsafe_link_pointer_cast(
575*58b9f456SAndroid Build Coastguard Worker                const_cast<__node_base&>(__end_).__self());
576*58b9f456SAndroid Build Coastguard Worker    }
577*58b9f456SAndroid Build Coastguard Worker
578*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
579*58b9f456SAndroid Build Coastguard Worker          size_type& __sz() _NOEXCEPT {return __size_alloc_.first();}
580*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
581*58b9f456SAndroid Build Coastguard Worker    const size_type& __sz() const _NOEXCEPT
582*58b9f456SAndroid Build Coastguard Worker        {return __size_alloc_.first();}
583*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
584*58b9f456SAndroid Build Coastguard Worker          __node_allocator& __node_alloc() _NOEXCEPT
585*58b9f456SAndroid Build Coastguard Worker          {return __size_alloc_.second();}
586*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
587*58b9f456SAndroid Build Coastguard Worker    const __node_allocator& __node_alloc() const _NOEXCEPT
588*58b9f456SAndroid Build Coastguard Worker        {return __size_alloc_.second();}
589*58b9f456SAndroid Build Coastguard Worker
590*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
591*58b9f456SAndroid Build Coastguard Worker    size_type __node_alloc_max_size() const _NOEXCEPT {
592*58b9f456SAndroid Build Coastguard Worker        return __node_alloc_traits::max_size(__node_alloc());
593*58b9f456SAndroid Build Coastguard Worker    }
594*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
595*58b9f456SAndroid Build Coastguard Worker    static void __unlink_nodes(__link_pointer __f, __link_pointer __l) _NOEXCEPT;
596*58b9f456SAndroid Build Coastguard Worker
597*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
598*58b9f456SAndroid Build Coastguard Worker    __list_imp()
599*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value);
600*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
601*58b9f456SAndroid Build Coastguard Worker    __list_imp(const allocator_type& __a);
602*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
603*58b9f456SAndroid Build Coastguard Worker    __list_imp(const __node_allocator& __a);
604*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
605*58b9f456SAndroid Build Coastguard Worker    __list_imp(__node_allocator&& __a) _NOEXCEPT;
606*58b9f456SAndroid Build Coastguard Worker#endif
607*58b9f456SAndroid Build Coastguard Worker    ~__list_imp();
608*58b9f456SAndroid Build Coastguard Worker    void clear() _NOEXCEPT;
609*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
610*58b9f456SAndroid Build Coastguard Worker    bool empty() const _NOEXCEPT {return __sz() == 0;}
611*58b9f456SAndroid Build Coastguard Worker
612*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
613*58b9f456SAndroid Build Coastguard Worker    iterator begin() _NOEXCEPT
614*58b9f456SAndroid Build Coastguard Worker    {
615*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
616*58b9f456SAndroid Build Coastguard Worker        return iterator(__end_.__next_, this);
617*58b9f456SAndroid Build Coastguard Worker#else
618*58b9f456SAndroid Build Coastguard Worker        return iterator(__end_.__next_);
619*58b9f456SAndroid Build Coastguard Worker#endif
620*58b9f456SAndroid Build Coastguard Worker    }
621*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
622*58b9f456SAndroid Build Coastguard Worker    const_iterator begin() const  _NOEXCEPT
623*58b9f456SAndroid Build Coastguard Worker    {
624*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
625*58b9f456SAndroid Build Coastguard Worker        return const_iterator(__end_.__next_, this);
626*58b9f456SAndroid Build Coastguard Worker#else
627*58b9f456SAndroid Build Coastguard Worker        return const_iterator(__end_.__next_);
628*58b9f456SAndroid Build Coastguard Worker#endif
629*58b9f456SAndroid Build Coastguard Worker    }
630*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
631*58b9f456SAndroid Build Coastguard Worker    iterator end() _NOEXCEPT
632*58b9f456SAndroid Build Coastguard Worker    {
633*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
634*58b9f456SAndroid Build Coastguard Worker        return iterator(__end_as_link(), this);
635*58b9f456SAndroid Build Coastguard Worker#else
636*58b9f456SAndroid Build Coastguard Worker        return iterator(__end_as_link());
637*58b9f456SAndroid Build Coastguard Worker#endif
638*58b9f456SAndroid Build Coastguard Worker    }
639*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
640*58b9f456SAndroid Build Coastguard Worker    const_iterator end() const _NOEXCEPT
641*58b9f456SAndroid Build Coastguard Worker    {
642*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
643*58b9f456SAndroid Build Coastguard Worker        return const_iterator(__end_as_link(), this);
644*58b9f456SAndroid Build Coastguard Worker#else
645*58b9f456SAndroid Build Coastguard Worker        return const_iterator(__end_as_link());
646*58b9f456SAndroid Build Coastguard Worker#endif
647*58b9f456SAndroid Build Coastguard Worker    }
648*58b9f456SAndroid Build Coastguard Worker
649*58b9f456SAndroid Build Coastguard Worker    void swap(__list_imp& __c)
650*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER >= 14
651*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_DEBUG;
652*58b9f456SAndroid Build Coastguard Worker#else
653*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value ||
654*58b9f456SAndroid Build Coastguard Worker                    __is_nothrow_swappable<allocator_type>::value);
655*58b9f456SAndroid Build Coastguard Worker#endif
656*58b9f456SAndroid Build Coastguard Worker
657*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
658*58b9f456SAndroid Build Coastguard Worker    void __copy_assign_alloc(const __list_imp& __c)
659*58b9f456SAndroid Build Coastguard Worker        {__copy_assign_alloc(__c, integral_constant<bool,
660*58b9f456SAndroid Build Coastguard Worker                      __node_alloc_traits::propagate_on_container_copy_assignment::value>());}
661*58b9f456SAndroid Build Coastguard Worker
662*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
663*58b9f456SAndroid Build Coastguard Worker    void __move_assign_alloc(__list_imp& __c)
664*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(
665*58b9f456SAndroid Build Coastguard Worker            !__node_alloc_traits::propagate_on_container_move_assignment::value ||
666*58b9f456SAndroid Build Coastguard Worker            is_nothrow_move_assignable<__node_allocator>::value)
667*58b9f456SAndroid Build Coastguard Worker        {__move_assign_alloc(__c, integral_constant<bool,
668*58b9f456SAndroid Build Coastguard Worker                      __node_alloc_traits::propagate_on_container_move_assignment::value>());}
669*58b9f456SAndroid Build Coastguard Worker
670*58b9f456SAndroid Build Coastguard Workerprivate:
671*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
672*58b9f456SAndroid Build Coastguard Worker    void __copy_assign_alloc(const __list_imp& __c, true_type)
673*58b9f456SAndroid Build Coastguard Worker        {
674*58b9f456SAndroid Build Coastguard Worker            if (__node_alloc() != __c.__node_alloc())
675*58b9f456SAndroid Build Coastguard Worker                clear();
676*58b9f456SAndroid Build Coastguard Worker            __node_alloc() = __c.__node_alloc();
677*58b9f456SAndroid Build Coastguard Worker        }
678*58b9f456SAndroid Build Coastguard Worker
679*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
680*58b9f456SAndroid Build Coastguard Worker    void __copy_assign_alloc(const __list_imp&, false_type)
681*58b9f456SAndroid Build Coastguard Worker        {}
682*58b9f456SAndroid Build Coastguard Worker
683*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
684*58b9f456SAndroid Build Coastguard Worker    void __move_assign_alloc(__list_imp& __c, true_type)
685*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value)
686*58b9f456SAndroid Build Coastguard Worker        {
687*58b9f456SAndroid Build Coastguard Worker            __node_alloc() = _VSTD::move(__c.__node_alloc());
688*58b9f456SAndroid Build Coastguard Worker        }
689*58b9f456SAndroid Build Coastguard Worker
690*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
691*58b9f456SAndroid Build Coastguard Worker    void __move_assign_alloc(__list_imp&, false_type)
692*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT
693*58b9f456SAndroid Build Coastguard Worker        {}
694*58b9f456SAndroid Build Coastguard Worker
695*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
696*58b9f456SAndroid Build Coastguard Worker    void __invalidate_all_iterators() {
697*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
698*58b9f456SAndroid Build Coastguard Worker      __get_db()->__invalidate_all(this);
699*58b9f456SAndroid Build Coastguard Worker#endif
700*58b9f456SAndroid Build Coastguard Worker    }
701*58b9f456SAndroid Build Coastguard Worker};
702*58b9f456SAndroid Build Coastguard Worker
703*58b9f456SAndroid Build Coastguard Worker// Unlink nodes [__f, __l]
704*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
705*58b9f456SAndroid Build Coastguard Workerinline
706*58b9f456SAndroid Build Coastguard Workervoid
707*58b9f456SAndroid Build Coastguard Worker__list_imp<_Tp, _Alloc>::__unlink_nodes(__link_pointer __f, __link_pointer __l)
708*58b9f456SAndroid Build Coastguard Worker    _NOEXCEPT
709*58b9f456SAndroid Build Coastguard Worker{
710*58b9f456SAndroid Build Coastguard Worker    __f->__prev_->__next_ = __l->__next_;
711*58b9f456SAndroid Build Coastguard Worker    __l->__next_->__prev_ = __f->__prev_;
712*58b9f456SAndroid Build Coastguard Worker}
713*58b9f456SAndroid Build Coastguard Worker
714*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
715*58b9f456SAndroid Build Coastguard Workerinline
716*58b9f456SAndroid Build Coastguard Worker__list_imp<_Tp, _Alloc>::__list_imp()
717*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
718*58b9f456SAndroid Build Coastguard Worker    : __size_alloc_(0)
719*58b9f456SAndroid Build Coastguard Worker{
720*58b9f456SAndroid Build Coastguard Worker}
721*58b9f456SAndroid Build Coastguard Worker
722*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
723*58b9f456SAndroid Build Coastguard Workerinline
724*58b9f456SAndroid Build Coastguard Worker__list_imp<_Tp, _Alloc>::__list_imp(const allocator_type& __a)
725*58b9f456SAndroid Build Coastguard Worker    : __size_alloc_(0, __node_allocator(__a))
726*58b9f456SAndroid Build Coastguard Worker{
727*58b9f456SAndroid Build Coastguard Worker}
728*58b9f456SAndroid Build Coastguard Worker
729*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
730*58b9f456SAndroid Build Coastguard Workerinline __list_imp<_Tp, _Alloc>::__list_imp(const __node_allocator& __a)
731*58b9f456SAndroid Build Coastguard Worker    : __size_alloc_(0, __a) {}
732*58b9f456SAndroid Build Coastguard Worker
733*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
734*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
735*58b9f456SAndroid Build Coastguard Workerinline __list_imp<_Tp, _Alloc>::__list_imp(__node_allocator&& __a) _NOEXCEPT
736*58b9f456SAndroid Build Coastguard Worker    : __size_alloc_(0, std::move(__a)) {}
737*58b9f456SAndroid Build Coastguard Worker#endif
738*58b9f456SAndroid Build Coastguard Worker
739*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
740*58b9f456SAndroid Build Coastguard Worker__list_imp<_Tp, _Alloc>::~__list_imp() {
741*58b9f456SAndroid Build Coastguard Worker  clear();
742*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
743*58b9f456SAndroid Build Coastguard Worker    __get_db()->__erase_c(this);
744*58b9f456SAndroid Build Coastguard Worker#endif
745*58b9f456SAndroid Build Coastguard Worker}
746*58b9f456SAndroid Build Coastguard Worker
747*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
748*58b9f456SAndroid Build Coastguard Workervoid
749*58b9f456SAndroid Build Coastguard Worker__list_imp<_Tp, _Alloc>::clear() _NOEXCEPT
750*58b9f456SAndroid Build Coastguard Worker{
751*58b9f456SAndroid Build Coastguard Worker    if (!empty())
752*58b9f456SAndroid Build Coastguard Worker    {
753*58b9f456SAndroid Build Coastguard Worker        __node_allocator& __na = __node_alloc();
754*58b9f456SAndroid Build Coastguard Worker        __link_pointer __f = __end_.__next_;
755*58b9f456SAndroid Build Coastguard Worker        __link_pointer __l = __end_as_link();
756*58b9f456SAndroid Build Coastguard Worker        __unlink_nodes(__f, __l->__prev_);
757*58b9f456SAndroid Build Coastguard Worker        __sz() = 0;
758*58b9f456SAndroid Build Coastguard Worker        while (__f != __l)
759*58b9f456SAndroid Build Coastguard Worker        {
760*58b9f456SAndroid Build Coastguard Worker            __node_pointer __np = __f->__as_node();
761*58b9f456SAndroid Build Coastguard Worker            __f = __f->__next_;
762*58b9f456SAndroid Build Coastguard Worker            __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
763*58b9f456SAndroid Build Coastguard Worker            __node_alloc_traits::deallocate(__na, __np, 1);
764*58b9f456SAndroid Build Coastguard Worker        }
765*58b9f456SAndroid Build Coastguard Worker        __invalidate_all_iterators();
766*58b9f456SAndroid Build Coastguard Worker    }
767*58b9f456SAndroid Build Coastguard Worker}
768*58b9f456SAndroid Build Coastguard Worker
769*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
770*58b9f456SAndroid Build Coastguard Workervoid
771*58b9f456SAndroid Build Coastguard Worker__list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
772*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER >= 14
773*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_DEBUG
774*58b9f456SAndroid Build Coastguard Worker#else
775*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value ||
776*58b9f456SAndroid Build Coastguard Worker                    __is_nothrow_swappable<allocator_type>::value)
777*58b9f456SAndroid Build Coastguard Worker#endif
778*58b9f456SAndroid Build Coastguard Worker{
779*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__alloc_traits::propagate_on_container_swap::value ||
780*58b9f456SAndroid Build Coastguard Worker                   this->__node_alloc() == __c.__node_alloc(),
781*58b9f456SAndroid Build Coastguard Worker                   "list::swap: Either propagate_on_container_swap must be true"
782*58b9f456SAndroid Build Coastguard Worker                   " or the allocators must compare equal");
783*58b9f456SAndroid Build Coastguard Worker    using _VSTD::swap;
784*58b9f456SAndroid Build Coastguard Worker    __swap_allocator(__node_alloc(), __c.__node_alloc());
785*58b9f456SAndroid Build Coastguard Worker    swap(__sz(), __c.__sz());
786*58b9f456SAndroid Build Coastguard Worker    swap(__end_, __c.__end_);
787*58b9f456SAndroid Build Coastguard Worker    if (__sz() == 0)
788*58b9f456SAndroid Build Coastguard Worker        __end_.__next_ = __end_.__prev_ = __end_as_link();
789*58b9f456SAndroid Build Coastguard Worker    else
790*58b9f456SAndroid Build Coastguard Worker        __end_.__prev_->__next_ = __end_.__next_->__prev_ = __end_as_link();
791*58b9f456SAndroid Build Coastguard Worker    if (__c.__sz() == 0)
792*58b9f456SAndroid Build Coastguard Worker        __c.__end_.__next_ = __c.__end_.__prev_ = __c.__end_as_link();
793*58b9f456SAndroid Build Coastguard Worker    else
794*58b9f456SAndroid Build Coastguard Worker        __c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_ = __c.__end_as_link();
795*58b9f456SAndroid Build Coastguard Worker
796*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
797*58b9f456SAndroid Build Coastguard Worker    __libcpp_db* __db = __get_db();
798*58b9f456SAndroid Build Coastguard Worker    __c_node* __cn1 = __db->__find_c_and_lock(this);
799*58b9f456SAndroid Build Coastguard Worker    __c_node* __cn2 = __db->__find_c(&__c);
800*58b9f456SAndroid Build Coastguard Worker    std::swap(__cn1->beg_, __cn2->beg_);
801*58b9f456SAndroid Build Coastguard Worker    std::swap(__cn1->end_, __cn2->end_);
802*58b9f456SAndroid Build Coastguard Worker    std::swap(__cn1->cap_, __cn2->cap_);
803*58b9f456SAndroid Build Coastguard Worker    for (__i_node** __p = __cn1->end_; __p != __cn1->beg_;)
804*58b9f456SAndroid Build Coastguard Worker    {
805*58b9f456SAndroid Build Coastguard Worker        --__p;
806*58b9f456SAndroid Build Coastguard Worker        const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_);
807*58b9f456SAndroid Build Coastguard Worker        if (__i->__ptr_ == __c.__end_as_link())
808*58b9f456SAndroid Build Coastguard Worker        {
809*58b9f456SAndroid Build Coastguard Worker            __cn2->__add(*__p);
810*58b9f456SAndroid Build Coastguard Worker            if (--__cn1->end_ != __p)
811*58b9f456SAndroid Build Coastguard Worker                memmove(__p, __p+1, (__cn1->end_ - __p)*sizeof(__i_node*));
812*58b9f456SAndroid Build Coastguard Worker        }
813*58b9f456SAndroid Build Coastguard Worker        else
814*58b9f456SAndroid Build Coastguard Worker            (*__p)->__c_ = __cn1;
815*58b9f456SAndroid Build Coastguard Worker    }
816*58b9f456SAndroid Build Coastguard Worker    for (__i_node** __p = __cn2->end_; __p != __cn2->beg_;)
817*58b9f456SAndroid Build Coastguard Worker    {
818*58b9f456SAndroid Build Coastguard Worker        --__p;
819*58b9f456SAndroid Build Coastguard Worker        const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_);
820*58b9f456SAndroid Build Coastguard Worker        if (__i->__ptr_ == __end_as_link())
821*58b9f456SAndroid Build Coastguard Worker        {
822*58b9f456SAndroid Build Coastguard Worker            __cn1->__add(*__p);
823*58b9f456SAndroid Build Coastguard Worker            if (--__cn2->end_ != __p)
824*58b9f456SAndroid Build Coastguard Worker                memmove(__p, __p+1, (__cn2->end_ - __p)*sizeof(__i_node*));
825*58b9f456SAndroid Build Coastguard Worker        }
826*58b9f456SAndroid Build Coastguard Worker        else
827*58b9f456SAndroid Build Coastguard Worker            (*__p)->__c_ = __cn2;
828*58b9f456SAndroid Build Coastguard Worker    }
829*58b9f456SAndroid Build Coastguard Worker    __db->unlock();
830*58b9f456SAndroid Build Coastguard Worker#endif
831*58b9f456SAndroid Build Coastguard Worker}
832*58b9f456SAndroid Build Coastguard Worker
833*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc /*= allocator<_Tp>*/>
834*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS list
835*58b9f456SAndroid Build Coastguard Worker    : private __list_imp<_Tp, _Alloc>
836*58b9f456SAndroid Build Coastguard Worker{
837*58b9f456SAndroid Build Coastguard Worker    typedef __list_imp<_Tp, _Alloc> base;
838*58b9f456SAndroid Build Coastguard Worker    typedef typename base::__node              __node;
839*58b9f456SAndroid Build Coastguard Worker    typedef typename base::__node_allocator    __node_allocator;
840*58b9f456SAndroid Build Coastguard Worker    typedef typename base::__node_pointer      __node_pointer;
841*58b9f456SAndroid Build Coastguard Worker    typedef typename base::__node_alloc_traits __node_alloc_traits;
842*58b9f456SAndroid Build Coastguard Worker    typedef typename base::__node_base         __node_base;
843*58b9f456SAndroid Build Coastguard Worker    typedef typename base::__node_base_pointer __node_base_pointer;
844*58b9f456SAndroid Build Coastguard Worker    typedef typename base::__link_pointer __link_pointer;
845*58b9f456SAndroid Build Coastguard Worker
846*58b9f456SAndroid Build Coastguard Workerpublic:
847*58b9f456SAndroid Build Coastguard Worker    typedef _Tp                                      value_type;
848*58b9f456SAndroid Build Coastguard Worker    typedef _Alloc                                   allocator_type;
849*58b9f456SAndroid Build Coastguard Worker    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
850*58b9f456SAndroid Build Coastguard Worker                  "Invalid allocator::value_type");
851*58b9f456SAndroid Build Coastguard Worker    typedef value_type&                              reference;
852*58b9f456SAndroid Build Coastguard Worker    typedef const value_type&                        const_reference;
853*58b9f456SAndroid Build Coastguard Worker    typedef typename base::pointer                   pointer;
854*58b9f456SAndroid Build Coastguard Worker    typedef typename base::const_pointer             const_pointer;
855*58b9f456SAndroid Build Coastguard Worker    typedef typename base::size_type                 size_type;
856*58b9f456SAndroid Build Coastguard Worker    typedef typename base::difference_type           difference_type;
857*58b9f456SAndroid Build Coastguard Worker    typedef typename base::iterator                  iterator;
858*58b9f456SAndroid Build Coastguard Worker    typedef typename base::const_iterator            const_iterator;
859*58b9f456SAndroid Build Coastguard Worker    typedef _VSTD::reverse_iterator<iterator>         reverse_iterator;
860*58b9f456SAndroid Build Coastguard Worker    typedef _VSTD::reverse_iterator<const_iterator>   const_reverse_iterator;
861*58b9f456SAndroid Build Coastguard Worker
862*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
863*58b9f456SAndroid Build Coastguard Worker    list()
864*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
865*58b9f456SAndroid Build Coastguard Worker    {
866*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
867*58b9f456SAndroid Build Coastguard Worker        __get_db()->__insert_c(this);
868*58b9f456SAndroid Build Coastguard Worker#endif
869*58b9f456SAndroid Build Coastguard Worker    }
870*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
871*58b9f456SAndroid Build Coastguard Worker    explicit list(const allocator_type& __a) : base(__a)
872*58b9f456SAndroid Build Coastguard Worker    {
873*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
874*58b9f456SAndroid Build Coastguard Worker        __get_db()->__insert_c(this);
875*58b9f456SAndroid Build Coastguard Worker#endif
876*58b9f456SAndroid Build Coastguard Worker    }
877*58b9f456SAndroid Build Coastguard Worker    explicit list(size_type __n);
878*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 11
879*58b9f456SAndroid Build Coastguard Worker    explicit list(size_type __n, const allocator_type& __a);
880*58b9f456SAndroid Build Coastguard Worker#endif
881*58b9f456SAndroid Build Coastguard Worker    list(size_type __n, const value_type& __x);
882*58b9f456SAndroid Build Coastguard Worker    list(size_type __n, const value_type& __x, const allocator_type& __a);
883*58b9f456SAndroid Build Coastguard Worker    template <class _InpIter>
884*58b9f456SAndroid Build Coastguard Worker        list(_InpIter __f, _InpIter __l,
885*58b9f456SAndroid Build Coastguard Worker             typename enable_if<__is_input_iterator<_InpIter>::value>::type* = 0);
886*58b9f456SAndroid Build Coastguard Worker    template <class _InpIter>
887*58b9f456SAndroid Build Coastguard Worker        list(_InpIter __f, _InpIter __l, const allocator_type& __a,
888*58b9f456SAndroid Build Coastguard Worker             typename enable_if<__is_input_iterator<_InpIter>::value>::type* = 0);
889*58b9f456SAndroid Build Coastguard Worker
890*58b9f456SAndroid Build Coastguard Worker    list(const list& __c);
891*58b9f456SAndroid Build Coastguard Worker    list(const list& __c, const allocator_type& __a);
892*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
893*58b9f456SAndroid Build Coastguard Worker    list& operator=(const list& __c);
894*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
895*58b9f456SAndroid Build Coastguard Worker    list(initializer_list<value_type> __il);
896*58b9f456SAndroid Build Coastguard Worker    list(initializer_list<value_type> __il, const allocator_type& __a);
897*58b9f456SAndroid Build Coastguard Worker
898*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
899*58b9f456SAndroid Build Coastguard Worker    list(list&& __c)
900*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value);
901*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
902*58b9f456SAndroid Build Coastguard Worker    list(list&& __c, const allocator_type& __a);
903*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
904*58b9f456SAndroid Build Coastguard Worker    list& operator=(list&& __c)
905*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(
906*58b9f456SAndroid Build Coastguard Worker            __node_alloc_traits::propagate_on_container_move_assignment::value &&
907*58b9f456SAndroid Build Coastguard Worker            is_nothrow_move_assignable<__node_allocator>::value);
908*58b9f456SAndroid Build Coastguard Worker
909*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
910*58b9f456SAndroid Build Coastguard Worker    list& operator=(initializer_list<value_type> __il)
911*58b9f456SAndroid Build Coastguard Worker        {assign(__il.begin(), __il.end()); return *this;}
912*58b9f456SAndroid Build Coastguard Worker
913*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
914*58b9f456SAndroid Build Coastguard Worker    void assign(initializer_list<value_type> __il)
915*58b9f456SAndroid Build Coastguard Worker        {assign(__il.begin(), __il.end());}
916*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
917*58b9f456SAndroid Build Coastguard Worker
918*58b9f456SAndroid Build Coastguard Worker    template <class _InpIter>
919*58b9f456SAndroid Build Coastguard Worker        void assign(_InpIter __f, _InpIter __l,
920*58b9f456SAndroid Build Coastguard Worker             typename enable_if<__is_input_iterator<_InpIter>::value>::type* = 0);
921*58b9f456SAndroid Build Coastguard Worker    void assign(size_type __n, const value_type& __x);
922*58b9f456SAndroid Build Coastguard Worker
923*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
924*58b9f456SAndroid Build Coastguard Worker    allocator_type get_allocator() const _NOEXCEPT;
925*58b9f456SAndroid Build Coastguard Worker
926*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
927*58b9f456SAndroid Build Coastguard Worker    size_type size() const _NOEXCEPT     {return base::__sz();}
928*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
929*58b9f456SAndroid Build Coastguard Worker    bool empty() const _NOEXCEPT         {return base::empty();}
930*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
931*58b9f456SAndroid Build Coastguard Worker    size_type max_size() const _NOEXCEPT
932*58b9f456SAndroid Build Coastguard Worker        {
933*58b9f456SAndroid Build Coastguard Worker            return std::min<size_type>(
934*58b9f456SAndroid Build Coastguard Worker                base::__node_alloc_max_size(),
935*58b9f456SAndroid Build Coastguard Worker                numeric_limits<difference_type >::max());
936*58b9f456SAndroid Build Coastguard Worker        }
937*58b9f456SAndroid Build Coastguard Worker
938*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
939*58b9f456SAndroid Build Coastguard Worker          iterator begin() _NOEXCEPT        {return base::begin();}
940*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
941*58b9f456SAndroid Build Coastguard Worker    const_iterator begin()  const _NOEXCEPT {return base::begin();}
942*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
943*58b9f456SAndroid Build Coastguard Worker          iterator end() _NOEXCEPT          {return base::end();}
944*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
945*58b9f456SAndroid Build Coastguard Worker    const_iterator end()    const _NOEXCEPT {return base::end();}
946*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
947*58b9f456SAndroid Build Coastguard Worker    const_iterator cbegin() const _NOEXCEPT {return base::begin();}
948*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
949*58b9f456SAndroid Build Coastguard Worker    const_iterator cend()   const _NOEXCEPT {return base::end();}
950*58b9f456SAndroid Build Coastguard Worker
951*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
952*58b9f456SAndroid Build Coastguard Worker          reverse_iterator rbegin() _NOEXCEPT
953*58b9f456SAndroid Build Coastguard Worker            {return       reverse_iterator(end());}
954*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
955*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator rbegin()  const _NOEXCEPT
956*58b9f456SAndroid Build Coastguard Worker        {return const_reverse_iterator(end());}
957*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
958*58b9f456SAndroid Build Coastguard Worker          reverse_iterator rend() _NOEXCEPT
959*58b9f456SAndroid Build Coastguard Worker            {return       reverse_iterator(begin());}
960*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
961*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator rend()    const _NOEXCEPT
962*58b9f456SAndroid Build Coastguard Worker        {return const_reverse_iterator(begin());}
963*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
964*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator crbegin() const _NOEXCEPT
965*58b9f456SAndroid Build Coastguard Worker        {return const_reverse_iterator(end());}
966*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
967*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator crend()   const _NOEXCEPT
968*58b9f456SAndroid Build Coastguard Worker        {return const_reverse_iterator(begin());}
969*58b9f456SAndroid Build Coastguard Worker
970*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
971*58b9f456SAndroid Build Coastguard Worker    reference front()
972*58b9f456SAndroid Build Coastguard Worker    {
973*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_ASSERT(!empty(), "list::front called on empty list");
974*58b9f456SAndroid Build Coastguard Worker        return base::__end_.__next_->__as_node()->__value_;
975*58b9f456SAndroid Build Coastguard Worker    }
976*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
977*58b9f456SAndroid Build Coastguard Worker    const_reference front() const
978*58b9f456SAndroid Build Coastguard Worker    {
979*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_ASSERT(!empty(), "list::front called on empty list");
980*58b9f456SAndroid Build Coastguard Worker        return base::__end_.__next_->__as_node()->__value_;
981*58b9f456SAndroid Build Coastguard Worker    }
982*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
983*58b9f456SAndroid Build Coastguard Worker    reference back()
984*58b9f456SAndroid Build Coastguard Worker    {
985*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_ASSERT(!empty(), "list::back called on empty list");
986*58b9f456SAndroid Build Coastguard Worker        return base::__end_.__prev_->__as_node()->__value_;
987*58b9f456SAndroid Build Coastguard Worker    }
988*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
989*58b9f456SAndroid Build Coastguard Worker    const_reference back() const
990*58b9f456SAndroid Build Coastguard Worker    {
991*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_ASSERT(!empty(), "list::back called on empty list");
992*58b9f456SAndroid Build Coastguard Worker        return base::__end_.__prev_->__as_node()->__value_;
993*58b9f456SAndroid Build Coastguard Worker    }
994*58b9f456SAndroid Build Coastguard Worker
995*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
996*58b9f456SAndroid Build Coastguard Worker    void push_front(value_type&& __x);
997*58b9f456SAndroid Build Coastguard Worker    void push_back(value_type&& __x);
998*58b9f456SAndroid Build Coastguard Worker
999*58b9f456SAndroid Build Coastguard Worker    template <class... _Args>
1000*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14
1001*58b9f456SAndroid Build Coastguard Worker       reference emplace_front(_Args&&... __args);
1002*58b9f456SAndroid Build Coastguard Worker#else
1003*58b9f456SAndroid Build Coastguard Worker       void      emplace_front(_Args&&... __args);
1004*58b9f456SAndroid Build Coastguard Worker#endif
1005*58b9f456SAndroid Build Coastguard Worker    template <class... _Args>
1006*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14
1007*58b9f456SAndroid Build Coastguard Worker        reference emplace_back(_Args&&... __args);
1008*58b9f456SAndroid Build Coastguard Worker#else
1009*58b9f456SAndroid Build Coastguard Worker       void       emplace_back(_Args&&... __args);
1010*58b9f456SAndroid Build Coastguard Worker#endif
1011*58b9f456SAndroid Build Coastguard Worker    template <class... _Args>
1012*58b9f456SAndroid Build Coastguard Worker        iterator emplace(const_iterator __p, _Args&&... __args);
1013*58b9f456SAndroid Build Coastguard Worker
1014*58b9f456SAndroid Build Coastguard Worker    iterator insert(const_iterator __p, value_type&& __x);
1015*58b9f456SAndroid Build Coastguard Worker
1016*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1017*58b9f456SAndroid Build Coastguard Worker    iterator insert(const_iterator __p, initializer_list<value_type> __il)
1018*58b9f456SAndroid Build Coastguard Worker        {return insert(__p, __il.begin(), __il.end());}
1019*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
1020*58b9f456SAndroid Build Coastguard Worker
1021*58b9f456SAndroid Build Coastguard Worker    void push_front(const value_type& __x);
1022*58b9f456SAndroid Build Coastguard Worker    void push_back(const value_type& __x);
1023*58b9f456SAndroid Build Coastguard Worker
1024*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1025*58b9f456SAndroid Build Coastguard Worker    template <class _Arg>
1026*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1027*58b9f456SAndroid Build Coastguard Worker    void __emplace_back(_Arg&& __arg) { emplace_back(_VSTD::forward<_Arg>(__arg)); }
1028*58b9f456SAndroid Build Coastguard Worker#else
1029*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1030*58b9f456SAndroid Build Coastguard Worker    void __emplace_back(value_type const& __arg) { push_back(__arg); }
1031*58b9f456SAndroid Build Coastguard Worker#endif
1032*58b9f456SAndroid Build Coastguard Worker
1033*58b9f456SAndroid Build Coastguard Worker    iterator insert(const_iterator __p, const value_type& __x);
1034*58b9f456SAndroid Build Coastguard Worker    iterator insert(const_iterator __p, size_type __n, const value_type& __x);
1035*58b9f456SAndroid Build Coastguard Worker    template <class _InpIter>
1036*58b9f456SAndroid Build Coastguard Worker        iterator insert(const_iterator __p, _InpIter __f, _InpIter __l,
1037*58b9f456SAndroid Build Coastguard Worker             typename enable_if<__is_input_iterator<_InpIter>::value>::type* = 0);
1038*58b9f456SAndroid Build Coastguard Worker
1039*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1040*58b9f456SAndroid Build Coastguard Worker    void swap(list& __c)
1041*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER >= 14
1042*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_DEBUG
1043*58b9f456SAndroid Build Coastguard Worker#else
1044*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_DEBUG_(!__node_alloc_traits::propagate_on_container_swap::value ||
1045*58b9f456SAndroid Build Coastguard Worker                   __is_nothrow_swappable<__node_allocator>::value)
1046*58b9f456SAndroid Build Coastguard Worker#endif
1047*58b9f456SAndroid Build Coastguard Worker        {base::swap(__c);}
1048*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1049*58b9f456SAndroid Build Coastguard Worker    void clear() _NOEXCEPT {base::clear();}
1050*58b9f456SAndroid Build Coastguard Worker
1051*58b9f456SAndroid Build Coastguard Worker    void pop_front();
1052*58b9f456SAndroid Build Coastguard Worker    void pop_back();
1053*58b9f456SAndroid Build Coastguard Worker
1054*58b9f456SAndroid Build Coastguard Worker    iterator erase(const_iterator __p);
1055*58b9f456SAndroid Build Coastguard Worker    iterator erase(const_iterator __f, const_iterator __l);
1056*58b9f456SAndroid Build Coastguard Worker
1057*58b9f456SAndroid Build Coastguard Worker    void resize(size_type __n);
1058*58b9f456SAndroid Build Coastguard Worker    void resize(size_type __n, const value_type& __x);
1059*58b9f456SAndroid Build Coastguard Worker
1060*58b9f456SAndroid Build Coastguard Worker    void splice(const_iterator __p, list& __c);
1061*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1062*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1063*58b9f456SAndroid Build Coastguard Worker    void splice(const_iterator __p, list&& __c) {splice(__p, __c);}
1064*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1065*58b9f456SAndroid Build Coastguard Worker    void splice(const_iterator __p, list&& __c, const_iterator __i)
1066*58b9f456SAndroid Build Coastguard Worker        {splice(__p, __c, __i);}
1067*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1068*58b9f456SAndroid Build Coastguard Worker    void splice(const_iterator __p, list&& __c, const_iterator __f, const_iterator __l)
1069*58b9f456SAndroid Build Coastguard Worker        {splice(__p, __c, __f, __l);}
1070*58b9f456SAndroid Build Coastguard Worker#endif
1071*58b9f456SAndroid Build Coastguard Worker    void splice(const_iterator __p, list& __c, const_iterator __i);
1072*58b9f456SAndroid Build Coastguard Worker    void splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l);
1073*58b9f456SAndroid Build Coastguard Worker
1074*58b9f456SAndroid Build Coastguard Worker    void remove(const value_type& __x);
1075*58b9f456SAndroid Build Coastguard Worker    template <class _Pred> void remove_if(_Pred __pred);
1076*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1077*58b9f456SAndroid Build Coastguard Worker    void unique();
1078*58b9f456SAndroid Build Coastguard Worker    template <class _BinaryPred>
1079*58b9f456SAndroid Build Coastguard Worker        void unique(_BinaryPred __binary_pred);
1080*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1081*58b9f456SAndroid Build Coastguard Worker    void merge(list& __c);
1082*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1083*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1084*58b9f456SAndroid Build Coastguard Worker    void merge(list&& __c) {merge(__c);}
1085*58b9f456SAndroid Build Coastguard Worker
1086*58b9f456SAndroid Build Coastguard Worker    template <class _Comp>
1087*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1088*58b9f456SAndroid Build Coastguard Worker        void merge(list&& __c, _Comp __comp) {merge(__c, __comp);}
1089*58b9f456SAndroid Build Coastguard Worker#endif
1090*58b9f456SAndroid Build Coastguard Worker    template <class _Comp>
1091*58b9f456SAndroid Build Coastguard Worker        void merge(list& __c, _Comp __comp);
1092*58b9f456SAndroid Build Coastguard Worker
1093*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1094*58b9f456SAndroid Build Coastguard Worker    void sort();
1095*58b9f456SAndroid Build Coastguard Worker    template <class _Comp>
1096*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
1097*58b9f456SAndroid Build Coastguard Worker        void sort(_Comp __comp);
1098*58b9f456SAndroid Build Coastguard Worker
1099*58b9f456SAndroid Build Coastguard Worker    void reverse() _NOEXCEPT;
1100*58b9f456SAndroid Build Coastguard Worker
1101*58b9f456SAndroid Build Coastguard Worker    bool __invariants() const;
1102*58b9f456SAndroid Build Coastguard Worker
1103*58b9f456SAndroid Build Coastguard Worker    typedef __allocator_destructor<__node_allocator> __node_destructor;
1104*58b9f456SAndroid Build Coastguard Worker    typedef unique_ptr<__node, __node_destructor> __hold_pointer;
1105*58b9f456SAndroid Build Coastguard Worker
1106*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1107*58b9f456SAndroid Build Coastguard Worker    __hold_pointer __allocate_node(__node_allocator& __na) {
1108*58b9f456SAndroid Build Coastguard Worker      __node_pointer __p = __node_alloc_traits::allocate(__na, 1);
1109*58b9f456SAndroid Build Coastguard Worker      __p->__prev_ = nullptr;
1110*58b9f456SAndroid Build Coastguard Worker      return __hold_pointer(__p, __node_destructor(__na, 1));
1111*58b9f456SAndroid Build Coastguard Worker    }
1112*58b9f456SAndroid Build Coastguard Worker
1113*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1114*58b9f456SAndroid Build Coastguard Worker
1115*58b9f456SAndroid Build Coastguard Worker    bool __dereferenceable(const const_iterator* __i) const;
1116*58b9f456SAndroid Build Coastguard Worker    bool __decrementable(const const_iterator* __i) const;
1117*58b9f456SAndroid Build Coastguard Worker    bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
1118*58b9f456SAndroid Build Coastguard Worker    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
1119*58b9f456SAndroid Build Coastguard Worker
1120*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_DEBUG_LEVEL >= 2
1121*58b9f456SAndroid Build Coastguard Worker
1122*58b9f456SAndroid Build Coastguard Workerprivate:
1123*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1124*58b9f456SAndroid Build Coastguard Worker    static void __link_nodes  (__link_pointer __p, __link_pointer __f, __link_pointer __l);
1125*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1126*58b9f456SAndroid Build Coastguard Worker    void __link_nodes_at_front(__link_pointer __f, __link_pointer __l);
1127*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1128*58b9f456SAndroid Build Coastguard Worker    void __link_nodes_at_back (__link_pointer __f, __link_pointer __l);
1129*58b9f456SAndroid Build Coastguard Worker    iterator __iterator(size_type __n);
1130*58b9f456SAndroid Build Coastguard Worker    template <class _Comp>
1131*58b9f456SAndroid Build Coastguard Worker        static iterator __sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp);
1132*58b9f456SAndroid Build Coastguard Worker
1133*58b9f456SAndroid Build Coastguard Worker    void __move_assign(list& __c, true_type)
1134*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value);
1135*58b9f456SAndroid Build Coastguard Worker    void __move_assign(list& __c, false_type);
1136*58b9f456SAndroid Build Coastguard Worker};
1137*58b9f456SAndroid Build Coastguard Worker
1138*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
1139*58b9f456SAndroid Build Coastguard Workertemplate<class _InputIterator,
1140*58b9f456SAndroid Build Coastguard Worker         class _Alloc = typename std::allocator<typename iterator_traits<_InputIterator>::value_type>,
1141*58b9f456SAndroid Build Coastguard Worker         class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
1142*58b9f456SAndroid Build Coastguard Worker         >
1143*58b9f456SAndroid Build Coastguard Workerlist(_InputIterator, _InputIterator)
1144*58b9f456SAndroid Build Coastguard Worker  -> list<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
1145*58b9f456SAndroid Build Coastguard Worker
1146*58b9f456SAndroid Build Coastguard Workertemplate<class _InputIterator,
1147*58b9f456SAndroid Build Coastguard Worker         class _Alloc,
1148*58b9f456SAndroid Build Coastguard Worker         class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
1149*58b9f456SAndroid Build Coastguard Worker         >
1150*58b9f456SAndroid Build Coastguard Workerlist(_InputIterator, _InputIterator, _Alloc)
1151*58b9f456SAndroid Build Coastguard Worker  -> list<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
1152*58b9f456SAndroid Build Coastguard Worker#endif
1153*58b9f456SAndroid Build Coastguard Worker
1154*58b9f456SAndroid Build Coastguard Worker// Link in nodes [__f, __l] just prior to __p
1155*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1156*58b9f456SAndroid Build Coastguard Workerinline
1157*58b9f456SAndroid Build Coastguard Workervoid
1158*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::__link_nodes(__link_pointer __p, __link_pointer __f, __link_pointer __l)
1159*58b9f456SAndroid Build Coastguard Worker{
1160*58b9f456SAndroid Build Coastguard Worker    __p->__prev_->__next_ = __f;
1161*58b9f456SAndroid Build Coastguard Worker    __f->__prev_ = __p->__prev_;
1162*58b9f456SAndroid Build Coastguard Worker    __p->__prev_ = __l;
1163*58b9f456SAndroid Build Coastguard Worker    __l->__next_ = __p;
1164*58b9f456SAndroid Build Coastguard Worker}
1165*58b9f456SAndroid Build Coastguard Worker
1166*58b9f456SAndroid Build Coastguard Worker// Link in nodes [__f, __l] at the front of the list
1167*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1168*58b9f456SAndroid Build Coastguard Workerinline
1169*58b9f456SAndroid Build Coastguard Workervoid
1170*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::__link_nodes_at_front(__link_pointer __f, __link_pointer __l)
1171*58b9f456SAndroid Build Coastguard Worker{
1172*58b9f456SAndroid Build Coastguard Worker    __f->__prev_ = base::__end_as_link();
1173*58b9f456SAndroid Build Coastguard Worker    __l->__next_ = base::__end_.__next_;
1174*58b9f456SAndroid Build Coastguard Worker    __l->__next_->__prev_ = __l;
1175*58b9f456SAndroid Build Coastguard Worker    base::__end_.__next_ = __f;
1176*58b9f456SAndroid Build Coastguard Worker}
1177*58b9f456SAndroid Build Coastguard Worker
1178*58b9f456SAndroid Build Coastguard Worker// Link in nodes [__f, __l] at the back of the list
1179*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1180*58b9f456SAndroid Build Coastguard Workerinline
1181*58b9f456SAndroid Build Coastguard Workervoid
1182*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::__link_nodes_at_back(__link_pointer __f, __link_pointer __l)
1183*58b9f456SAndroid Build Coastguard Worker{
1184*58b9f456SAndroid Build Coastguard Worker    __l->__next_ = base::__end_as_link();
1185*58b9f456SAndroid Build Coastguard Worker    __f->__prev_ = base::__end_.__prev_;
1186*58b9f456SAndroid Build Coastguard Worker    __f->__prev_->__next_ = __f;
1187*58b9f456SAndroid Build Coastguard Worker    base::__end_.__prev_ = __l;
1188*58b9f456SAndroid Build Coastguard Worker}
1189*58b9f456SAndroid Build Coastguard Worker
1190*58b9f456SAndroid Build Coastguard Worker
1191*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1192*58b9f456SAndroid Build Coastguard Workerinline
1193*58b9f456SAndroid Build Coastguard Workertypename list<_Tp, _Alloc>::iterator
1194*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::__iterator(size_type __n)
1195*58b9f456SAndroid Build Coastguard Worker{
1196*58b9f456SAndroid Build Coastguard Worker    return __n <= base::__sz() / 2 ? _VSTD::next(begin(), __n)
1197*58b9f456SAndroid Build Coastguard Worker                                   : _VSTD::prev(end(), base::__sz() - __n);
1198*58b9f456SAndroid Build Coastguard Worker}
1199*58b9f456SAndroid Build Coastguard Worker
1200*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1201*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::list(size_type __n)
1202*58b9f456SAndroid Build Coastguard Worker{
1203*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1204*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1205*58b9f456SAndroid Build Coastguard Worker#endif
1206*58b9f456SAndroid Build Coastguard Worker    for (; __n > 0; --__n)
1207*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1208*58b9f456SAndroid Build Coastguard Worker        emplace_back();
1209*58b9f456SAndroid Build Coastguard Worker#else
1210*58b9f456SAndroid Build Coastguard Worker        push_back(value_type());
1211*58b9f456SAndroid Build Coastguard Worker#endif
1212*58b9f456SAndroid Build Coastguard Worker}
1213*58b9f456SAndroid Build Coastguard Worker
1214*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 11
1215*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1216*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : base(__a)
1217*58b9f456SAndroid Build Coastguard Worker{
1218*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1219*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1220*58b9f456SAndroid Build Coastguard Worker#endif
1221*58b9f456SAndroid Build Coastguard Worker    for (; __n > 0; --__n)
1222*58b9f456SAndroid Build Coastguard Worker        emplace_back();
1223*58b9f456SAndroid Build Coastguard Worker}
1224*58b9f456SAndroid Build Coastguard Worker#endif
1225*58b9f456SAndroid Build Coastguard Worker
1226*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1227*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::list(size_type __n, const value_type& __x)
1228*58b9f456SAndroid Build Coastguard Worker{
1229*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1230*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1231*58b9f456SAndroid Build Coastguard Worker#endif
1232*58b9f456SAndroid Build Coastguard Worker    for (; __n > 0; --__n)
1233*58b9f456SAndroid Build Coastguard Worker        push_back(__x);
1234*58b9f456SAndroid Build Coastguard Worker}
1235*58b9f456SAndroid Build Coastguard Worker
1236*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1237*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::list(size_type __n, const value_type& __x, const allocator_type& __a)
1238*58b9f456SAndroid Build Coastguard Worker    : base(__a)
1239*58b9f456SAndroid Build Coastguard Worker{
1240*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1241*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1242*58b9f456SAndroid Build Coastguard Worker#endif
1243*58b9f456SAndroid Build Coastguard Worker    for (; __n > 0; --__n)
1244*58b9f456SAndroid Build Coastguard Worker        push_back(__x);
1245*58b9f456SAndroid Build Coastguard Worker}
1246*58b9f456SAndroid Build Coastguard Worker
1247*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1248*58b9f456SAndroid Build Coastguard Workertemplate <class _InpIter>
1249*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l,
1250*58b9f456SAndroid Build Coastguard Worker                        typename enable_if<__is_input_iterator<_InpIter>::value>::type*)
1251*58b9f456SAndroid Build Coastguard Worker{
1252*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1253*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1254*58b9f456SAndroid Build Coastguard Worker#endif
1255*58b9f456SAndroid Build Coastguard Worker    for (; __f != __l; ++__f)
1256*58b9f456SAndroid Build Coastguard Worker        __emplace_back(*__f);
1257*58b9f456SAndroid Build Coastguard Worker}
1258*58b9f456SAndroid Build Coastguard Worker
1259*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1260*58b9f456SAndroid Build Coastguard Workertemplate <class _InpIter>
1261*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a,
1262*58b9f456SAndroid Build Coastguard Worker                        typename enable_if<__is_input_iterator<_InpIter>::value>::type*)
1263*58b9f456SAndroid Build Coastguard Worker    : base(__a)
1264*58b9f456SAndroid Build Coastguard Worker{
1265*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1266*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1267*58b9f456SAndroid Build Coastguard Worker#endif
1268*58b9f456SAndroid Build Coastguard Worker    for (; __f != __l; ++__f)
1269*58b9f456SAndroid Build Coastguard Worker        __emplace_back(*__f);
1270*58b9f456SAndroid Build Coastguard Worker}
1271*58b9f456SAndroid Build Coastguard Worker
1272*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1273*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::list(const list& __c)
1274*58b9f456SAndroid Build Coastguard Worker    : base(__node_alloc_traits::select_on_container_copy_construction(
1275*58b9f456SAndroid Build Coastguard Worker          __c.__node_alloc())) {
1276*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1277*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1278*58b9f456SAndroid Build Coastguard Worker#endif
1279*58b9f456SAndroid Build Coastguard Worker    for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i)
1280*58b9f456SAndroid Build Coastguard Worker        push_back(*__i);
1281*58b9f456SAndroid Build Coastguard Worker}
1282*58b9f456SAndroid Build Coastguard Worker
1283*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1284*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::list(const list& __c, const allocator_type& __a)
1285*58b9f456SAndroid Build Coastguard Worker    : base(__a)
1286*58b9f456SAndroid Build Coastguard Worker{
1287*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1288*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1289*58b9f456SAndroid Build Coastguard Worker#endif
1290*58b9f456SAndroid Build Coastguard Worker    for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i)
1291*58b9f456SAndroid Build Coastguard Worker        push_back(*__i);
1292*58b9f456SAndroid Build Coastguard Worker}
1293*58b9f456SAndroid Build Coastguard Worker
1294*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1295*58b9f456SAndroid Build Coastguard Worker
1296*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1297*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::list(initializer_list<value_type> __il, const allocator_type& __a)
1298*58b9f456SAndroid Build Coastguard Worker    : base(__a)
1299*58b9f456SAndroid Build Coastguard Worker{
1300*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1301*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1302*58b9f456SAndroid Build Coastguard Worker#endif
1303*58b9f456SAndroid Build Coastguard Worker    for (typename initializer_list<value_type>::const_iterator __i = __il.begin(),
1304*58b9f456SAndroid Build Coastguard Worker            __e = __il.end(); __i != __e; ++__i)
1305*58b9f456SAndroid Build Coastguard Worker        push_back(*__i);
1306*58b9f456SAndroid Build Coastguard Worker}
1307*58b9f456SAndroid Build Coastguard Worker
1308*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1309*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::list(initializer_list<value_type> __il)
1310*58b9f456SAndroid Build Coastguard Worker{
1311*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1312*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1313*58b9f456SAndroid Build Coastguard Worker#endif
1314*58b9f456SAndroid Build Coastguard Worker    for (typename initializer_list<value_type>::const_iterator __i = __il.begin(),
1315*58b9f456SAndroid Build Coastguard Worker            __e = __il.end(); __i != __e; ++__i)
1316*58b9f456SAndroid Build Coastguard Worker        push_back(*__i);
1317*58b9f456SAndroid Build Coastguard Worker}
1318*58b9f456SAndroid Build Coastguard Worker
1319*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1320*58b9f456SAndroid Build Coastguard Workerinline list<_Tp, _Alloc>::list(list&& __c)
1321*58b9f456SAndroid Build Coastguard Worker    _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value)
1322*58b9f456SAndroid Build Coastguard Worker    : base(_VSTD::move(__c.__node_alloc())) {
1323*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1324*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1325*58b9f456SAndroid Build Coastguard Worker#endif
1326*58b9f456SAndroid Build Coastguard Worker    splice(end(), __c);
1327*58b9f456SAndroid Build Coastguard Worker}
1328*58b9f456SAndroid Build Coastguard Worker
1329*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1330*58b9f456SAndroid Build Coastguard Workerinline
1331*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::list(list&& __c, const allocator_type& __a)
1332*58b9f456SAndroid Build Coastguard Worker    : base(__a)
1333*58b9f456SAndroid Build Coastguard Worker{
1334*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1335*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1336*58b9f456SAndroid Build Coastguard Worker#endif
1337*58b9f456SAndroid Build Coastguard Worker    if (__a == __c.get_allocator())
1338*58b9f456SAndroid Build Coastguard Worker        splice(end(), __c);
1339*58b9f456SAndroid Build Coastguard Worker    else
1340*58b9f456SAndroid Build Coastguard Worker    {
1341*58b9f456SAndroid Build Coastguard Worker        typedef move_iterator<iterator> _Ip;
1342*58b9f456SAndroid Build Coastguard Worker        assign(_Ip(__c.begin()), _Ip(__c.end()));
1343*58b9f456SAndroid Build Coastguard Worker    }
1344*58b9f456SAndroid Build Coastguard Worker}
1345*58b9f456SAndroid Build Coastguard Worker
1346*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1347*58b9f456SAndroid Build Coastguard Workerinline
1348*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>&
1349*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::operator=(list&& __c)
1350*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(
1351*58b9f456SAndroid Build Coastguard Worker            __node_alloc_traits::propagate_on_container_move_assignment::value &&
1352*58b9f456SAndroid Build Coastguard Worker            is_nothrow_move_assignable<__node_allocator>::value)
1353*58b9f456SAndroid Build Coastguard Worker{
1354*58b9f456SAndroid Build Coastguard Worker    __move_assign(__c, integral_constant<bool,
1355*58b9f456SAndroid Build Coastguard Worker          __node_alloc_traits::propagate_on_container_move_assignment::value>());
1356*58b9f456SAndroid Build Coastguard Worker    return *this;
1357*58b9f456SAndroid Build Coastguard Worker}
1358*58b9f456SAndroid Build Coastguard Worker
1359*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1360*58b9f456SAndroid Build Coastguard Workervoid
1361*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::__move_assign(list& __c, false_type)
1362*58b9f456SAndroid Build Coastguard Worker{
1363*58b9f456SAndroid Build Coastguard Worker    if (base::__node_alloc() != __c.__node_alloc())
1364*58b9f456SAndroid Build Coastguard Worker    {
1365*58b9f456SAndroid Build Coastguard Worker        typedef move_iterator<iterator> _Ip;
1366*58b9f456SAndroid Build Coastguard Worker        assign(_Ip(__c.begin()), _Ip(__c.end()));
1367*58b9f456SAndroid Build Coastguard Worker    }
1368*58b9f456SAndroid Build Coastguard Worker    else
1369*58b9f456SAndroid Build Coastguard Worker        __move_assign(__c, true_type());
1370*58b9f456SAndroid Build Coastguard Worker}
1371*58b9f456SAndroid Build Coastguard Worker
1372*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1373*58b9f456SAndroid Build Coastguard Workervoid
1374*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::__move_assign(list& __c, true_type)
1375*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value)
1376*58b9f456SAndroid Build Coastguard Worker{
1377*58b9f456SAndroid Build Coastguard Worker    clear();
1378*58b9f456SAndroid Build Coastguard Worker    base::__move_assign_alloc(__c);
1379*58b9f456SAndroid Build Coastguard Worker    splice(end(), __c);
1380*58b9f456SAndroid Build Coastguard Worker}
1381*58b9f456SAndroid Build Coastguard Worker
1382*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
1383*58b9f456SAndroid Build Coastguard Worker
1384*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1385*58b9f456SAndroid Build Coastguard Workerinline
1386*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>&
1387*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::operator=(const list& __c)
1388*58b9f456SAndroid Build Coastguard Worker{
1389*58b9f456SAndroid Build Coastguard Worker    if (this != &__c)
1390*58b9f456SAndroid Build Coastguard Worker    {
1391*58b9f456SAndroid Build Coastguard Worker        base::__copy_assign_alloc(__c);
1392*58b9f456SAndroid Build Coastguard Worker        assign(__c.begin(), __c.end());
1393*58b9f456SAndroid Build Coastguard Worker    }
1394*58b9f456SAndroid Build Coastguard Worker    return *this;
1395*58b9f456SAndroid Build Coastguard Worker}
1396*58b9f456SAndroid Build Coastguard Worker
1397*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1398*58b9f456SAndroid Build Coastguard Workertemplate <class _InpIter>
1399*58b9f456SAndroid Build Coastguard Workervoid
1400*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l,
1401*58b9f456SAndroid Build Coastguard Worker                          typename enable_if<__is_input_iterator<_InpIter>::value>::type*)
1402*58b9f456SAndroid Build Coastguard Worker{
1403*58b9f456SAndroid Build Coastguard Worker    iterator __i = begin();
1404*58b9f456SAndroid Build Coastguard Worker    iterator __e = end();
1405*58b9f456SAndroid Build Coastguard Worker    for (; __f != __l && __i != __e; ++__f, ++__i)
1406*58b9f456SAndroid Build Coastguard Worker        *__i = *__f;
1407*58b9f456SAndroid Build Coastguard Worker    if (__i == __e)
1408*58b9f456SAndroid Build Coastguard Worker        insert(__e, __f, __l);
1409*58b9f456SAndroid Build Coastguard Worker    else
1410*58b9f456SAndroid Build Coastguard Worker        erase(__i, __e);
1411*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1412*58b9f456SAndroid Build Coastguard Worker      __get_db()->__invalidate_all(this);
1413*58b9f456SAndroid Build Coastguard Worker#endif
1414*58b9f456SAndroid Build Coastguard Worker}
1415*58b9f456SAndroid Build Coastguard Worker
1416*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1417*58b9f456SAndroid Build Coastguard Workervoid
1418*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::assign(size_type __n, const value_type& __x)
1419*58b9f456SAndroid Build Coastguard Worker{
1420*58b9f456SAndroid Build Coastguard Worker    iterator __i = begin();
1421*58b9f456SAndroid Build Coastguard Worker    iterator __e = end();
1422*58b9f456SAndroid Build Coastguard Worker    for (; __n > 0 && __i != __e; --__n, ++__i)
1423*58b9f456SAndroid Build Coastguard Worker        *__i = __x;
1424*58b9f456SAndroid Build Coastguard Worker    if (__i == __e)
1425*58b9f456SAndroid Build Coastguard Worker        insert(__e, __n, __x);
1426*58b9f456SAndroid Build Coastguard Worker    else
1427*58b9f456SAndroid Build Coastguard Worker        erase(__i, __e);
1428*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1429*58b9f456SAndroid Build Coastguard Worker      __get_db()->__invalidate_all(this);
1430*58b9f456SAndroid Build Coastguard Worker#endif
1431*58b9f456SAndroid Build Coastguard Worker}
1432*58b9f456SAndroid Build Coastguard Worker
1433*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1434*58b9f456SAndroid Build Coastguard Workerinline
1435*58b9f456SAndroid Build Coastguard Worker_Alloc
1436*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::get_allocator() const _NOEXCEPT
1437*58b9f456SAndroid Build Coastguard Worker{
1438*58b9f456SAndroid Build Coastguard Worker    return allocator_type(base::__node_alloc());
1439*58b9f456SAndroid Build Coastguard Worker}
1440*58b9f456SAndroid Build Coastguard Worker
1441*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1442*58b9f456SAndroid Build Coastguard Workertypename list<_Tp, _Alloc>::iterator
1443*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x)
1444*58b9f456SAndroid Build Coastguard Worker{
1445*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1446*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
1447*58b9f456SAndroid Build Coastguard Worker        "list::insert(iterator, x) called with an iterator not"
1448*58b9f456SAndroid Build Coastguard Worker        " referring to this list");
1449*58b9f456SAndroid Build Coastguard Worker#endif
1450*58b9f456SAndroid Build Coastguard Worker    __node_allocator& __na = base::__node_alloc();
1451*58b9f456SAndroid Build Coastguard Worker    __hold_pointer __hold = __allocate_node(__na);
1452*58b9f456SAndroid Build Coastguard Worker    __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
1453*58b9f456SAndroid Build Coastguard Worker    __link_nodes(__p.__ptr_, __hold->__as_link(), __hold->__as_link());
1454*58b9f456SAndroid Build Coastguard Worker    ++base::__sz();
1455*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1456*58b9f456SAndroid Build Coastguard Worker    return iterator(__hold.release()->__as_link(), this);
1457*58b9f456SAndroid Build Coastguard Worker#else
1458*58b9f456SAndroid Build Coastguard Worker    return iterator(__hold.release()->__as_link());
1459*58b9f456SAndroid Build Coastguard Worker#endif
1460*58b9f456SAndroid Build Coastguard Worker}
1461*58b9f456SAndroid Build Coastguard Worker
1462*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1463*58b9f456SAndroid Build Coastguard Workertypename list<_Tp, _Alloc>::iterator
1464*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& __x)
1465*58b9f456SAndroid Build Coastguard Worker{
1466*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1467*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
1468*58b9f456SAndroid Build Coastguard Worker        "list::insert(iterator, n, x) called with an iterator not"
1469*58b9f456SAndroid Build Coastguard Worker        " referring to this list");
1470*58b9f456SAndroid Build Coastguard Worker    iterator __r(__p.__ptr_, this);
1471*58b9f456SAndroid Build Coastguard Worker#else
1472*58b9f456SAndroid Build Coastguard Worker    iterator __r(__p.__ptr_);
1473*58b9f456SAndroid Build Coastguard Worker#endif
1474*58b9f456SAndroid Build Coastguard Worker    if (__n > 0)
1475*58b9f456SAndroid Build Coastguard Worker    {
1476*58b9f456SAndroid Build Coastguard Worker        size_type __ds = 0;
1477*58b9f456SAndroid Build Coastguard Worker        __node_allocator& __na = base::__node_alloc();
1478*58b9f456SAndroid Build Coastguard Worker        __hold_pointer __hold = __allocate_node(__na);
1479*58b9f456SAndroid Build Coastguard Worker        __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
1480*58b9f456SAndroid Build Coastguard Worker        ++__ds;
1481*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1482*58b9f456SAndroid Build Coastguard Worker        __r = iterator(__hold->__as_link(), this);
1483*58b9f456SAndroid Build Coastguard Worker#else
1484*58b9f456SAndroid Build Coastguard Worker        __r = iterator(__hold->__as_link());
1485*58b9f456SAndroid Build Coastguard Worker#endif
1486*58b9f456SAndroid Build Coastguard Worker        __hold.release();
1487*58b9f456SAndroid Build Coastguard Worker        iterator __e = __r;
1488*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1489*58b9f456SAndroid Build Coastguard Worker        try
1490*58b9f456SAndroid Build Coastguard Worker        {
1491*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1492*58b9f456SAndroid Build Coastguard Worker            for (--__n; __n != 0; --__n, ++__e, ++__ds)
1493*58b9f456SAndroid Build Coastguard Worker            {
1494*58b9f456SAndroid Build Coastguard Worker                __hold.reset(__node_alloc_traits::allocate(__na, 1));
1495*58b9f456SAndroid Build Coastguard Worker                __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
1496*58b9f456SAndroid Build Coastguard Worker                __e.__ptr_->__next_ = __hold->__as_link();
1497*58b9f456SAndroid Build Coastguard Worker                __hold->__prev_ = __e.__ptr_;
1498*58b9f456SAndroid Build Coastguard Worker                __hold.release();
1499*58b9f456SAndroid Build Coastguard Worker            }
1500*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1501*58b9f456SAndroid Build Coastguard Worker        }
1502*58b9f456SAndroid Build Coastguard Worker        catch (...)
1503*58b9f456SAndroid Build Coastguard Worker        {
1504*58b9f456SAndroid Build Coastguard Worker            while (true)
1505*58b9f456SAndroid Build Coastguard Worker            {
1506*58b9f456SAndroid Build Coastguard Worker                __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e));
1507*58b9f456SAndroid Build Coastguard Worker                __link_pointer __prev = __e.__ptr_->__prev_;
1508*58b9f456SAndroid Build Coastguard Worker                __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
1509*58b9f456SAndroid Build Coastguard Worker                if (__prev == 0)
1510*58b9f456SAndroid Build Coastguard Worker                    break;
1511*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1512*58b9f456SAndroid Build Coastguard Worker                __e = iterator(__prev, this);
1513*58b9f456SAndroid Build Coastguard Worker#else
1514*58b9f456SAndroid Build Coastguard Worker                __e = iterator(__prev);
1515*58b9f456SAndroid Build Coastguard Worker#endif
1516*58b9f456SAndroid Build Coastguard Worker            }
1517*58b9f456SAndroid Build Coastguard Worker            throw;
1518*58b9f456SAndroid Build Coastguard Worker        }
1519*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1520*58b9f456SAndroid Build Coastguard Worker        __link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_);
1521*58b9f456SAndroid Build Coastguard Worker        base::__sz() += __ds;
1522*58b9f456SAndroid Build Coastguard Worker    }
1523*58b9f456SAndroid Build Coastguard Worker    return __r;
1524*58b9f456SAndroid Build Coastguard Worker}
1525*58b9f456SAndroid Build Coastguard Worker
1526*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1527*58b9f456SAndroid Build Coastguard Workertemplate <class _InpIter>
1528*58b9f456SAndroid Build Coastguard Workertypename list<_Tp, _Alloc>::iterator
1529*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,
1530*58b9f456SAndroid Build Coastguard Worker             typename enable_if<__is_input_iterator<_InpIter>::value>::type*)
1531*58b9f456SAndroid Build Coastguard Worker{
1532*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1533*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
1534*58b9f456SAndroid Build Coastguard Worker        "list::insert(iterator, range) called with an iterator not"
1535*58b9f456SAndroid Build Coastguard Worker        " referring to this list");
1536*58b9f456SAndroid Build Coastguard Worker    iterator __r(__p.__ptr_, this);
1537*58b9f456SAndroid Build Coastguard Worker#else
1538*58b9f456SAndroid Build Coastguard Worker    iterator __r(__p.__ptr_);
1539*58b9f456SAndroid Build Coastguard Worker#endif
1540*58b9f456SAndroid Build Coastguard Worker    if (__f != __l)
1541*58b9f456SAndroid Build Coastguard Worker    {
1542*58b9f456SAndroid Build Coastguard Worker        size_type __ds = 0;
1543*58b9f456SAndroid Build Coastguard Worker        __node_allocator& __na = base::__node_alloc();
1544*58b9f456SAndroid Build Coastguard Worker        __hold_pointer __hold = __allocate_node(__na);
1545*58b9f456SAndroid Build Coastguard Worker        __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), *__f);
1546*58b9f456SAndroid Build Coastguard Worker        ++__ds;
1547*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1548*58b9f456SAndroid Build Coastguard Worker        __r = iterator(__hold.get()->__as_link(), this);
1549*58b9f456SAndroid Build Coastguard Worker#else
1550*58b9f456SAndroid Build Coastguard Worker        __r = iterator(__hold.get()->__as_link());
1551*58b9f456SAndroid Build Coastguard Worker#endif
1552*58b9f456SAndroid Build Coastguard Worker        __hold.release();
1553*58b9f456SAndroid Build Coastguard Worker        iterator __e = __r;
1554*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1555*58b9f456SAndroid Build Coastguard Worker        try
1556*58b9f456SAndroid Build Coastguard Worker        {
1557*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1558*58b9f456SAndroid Build Coastguard Worker            for (++__f; __f != __l; ++__f, (void) ++__e, (void) ++__ds)
1559*58b9f456SAndroid Build Coastguard Worker            {
1560*58b9f456SAndroid Build Coastguard Worker                __hold.reset(__node_alloc_traits::allocate(__na, 1));
1561*58b9f456SAndroid Build Coastguard Worker                __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), *__f);
1562*58b9f456SAndroid Build Coastguard Worker                __e.__ptr_->__next_ = __hold.get()->__as_link();
1563*58b9f456SAndroid Build Coastguard Worker                __hold->__prev_ = __e.__ptr_;
1564*58b9f456SAndroid Build Coastguard Worker                __hold.release();
1565*58b9f456SAndroid Build Coastguard Worker            }
1566*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1567*58b9f456SAndroid Build Coastguard Worker        }
1568*58b9f456SAndroid Build Coastguard Worker        catch (...)
1569*58b9f456SAndroid Build Coastguard Worker        {
1570*58b9f456SAndroid Build Coastguard Worker            while (true)
1571*58b9f456SAndroid Build Coastguard Worker            {
1572*58b9f456SAndroid Build Coastguard Worker                __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e));
1573*58b9f456SAndroid Build Coastguard Worker                __link_pointer __prev = __e.__ptr_->__prev_;
1574*58b9f456SAndroid Build Coastguard Worker                __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
1575*58b9f456SAndroid Build Coastguard Worker                if (__prev == 0)
1576*58b9f456SAndroid Build Coastguard Worker                    break;
1577*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1578*58b9f456SAndroid Build Coastguard Worker                __e = iterator(__prev, this);
1579*58b9f456SAndroid Build Coastguard Worker#else
1580*58b9f456SAndroid Build Coastguard Worker                __e = iterator(__prev);
1581*58b9f456SAndroid Build Coastguard Worker#endif
1582*58b9f456SAndroid Build Coastguard Worker            }
1583*58b9f456SAndroid Build Coastguard Worker            throw;
1584*58b9f456SAndroid Build Coastguard Worker        }
1585*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1586*58b9f456SAndroid Build Coastguard Worker        __link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_);
1587*58b9f456SAndroid Build Coastguard Worker        base::__sz() += __ds;
1588*58b9f456SAndroid Build Coastguard Worker    }
1589*58b9f456SAndroid Build Coastguard Worker    return __r;
1590*58b9f456SAndroid Build Coastguard Worker}
1591*58b9f456SAndroid Build Coastguard Worker
1592*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1593*58b9f456SAndroid Build Coastguard Workervoid
1594*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::push_front(const value_type& __x)
1595*58b9f456SAndroid Build Coastguard Worker{
1596*58b9f456SAndroid Build Coastguard Worker    __node_allocator& __na = base::__node_alloc();
1597*58b9f456SAndroid Build Coastguard Worker    __hold_pointer __hold = __allocate_node(__na);
1598*58b9f456SAndroid Build Coastguard Worker    __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
1599*58b9f456SAndroid Build Coastguard Worker    __link_pointer __nl = __hold->__as_link();
1600*58b9f456SAndroid Build Coastguard Worker    __link_nodes_at_front(__nl, __nl);
1601*58b9f456SAndroid Build Coastguard Worker    ++base::__sz();
1602*58b9f456SAndroid Build Coastguard Worker    __hold.release();
1603*58b9f456SAndroid Build Coastguard Worker}
1604*58b9f456SAndroid Build Coastguard Worker
1605*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1606*58b9f456SAndroid Build Coastguard Workervoid
1607*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::push_back(const value_type& __x)
1608*58b9f456SAndroid Build Coastguard Worker{
1609*58b9f456SAndroid Build Coastguard Worker    __node_allocator& __na = base::__node_alloc();
1610*58b9f456SAndroid Build Coastguard Worker    __hold_pointer __hold = __allocate_node(__na);
1611*58b9f456SAndroid Build Coastguard Worker    __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
1612*58b9f456SAndroid Build Coastguard Worker    __link_nodes_at_back(__hold.get()->__as_link(), __hold.get()->__as_link());
1613*58b9f456SAndroid Build Coastguard Worker    ++base::__sz();
1614*58b9f456SAndroid Build Coastguard Worker    __hold.release();
1615*58b9f456SAndroid Build Coastguard Worker}
1616*58b9f456SAndroid Build Coastguard Worker
1617*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1618*58b9f456SAndroid Build Coastguard Worker
1619*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1620*58b9f456SAndroid Build Coastguard Workervoid
1621*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::push_front(value_type&& __x)
1622*58b9f456SAndroid Build Coastguard Worker{
1623*58b9f456SAndroid Build Coastguard Worker    __node_allocator& __na = base::__node_alloc();
1624*58b9f456SAndroid Build Coastguard Worker    __hold_pointer __hold = __allocate_node(__na);
1625*58b9f456SAndroid Build Coastguard Worker    __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x));
1626*58b9f456SAndroid Build Coastguard Worker    __link_nodes_at_front(__hold.get()->__as_link(), __hold.get()->__as_link());
1627*58b9f456SAndroid Build Coastguard Worker    ++base::__sz();
1628*58b9f456SAndroid Build Coastguard Worker    __hold.release();
1629*58b9f456SAndroid Build Coastguard Worker}
1630*58b9f456SAndroid Build Coastguard Worker
1631*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1632*58b9f456SAndroid Build Coastguard Workervoid
1633*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::push_back(value_type&& __x)
1634*58b9f456SAndroid Build Coastguard Worker{
1635*58b9f456SAndroid Build Coastguard Worker    __node_allocator& __na = base::__node_alloc();
1636*58b9f456SAndroid Build Coastguard Worker    __hold_pointer __hold = __allocate_node(__na);
1637*58b9f456SAndroid Build Coastguard Worker    __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x));
1638*58b9f456SAndroid Build Coastguard Worker    __link_nodes_at_back(__hold.get()->__as_link(), __hold.get()->__as_link());
1639*58b9f456SAndroid Build Coastguard Worker    ++base::__sz();
1640*58b9f456SAndroid Build Coastguard Worker    __hold.release();
1641*58b9f456SAndroid Build Coastguard Worker}
1642*58b9f456SAndroid Build Coastguard Worker
1643*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1644*58b9f456SAndroid Build Coastguard Workertemplate <class... _Args>
1645*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14
1646*58b9f456SAndroid Build Coastguard Workertypename list<_Tp, _Alloc>::reference
1647*58b9f456SAndroid Build Coastguard Worker#else
1648*58b9f456SAndroid Build Coastguard Workervoid
1649*58b9f456SAndroid Build Coastguard Worker#endif
1650*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::emplace_front(_Args&&... __args)
1651*58b9f456SAndroid Build Coastguard Worker{
1652*58b9f456SAndroid Build Coastguard Worker    __node_allocator& __na = base::__node_alloc();
1653*58b9f456SAndroid Build Coastguard Worker    __hold_pointer __hold = __allocate_node(__na);
1654*58b9f456SAndroid Build Coastguard Worker    __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...);
1655*58b9f456SAndroid Build Coastguard Worker    __link_nodes_at_front(__hold.get()->__as_link(), __hold.get()->__as_link());
1656*58b9f456SAndroid Build Coastguard Worker    ++base::__sz();
1657*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14
1658*58b9f456SAndroid Build Coastguard Worker    return __hold.release()->__value_;
1659*58b9f456SAndroid Build Coastguard Worker#else
1660*58b9f456SAndroid Build Coastguard Worker    __hold.release();
1661*58b9f456SAndroid Build Coastguard Worker#endif
1662*58b9f456SAndroid Build Coastguard Worker}
1663*58b9f456SAndroid Build Coastguard Worker
1664*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1665*58b9f456SAndroid Build Coastguard Workertemplate <class... _Args>
1666*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14
1667*58b9f456SAndroid Build Coastguard Workertypename list<_Tp, _Alloc>::reference
1668*58b9f456SAndroid Build Coastguard Worker#else
1669*58b9f456SAndroid Build Coastguard Workervoid
1670*58b9f456SAndroid Build Coastguard Worker#endif
1671*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::emplace_back(_Args&&... __args)
1672*58b9f456SAndroid Build Coastguard Worker{
1673*58b9f456SAndroid Build Coastguard Worker    __node_allocator& __na = base::__node_alloc();
1674*58b9f456SAndroid Build Coastguard Worker    __hold_pointer __hold = __allocate_node(__na);
1675*58b9f456SAndroid Build Coastguard Worker    __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...);
1676*58b9f456SAndroid Build Coastguard Worker    __link_pointer __nl = __hold->__as_link();
1677*58b9f456SAndroid Build Coastguard Worker    __link_nodes_at_back(__nl, __nl);
1678*58b9f456SAndroid Build Coastguard Worker    ++base::__sz();
1679*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14
1680*58b9f456SAndroid Build Coastguard Worker    return __hold.release()->__value_;
1681*58b9f456SAndroid Build Coastguard Worker#else
1682*58b9f456SAndroid Build Coastguard Worker    __hold.release();
1683*58b9f456SAndroid Build Coastguard Worker#endif
1684*58b9f456SAndroid Build Coastguard Worker}
1685*58b9f456SAndroid Build Coastguard Worker
1686*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1687*58b9f456SAndroid Build Coastguard Workertemplate <class... _Args>
1688*58b9f456SAndroid Build Coastguard Workertypename list<_Tp, _Alloc>::iterator
1689*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args)
1690*58b9f456SAndroid Build Coastguard Worker{
1691*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1692*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
1693*58b9f456SAndroid Build Coastguard Worker        "list::emplace(iterator, args...) called with an iterator not"
1694*58b9f456SAndroid Build Coastguard Worker        " referring to this list");
1695*58b9f456SAndroid Build Coastguard Worker#endif
1696*58b9f456SAndroid Build Coastguard Worker    __node_allocator& __na = base::__node_alloc();
1697*58b9f456SAndroid Build Coastguard Worker    __hold_pointer __hold = __allocate_node(__na);
1698*58b9f456SAndroid Build Coastguard Worker    __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...);
1699*58b9f456SAndroid Build Coastguard Worker    __link_pointer __nl = __hold.get()->__as_link();
1700*58b9f456SAndroid Build Coastguard Worker    __link_nodes(__p.__ptr_, __nl, __nl);
1701*58b9f456SAndroid Build Coastguard Worker    ++base::__sz();
1702*58b9f456SAndroid Build Coastguard Worker    __hold.release();
1703*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1704*58b9f456SAndroid Build Coastguard Worker    return iterator(__nl, this);
1705*58b9f456SAndroid Build Coastguard Worker#else
1706*58b9f456SAndroid Build Coastguard Worker    return iterator(__nl);
1707*58b9f456SAndroid Build Coastguard Worker#endif
1708*58b9f456SAndroid Build Coastguard Worker}
1709*58b9f456SAndroid Build Coastguard Worker
1710*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1711*58b9f456SAndroid Build Coastguard Workertypename list<_Tp, _Alloc>::iterator
1712*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x)
1713*58b9f456SAndroid Build Coastguard Worker{
1714*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1715*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
1716*58b9f456SAndroid Build Coastguard Worker        "list::insert(iterator, x) called with an iterator not"
1717*58b9f456SAndroid Build Coastguard Worker        " referring to this list");
1718*58b9f456SAndroid Build Coastguard Worker#endif
1719*58b9f456SAndroid Build Coastguard Worker    __node_allocator& __na = base::__node_alloc();
1720*58b9f456SAndroid Build Coastguard Worker    __hold_pointer __hold = __allocate_node(__na);
1721*58b9f456SAndroid Build Coastguard Worker    __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x));
1722*58b9f456SAndroid Build Coastguard Worker    __link_pointer __nl = __hold->__as_link();
1723*58b9f456SAndroid Build Coastguard Worker    __link_nodes(__p.__ptr_, __nl, __nl);
1724*58b9f456SAndroid Build Coastguard Worker    ++base::__sz();
1725*58b9f456SAndroid Build Coastguard Worker    __hold.release();
1726*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1727*58b9f456SAndroid Build Coastguard Worker    return iterator(__nl, this);
1728*58b9f456SAndroid Build Coastguard Worker#else
1729*58b9f456SAndroid Build Coastguard Worker    return iterator(__nl);
1730*58b9f456SAndroid Build Coastguard Worker#endif
1731*58b9f456SAndroid Build Coastguard Worker}
1732*58b9f456SAndroid Build Coastguard Worker
1733*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
1734*58b9f456SAndroid Build Coastguard Worker
1735*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1736*58b9f456SAndroid Build Coastguard Workervoid
1737*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::pop_front()
1738*58b9f456SAndroid Build Coastguard Worker{
1739*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(!empty(), "list::pop_front() called with empty list");
1740*58b9f456SAndroid Build Coastguard Worker    __node_allocator& __na = base::__node_alloc();
1741*58b9f456SAndroid Build Coastguard Worker    __link_pointer __n = base::__end_.__next_;
1742*58b9f456SAndroid Build Coastguard Worker    base::__unlink_nodes(__n, __n);
1743*58b9f456SAndroid Build Coastguard Worker    --base::__sz();
1744*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1745*58b9f456SAndroid Build Coastguard Worker    __c_node* __c = __get_db()->__find_c_and_lock(this);
1746*58b9f456SAndroid Build Coastguard Worker    for (__i_node** __p = __c->end_; __p != __c->beg_; )
1747*58b9f456SAndroid Build Coastguard Worker    {
1748*58b9f456SAndroid Build Coastguard Worker        --__p;
1749*58b9f456SAndroid Build Coastguard Worker        iterator* __i = static_cast<iterator*>((*__p)->__i_);
1750*58b9f456SAndroid Build Coastguard Worker        if (__i->__ptr_ == __n)
1751*58b9f456SAndroid Build Coastguard Worker        {
1752*58b9f456SAndroid Build Coastguard Worker            (*__p)->__c_ = nullptr;
1753*58b9f456SAndroid Build Coastguard Worker            if (--__c->end_ != __p)
1754*58b9f456SAndroid Build Coastguard Worker                memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
1755*58b9f456SAndroid Build Coastguard Worker        }
1756*58b9f456SAndroid Build Coastguard Worker    }
1757*58b9f456SAndroid Build Coastguard Worker    __get_db()->unlock();
1758*58b9f456SAndroid Build Coastguard Worker#endif
1759*58b9f456SAndroid Build Coastguard Worker    __node_pointer __np = __n->__as_node();
1760*58b9f456SAndroid Build Coastguard Worker    __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
1761*58b9f456SAndroid Build Coastguard Worker    __node_alloc_traits::deallocate(__na, __np, 1);
1762*58b9f456SAndroid Build Coastguard Worker}
1763*58b9f456SAndroid Build Coastguard Worker
1764*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1765*58b9f456SAndroid Build Coastguard Workervoid
1766*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::pop_back()
1767*58b9f456SAndroid Build Coastguard Worker{
1768*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(!empty(), "list::pop_back() called with empty list");
1769*58b9f456SAndroid Build Coastguard Worker    __node_allocator& __na = base::__node_alloc();
1770*58b9f456SAndroid Build Coastguard Worker    __link_pointer __n = base::__end_.__prev_;
1771*58b9f456SAndroid Build Coastguard Worker    base::__unlink_nodes(__n, __n);
1772*58b9f456SAndroid Build Coastguard Worker    --base::__sz();
1773*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1774*58b9f456SAndroid Build Coastguard Worker    __c_node* __c = __get_db()->__find_c_and_lock(this);
1775*58b9f456SAndroid Build Coastguard Worker    for (__i_node** __p = __c->end_; __p != __c->beg_; )
1776*58b9f456SAndroid Build Coastguard Worker    {
1777*58b9f456SAndroid Build Coastguard Worker        --__p;
1778*58b9f456SAndroid Build Coastguard Worker        iterator* __i = static_cast<iterator*>((*__p)->__i_);
1779*58b9f456SAndroid Build Coastguard Worker        if (__i->__ptr_ == __n)
1780*58b9f456SAndroid Build Coastguard Worker        {
1781*58b9f456SAndroid Build Coastguard Worker            (*__p)->__c_ = nullptr;
1782*58b9f456SAndroid Build Coastguard Worker            if (--__c->end_ != __p)
1783*58b9f456SAndroid Build Coastguard Worker                memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
1784*58b9f456SAndroid Build Coastguard Worker        }
1785*58b9f456SAndroid Build Coastguard Worker    }
1786*58b9f456SAndroid Build Coastguard Worker    __get_db()->unlock();
1787*58b9f456SAndroid Build Coastguard Worker#endif
1788*58b9f456SAndroid Build Coastguard Worker    __node_pointer __np = __n->__as_node();
1789*58b9f456SAndroid Build Coastguard Worker    __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
1790*58b9f456SAndroid Build Coastguard Worker    __node_alloc_traits::deallocate(__na, __np, 1);
1791*58b9f456SAndroid Build Coastguard Worker}
1792*58b9f456SAndroid Build Coastguard Worker
1793*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1794*58b9f456SAndroid Build Coastguard Workertypename list<_Tp, _Alloc>::iterator
1795*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::erase(const_iterator __p)
1796*58b9f456SAndroid Build Coastguard Worker{
1797*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1798*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
1799*58b9f456SAndroid Build Coastguard Worker        "list::erase(iterator) called with an iterator not"
1800*58b9f456SAndroid Build Coastguard Worker        " referring to this list");
1801*58b9f456SAndroid Build Coastguard Worker#endif
1802*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__p != end(),
1803*58b9f456SAndroid Build Coastguard Worker        "list::erase(iterator) called with a non-dereferenceable iterator");
1804*58b9f456SAndroid Build Coastguard Worker    __node_allocator& __na = base::__node_alloc();
1805*58b9f456SAndroid Build Coastguard Worker    __link_pointer __n = __p.__ptr_;
1806*58b9f456SAndroid Build Coastguard Worker    __link_pointer __r = __n->__next_;
1807*58b9f456SAndroid Build Coastguard Worker    base::__unlink_nodes(__n, __n);
1808*58b9f456SAndroid Build Coastguard Worker    --base::__sz();
1809*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1810*58b9f456SAndroid Build Coastguard Worker    __c_node* __c = __get_db()->__find_c_and_lock(this);
1811*58b9f456SAndroid Build Coastguard Worker    for (__i_node** __ip = __c->end_; __ip != __c->beg_; )
1812*58b9f456SAndroid Build Coastguard Worker    {
1813*58b9f456SAndroid Build Coastguard Worker        --__ip;
1814*58b9f456SAndroid Build Coastguard Worker        iterator* __i = static_cast<iterator*>((*__ip)->__i_);
1815*58b9f456SAndroid Build Coastguard Worker        if (__i->__ptr_ == __n)
1816*58b9f456SAndroid Build Coastguard Worker        {
1817*58b9f456SAndroid Build Coastguard Worker            (*__ip)->__c_ = nullptr;
1818*58b9f456SAndroid Build Coastguard Worker            if (--__c->end_ != __ip)
1819*58b9f456SAndroid Build Coastguard Worker                memmove(__ip, __ip+1, (__c->end_ - __ip)*sizeof(__i_node*));
1820*58b9f456SAndroid Build Coastguard Worker        }
1821*58b9f456SAndroid Build Coastguard Worker    }
1822*58b9f456SAndroid Build Coastguard Worker    __get_db()->unlock();
1823*58b9f456SAndroid Build Coastguard Worker#endif
1824*58b9f456SAndroid Build Coastguard Worker    __node_pointer __np = __n->__as_node();
1825*58b9f456SAndroid Build Coastguard Worker    __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
1826*58b9f456SAndroid Build Coastguard Worker    __node_alloc_traits::deallocate(__na, __np, 1);
1827*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1828*58b9f456SAndroid Build Coastguard Worker    return iterator(__r, this);
1829*58b9f456SAndroid Build Coastguard Worker#else
1830*58b9f456SAndroid Build Coastguard Worker    return iterator(__r);
1831*58b9f456SAndroid Build Coastguard Worker#endif
1832*58b9f456SAndroid Build Coastguard Worker}
1833*58b9f456SAndroid Build Coastguard Worker
1834*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1835*58b9f456SAndroid Build Coastguard Workertypename list<_Tp, _Alloc>::iterator
1836*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)
1837*58b9f456SAndroid Build Coastguard Worker{
1838*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1839*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__f) == this,
1840*58b9f456SAndroid Build Coastguard Worker        "list::erase(iterator, iterator) called with an iterator not"
1841*58b9f456SAndroid Build Coastguard Worker        " referring to this list");
1842*58b9f456SAndroid Build Coastguard Worker   _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__l) == this,
1843*58b9f456SAndroid Build Coastguard Worker        "list::erase(iterator, iterator) called with an iterator not"
1844*58b9f456SAndroid Build Coastguard Worker        " referring to this list");
1845*58b9f456SAndroid Build Coastguard Worker#endif
1846*58b9f456SAndroid Build Coastguard Worker    if (__f != __l)
1847*58b9f456SAndroid Build Coastguard Worker    {
1848*58b9f456SAndroid Build Coastguard Worker        __node_allocator& __na = base::__node_alloc();
1849*58b9f456SAndroid Build Coastguard Worker        base::__unlink_nodes(__f.__ptr_, __l.__ptr_->__prev_);
1850*58b9f456SAndroid Build Coastguard Worker        while (__f != __l)
1851*58b9f456SAndroid Build Coastguard Worker        {
1852*58b9f456SAndroid Build Coastguard Worker            __link_pointer __n = __f.__ptr_;
1853*58b9f456SAndroid Build Coastguard Worker            ++__f;
1854*58b9f456SAndroid Build Coastguard Worker            --base::__sz();
1855*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1856*58b9f456SAndroid Build Coastguard Worker            __c_node* __c = __get_db()->__find_c_and_lock(this);
1857*58b9f456SAndroid Build Coastguard Worker            for (__i_node** __p = __c->end_; __p != __c->beg_; )
1858*58b9f456SAndroid Build Coastguard Worker            {
1859*58b9f456SAndroid Build Coastguard Worker                --__p;
1860*58b9f456SAndroid Build Coastguard Worker                iterator* __i = static_cast<iterator*>((*__p)->__i_);
1861*58b9f456SAndroid Build Coastguard Worker                if (__i->__ptr_ == __n)
1862*58b9f456SAndroid Build Coastguard Worker                {
1863*58b9f456SAndroid Build Coastguard Worker                    (*__p)->__c_ = nullptr;
1864*58b9f456SAndroid Build Coastguard Worker                    if (--__c->end_ != __p)
1865*58b9f456SAndroid Build Coastguard Worker                        memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
1866*58b9f456SAndroid Build Coastguard Worker                }
1867*58b9f456SAndroid Build Coastguard Worker            }
1868*58b9f456SAndroid Build Coastguard Worker            __get_db()->unlock();
1869*58b9f456SAndroid Build Coastguard Worker#endif
1870*58b9f456SAndroid Build Coastguard Worker            __node_pointer __np = __n->__as_node();
1871*58b9f456SAndroid Build Coastguard Worker            __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
1872*58b9f456SAndroid Build Coastguard Worker            __node_alloc_traits::deallocate(__na, __np, 1);
1873*58b9f456SAndroid Build Coastguard Worker        }
1874*58b9f456SAndroid Build Coastguard Worker    }
1875*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1876*58b9f456SAndroid Build Coastguard Worker    return iterator(__l.__ptr_, this);
1877*58b9f456SAndroid Build Coastguard Worker#else
1878*58b9f456SAndroid Build Coastguard Worker    return iterator(__l.__ptr_);
1879*58b9f456SAndroid Build Coastguard Worker#endif
1880*58b9f456SAndroid Build Coastguard Worker}
1881*58b9f456SAndroid Build Coastguard Worker
1882*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1883*58b9f456SAndroid Build Coastguard Workervoid
1884*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::resize(size_type __n)
1885*58b9f456SAndroid Build Coastguard Worker{
1886*58b9f456SAndroid Build Coastguard Worker    if (__n < base::__sz())
1887*58b9f456SAndroid Build Coastguard Worker        erase(__iterator(__n), end());
1888*58b9f456SAndroid Build Coastguard Worker    else if (__n > base::__sz())
1889*58b9f456SAndroid Build Coastguard Worker    {
1890*58b9f456SAndroid Build Coastguard Worker        __n -= base::__sz();
1891*58b9f456SAndroid Build Coastguard Worker        size_type __ds = 0;
1892*58b9f456SAndroid Build Coastguard Worker        __node_allocator& __na = base::__node_alloc();
1893*58b9f456SAndroid Build Coastguard Worker        __hold_pointer __hold = __allocate_node(__na);
1894*58b9f456SAndroid Build Coastguard Worker        __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_));
1895*58b9f456SAndroid Build Coastguard Worker        ++__ds;
1896*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1897*58b9f456SAndroid Build Coastguard Worker        iterator __r = iterator(__hold.release()->__as_link(), this);
1898*58b9f456SAndroid Build Coastguard Worker#else
1899*58b9f456SAndroid Build Coastguard Worker        iterator __r = iterator(__hold.release()->__as_link());
1900*58b9f456SAndroid Build Coastguard Worker#endif
1901*58b9f456SAndroid Build Coastguard Worker        iterator __e = __r;
1902*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1903*58b9f456SAndroid Build Coastguard Worker        try
1904*58b9f456SAndroid Build Coastguard Worker        {
1905*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1906*58b9f456SAndroid Build Coastguard Worker            for (--__n; __n != 0; --__n, ++__e, ++__ds)
1907*58b9f456SAndroid Build Coastguard Worker            {
1908*58b9f456SAndroid Build Coastguard Worker                __hold.reset(__node_alloc_traits::allocate(__na, 1));
1909*58b9f456SAndroid Build Coastguard Worker                __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_));
1910*58b9f456SAndroid Build Coastguard Worker                __e.__ptr_->__next_ = __hold.get()->__as_link();
1911*58b9f456SAndroid Build Coastguard Worker                __hold->__prev_ = __e.__ptr_;
1912*58b9f456SAndroid Build Coastguard Worker                __hold.release();
1913*58b9f456SAndroid Build Coastguard Worker            }
1914*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1915*58b9f456SAndroid Build Coastguard Worker        }
1916*58b9f456SAndroid Build Coastguard Worker        catch (...)
1917*58b9f456SAndroid Build Coastguard Worker        {
1918*58b9f456SAndroid Build Coastguard Worker            while (true)
1919*58b9f456SAndroid Build Coastguard Worker            {
1920*58b9f456SAndroid Build Coastguard Worker                __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e));
1921*58b9f456SAndroid Build Coastguard Worker                __link_pointer __prev = __e.__ptr_->__prev_;
1922*58b9f456SAndroid Build Coastguard Worker                __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
1923*58b9f456SAndroid Build Coastguard Worker                if (__prev == 0)
1924*58b9f456SAndroid Build Coastguard Worker                    break;
1925*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1926*58b9f456SAndroid Build Coastguard Worker                __e = iterator(__prev, this);
1927*58b9f456SAndroid Build Coastguard Worker#else
1928*58b9f456SAndroid Build Coastguard Worker                __e = iterator(__prev);
1929*58b9f456SAndroid Build Coastguard Worker#endif
1930*58b9f456SAndroid Build Coastguard Worker            }
1931*58b9f456SAndroid Build Coastguard Worker            throw;
1932*58b9f456SAndroid Build Coastguard Worker        }
1933*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1934*58b9f456SAndroid Build Coastguard Worker        __link_nodes_at_back(__r.__ptr_, __e.__ptr_);
1935*58b9f456SAndroid Build Coastguard Worker        base::__sz() += __ds;
1936*58b9f456SAndroid Build Coastguard Worker    }
1937*58b9f456SAndroid Build Coastguard Worker}
1938*58b9f456SAndroid Build Coastguard Worker
1939*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1940*58b9f456SAndroid Build Coastguard Workervoid
1941*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::resize(size_type __n, const value_type& __x)
1942*58b9f456SAndroid Build Coastguard Worker{
1943*58b9f456SAndroid Build Coastguard Worker    if (__n < base::__sz())
1944*58b9f456SAndroid Build Coastguard Worker        erase(__iterator(__n), end());
1945*58b9f456SAndroid Build Coastguard Worker    else if (__n > base::__sz())
1946*58b9f456SAndroid Build Coastguard Worker    {
1947*58b9f456SAndroid Build Coastguard Worker        __n -= base::__sz();
1948*58b9f456SAndroid Build Coastguard Worker        size_type __ds = 0;
1949*58b9f456SAndroid Build Coastguard Worker        __node_allocator& __na = base::__node_alloc();
1950*58b9f456SAndroid Build Coastguard Worker        __hold_pointer __hold = __allocate_node(__na);
1951*58b9f456SAndroid Build Coastguard Worker        __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
1952*58b9f456SAndroid Build Coastguard Worker        ++__ds;
1953*58b9f456SAndroid Build Coastguard Worker        __link_pointer __nl = __hold.release()->__as_link();
1954*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1955*58b9f456SAndroid Build Coastguard Worker        iterator __r = iterator(__nl, this);
1956*58b9f456SAndroid Build Coastguard Worker#else
1957*58b9f456SAndroid Build Coastguard Worker        iterator __r = iterator(__nl);
1958*58b9f456SAndroid Build Coastguard Worker#endif
1959*58b9f456SAndroid Build Coastguard Worker        iterator __e = __r;
1960*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1961*58b9f456SAndroid Build Coastguard Worker        try
1962*58b9f456SAndroid Build Coastguard Worker        {
1963*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1964*58b9f456SAndroid Build Coastguard Worker            for (--__n; __n != 0; --__n, ++__e, ++__ds)
1965*58b9f456SAndroid Build Coastguard Worker            {
1966*58b9f456SAndroid Build Coastguard Worker                __hold.reset(__node_alloc_traits::allocate(__na, 1));
1967*58b9f456SAndroid Build Coastguard Worker                __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
1968*58b9f456SAndroid Build Coastguard Worker                __e.__ptr_->__next_ = __hold.get()->__as_link();
1969*58b9f456SAndroid Build Coastguard Worker                __hold->__prev_ = __e.__ptr_;
1970*58b9f456SAndroid Build Coastguard Worker                __hold.release();
1971*58b9f456SAndroid Build Coastguard Worker            }
1972*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
1973*58b9f456SAndroid Build Coastguard Worker        }
1974*58b9f456SAndroid Build Coastguard Worker        catch (...)
1975*58b9f456SAndroid Build Coastguard Worker        {
1976*58b9f456SAndroid Build Coastguard Worker            while (true)
1977*58b9f456SAndroid Build Coastguard Worker            {
1978*58b9f456SAndroid Build Coastguard Worker                __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e));
1979*58b9f456SAndroid Build Coastguard Worker                __link_pointer __prev = __e.__ptr_->__prev_;
1980*58b9f456SAndroid Build Coastguard Worker                __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1);
1981*58b9f456SAndroid Build Coastguard Worker                if (__prev == 0)
1982*58b9f456SAndroid Build Coastguard Worker                    break;
1983*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1984*58b9f456SAndroid Build Coastguard Worker                __e = iterator(__prev, this);
1985*58b9f456SAndroid Build Coastguard Worker#else
1986*58b9f456SAndroid Build Coastguard Worker                __e = iterator(__prev);
1987*58b9f456SAndroid Build Coastguard Worker#endif
1988*58b9f456SAndroid Build Coastguard Worker            }
1989*58b9f456SAndroid Build Coastguard Worker            throw;
1990*58b9f456SAndroid Build Coastguard Worker        }
1991*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
1992*58b9f456SAndroid Build Coastguard Worker        __link_nodes(base::__end_as_link(), __r.__ptr_, __e.__ptr_);
1993*58b9f456SAndroid Build Coastguard Worker        base::__sz() += __ds;
1994*58b9f456SAndroid Build Coastguard Worker    }
1995*58b9f456SAndroid Build Coastguard Worker}
1996*58b9f456SAndroid Build Coastguard Worker
1997*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
1998*58b9f456SAndroid Build Coastguard Workervoid
1999*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::splice(const_iterator __p, list& __c)
2000*58b9f456SAndroid Build Coastguard Worker{
2001*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(this != &__c,
2002*58b9f456SAndroid Build Coastguard Worker                   "list::splice(iterator, list) called with this == &list");
2003*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2004*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
2005*58b9f456SAndroid Build Coastguard Worker        "list::splice(iterator, list) called with an iterator not"
2006*58b9f456SAndroid Build Coastguard Worker        " referring to this list");
2007*58b9f456SAndroid Build Coastguard Worker#endif
2008*58b9f456SAndroid Build Coastguard Worker    if (!__c.empty())
2009*58b9f456SAndroid Build Coastguard Worker    {
2010*58b9f456SAndroid Build Coastguard Worker        __link_pointer __f = __c.__end_.__next_;
2011*58b9f456SAndroid Build Coastguard Worker        __link_pointer __l = __c.__end_.__prev_;
2012*58b9f456SAndroid Build Coastguard Worker        base::__unlink_nodes(__f, __l);
2013*58b9f456SAndroid Build Coastguard Worker        __link_nodes(__p.__ptr_, __f, __l);
2014*58b9f456SAndroid Build Coastguard Worker        base::__sz() += __c.__sz();
2015*58b9f456SAndroid Build Coastguard Worker        __c.__sz() = 0;
2016*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2017*58b9f456SAndroid Build Coastguard Worker        __libcpp_db* __db = __get_db();
2018*58b9f456SAndroid Build Coastguard Worker        __c_node* __cn1 = __db->__find_c_and_lock(this);
2019*58b9f456SAndroid Build Coastguard Worker        __c_node* __cn2 = __db->__find_c(&__c);
2020*58b9f456SAndroid Build Coastguard Worker        for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;)
2021*58b9f456SAndroid Build Coastguard Worker        {
2022*58b9f456SAndroid Build Coastguard Worker            --__ip;
2023*58b9f456SAndroid Build Coastguard Worker            iterator* __i = static_cast<iterator*>((*__ip)->__i_);
2024*58b9f456SAndroid Build Coastguard Worker            if (__i->__ptr_ != __c.__end_as_link())
2025*58b9f456SAndroid Build Coastguard Worker            {
2026*58b9f456SAndroid Build Coastguard Worker                __cn1->__add(*__ip);
2027*58b9f456SAndroid Build Coastguard Worker                (*__ip)->__c_ = __cn1;
2028*58b9f456SAndroid Build Coastguard Worker                if (--__cn2->end_ != __ip)
2029*58b9f456SAndroid Build Coastguard Worker                    memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
2030*58b9f456SAndroid Build Coastguard Worker            }
2031*58b9f456SAndroid Build Coastguard Worker        }
2032*58b9f456SAndroid Build Coastguard Worker        __db->unlock();
2033*58b9f456SAndroid Build Coastguard Worker#endif
2034*58b9f456SAndroid Build Coastguard Worker    }
2035*58b9f456SAndroid Build Coastguard Worker}
2036*58b9f456SAndroid Build Coastguard Worker
2037*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
2038*58b9f456SAndroid Build Coastguard Workervoid
2039*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)
2040*58b9f456SAndroid Build Coastguard Worker{
2041*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2042*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
2043*58b9f456SAndroid Build Coastguard Worker        "list::splice(iterator, list, iterator) called with first iterator not"
2044*58b9f456SAndroid Build Coastguard Worker        " referring to this list");
2045*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__i) == &__c,
2046*58b9f456SAndroid Build Coastguard Worker        "list::splice(iterator, list, iterator) called with second iterator not"
2047*58b9f456SAndroid Build Coastguard Worker        " referring to list argument");
2048*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(&__i),
2049*58b9f456SAndroid Build Coastguard Worker        "list::splice(iterator, list, iterator) called with second iterator not"
2050*58b9f456SAndroid Build Coastguard Worker        " derefereceable");
2051*58b9f456SAndroid Build Coastguard Worker#endif
2052*58b9f456SAndroid Build Coastguard Worker    if (__p.__ptr_ != __i.__ptr_ && __p.__ptr_ != __i.__ptr_->__next_)
2053*58b9f456SAndroid Build Coastguard Worker    {
2054*58b9f456SAndroid Build Coastguard Worker        __link_pointer __f = __i.__ptr_;
2055*58b9f456SAndroid Build Coastguard Worker        base::__unlink_nodes(__f, __f);
2056*58b9f456SAndroid Build Coastguard Worker        __link_nodes(__p.__ptr_, __f, __f);
2057*58b9f456SAndroid Build Coastguard Worker        --__c.__sz();
2058*58b9f456SAndroid Build Coastguard Worker        ++base::__sz();
2059*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2060*58b9f456SAndroid Build Coastguard Worker        __libcpp_db* __db = __get_db();
2061*58b9f456SAndroid Build Coastguard Worker        __c_node* __cn1 = __db->__find_c_and_lock(this);
2062*58b9f456SAndroid Build Coastguard Worker        __c_node* __cn2 = __db->__find_c(&__c);
2063*58b9f456SAndroid Build Coastguard Worker        for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;)
2064*58b9f456SAndroid Build Coastguard Worker        {
2065*58b9f456SAndroid Build Coastguard Worker            --__ip;
2066*58b9f456SAndroid Build Coastguard Worker            iterator* __j = static_cast<iterator*>((*__ip)->__i_);
2067*58b9f456SAndroid Build Coastguard Worker            if (__j->__ptr_ == __f)
2068*58b9f456SAndroid Build Coastguard Worker            {
2069*58b9f456SAndroid Build Coastguard Worker                __cn1->__add(*__ip);
2070*58b9f456SAndroid Build Coastguard Worker                (*__ip)->__c_ = __cn1;
2071*58b9f456SAndroid Build Coastguard Worker                if (--__cn2->end_ != __ip)
2072*58b9f456SAndroid Build Coastguard Worker                    memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
2073*58b9f456SAndroid Build Coastguard Worker            }
2074*58b9f456SAndroid Build Coastguard Worker        }
2075*58b9f456SAndroid Build Coastguard Worker        __db->unlock();
2076*58b9f456SAndroid Build Coastguard Worker#endif
2077*58b9f456SAndroid Build Coastguard Worker    }
2078*58b9f456SAndroid Build Coastguard Worker}
2079*58b9f456SAndroid Build Coastguard Worker
2080*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
2081*58b9f456SAndroid Build Coastguard Workervoid
2082*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l)
2083*58b9f456SAndroid Build Coastguard Worker{
2084*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2085*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
2086*58b9f456SAndroid Build Coastguard Worker        "list::splice(iterator, list, iterator, iterator) called with first iterator not"
2087*58b9f456SAndroid Build Coastguard Worker        " referring to this list");
2088*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__f) == &__c,
2089*58b9f456SAndroid Build Coastguard Worker        "list::splice(iterator, list, iterator, iterator) called with second iterator not"
2090*58b9f456SAndroid Build Coastguard Worker        " referring to list argument");
2091*58b9f456SAndroid Build Coastguard Worker    if (this == &__c)
2092*58b9f456SAndroid Build Coastguard Worker    {
2093*58b9f456SAndroid Build Coastguard Worker        for (const_iterator __i = __f; __i != __l; ++__i)
2094*58b9f456SAndroid Build Coastguard Worker            _LIBCPP_ASSERT(__i != __p,
2095*58b9f456SAndroid Build Coastguard Worker                           "list::splice(iterator, list, iterator, iterator)"
2096*58b9f456SAndroid Build Coastguard Worker                           " called with the first iterator within the range"
2097*58b9f456SAndroid Build Coastguard Worker                           " of the second and third iterators");
2098*58b9f456SAndroid Build Coastguard Worker    }
2099*58b9f456SAndroid Build Coastguard Worker#endif
2100*58b9f456SAndroid Build Coastguard Worker    if (__f != __l)
2101*58b9f456SAndroid Build Coastguard Worker    {
2102*58b9f456SAndroid Build Coastguard Worker        __link_pointer __first = __f.__ptr_;
2103*58b9f456SAndroid Build Coastguard Worker        --__l;
2104*58b9f456SAndroid Build Coastguard Worker        __link_pointer __last = __l.__ptr_;
2105*58b9f456SAndroid Build Coastguard Worker        if (this != &__c)
2106*58b9f456SAndroid Build Coastguard Worker        {
2107*58b9f456SAndroid Build Coastguard Worker            size_type __s = _VSTD::distance(__f, __l) + 1;
2108*58b9f456SAndroid Build Coastguard Worker            __c.__sz() -= __s;
2109*58b9f456SAndroid Build Coastguard Worker            base::__sz() += __s;
2110*58b9f456SAndroid Build Coastguard Worker        }
2111*58b9f456SAndroid Build Coastguard Worker        base::__unlink_nodes(__first, __last);
2112*58b9f456SAndroid Build Coastguard Worker        __link_nodes(__p.__ptr_, __first, __last);
2113*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2114*58b9f456SAndroid Build Coastguard Worker        __libcpp_db* __db = __get_db();
2115*58b9f456SAndroid Build Coastguard Worker        __c_node* __cn1 = __db->__find_c_and_lock(this);
2116*58b9f456SAndroid Build Coastguard Worker        __c_node* __cn2 = __db->__find_c(&__c);
2117*58b9f456SAndroid Build Coastguard Worker        for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;)
2118*58b9f456SAndroid Build Coastguard Worker        {
2119*58b9f456SAndroid Build Coastguard Worker            --__ip;
2120*58b9f456SAndroid Build Coastguard Worker            iterator* __j = static_cast<iterator*>((*__ip)->__i_);
2121*58b9f456SAndroid Build Coastguard Worker            for (__link_pointer __k = __f.__ptr_;
2122*58b9f456SAndroid Build Coastguard Worker                                          __k != __l.__ptr_; __k = __k->__next_)
2123*58b9f456SAndroid Build Coastguard Worker            {
2124*58b9f456SAndroid Build Coastguard Worker                if (__j->__ptr_ == __k)
2125*58b9f456SAndroid Build Coastguard Worker                {
2126*58b9f456SAndroid Build Coastguard Worker                    __cn1->__add(*__ip);
2127*58b9f456SAndroid Build Coastguard Worker                    (*__ip)->__c_ = __cn1;
2128*58b9f456SAndroid Build Coastguard Worker                    if (--__cn2->end_ != __ip)
2129*58b9f456SAndroid Build Coastguard Worker                        memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
2130*58b9f456SAndroid Build Coastguard Worker                }
2131*58b9f456SAndroid Build Coastguard Worker            }
2132*58b9f456SAndroid Build Coastguard Worker        }
2133*58b9f456SAndroid Build Coastguard Worker        __db->unlock();
2134*58b9f456SAndroid Build Coastguard Worker#endif
2135*58b9f456SAndroid Build Coastguard Worker    }
2136*58b9f456SAndroid Build Coastguard Worker}
2137*58b9f456SAndroid Build Coastguard Worker
2138*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
2139*58b9f456SAndroid Build Coastguard Workervoid
2140*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::remove(const value_type& __x)
2141*58b9f456SAndroid Build Coastguard Worker{
2142*58b9f456SAndroid Build Coastguard Worker    list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
2143*58b9f456SAndroid Build Coastguard Worker    for (const_iterator __i = begin(), __e = end(); __i != __e;)
2144*58b9f456SAndroid Build Coastguard Worker    {
2145*58b9f456SAndroid Build Coastguard Worker        if (*__i == __x)
2146*58b9f456SAndroid Build Coastguard Worker        {
2147*58b9f456SAndroid Build Coastguard Worker            const_iterator __j = _VSTD::next(__i);
2148*58b9f456SAndroid Build Coastguard Worker            for (; __j != __e && *__j == __x; ++__j)
2149*58b9f456SAndroid Build Coastguard Worker                ;
2150*58b9f456SAndroid Build Coastguard Worker            __deleted_nodes.splice(__deleted_nodes.end(), *this, __i, __j);
2151*58b9f456SAndroid Build Coastguard Worker            __i = __j;
2152*58b9f456SAndroid Build Coastguard Worker            if (__i != __e)
2153*58b9f456SAndroid Build Coastguard Worker                ++__i;
2154*58b9f456SAndroid Build Coastguard Worker        }
2155*58b9f456SAndroid Build Coastguard Worker        else
2156*58b9f456SAndroid Build Coastguard Worker            ++__i;
2157*58b9f456SAndroid Build Coastguard Worker    }
2158*58b9f456SAndroid Build Coastguard Worker}
2159*58b9f456SAndroid Build Coastguard Worker
2160*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
2161*58b9f456SAndroid Build Coastguard Workertemplate <class _Pred>
2162*58b9f456SAndroid Build Coastguard Workervoid
2163*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::remove_if(_Pred __pred)
2164*58b9f456SAndroid Build Coastguard Worker{
2165*58b9f456SAndroid Build Coastguard Worker    for (iterator __i = begin(), __e = end(); __i != __e;)
2166*58b9f456SAndroid Build Coastguard Worker    {
2167*58b9f456SAndroid Build Coastguard Worker        if (__pred(*__i))
2168*58b9f456SAndroid Build Coastguard Worker        {
2169*58b9f456SAndroid Build Coastguard Worker            iterator __j = _VSTD::next(__i);
2170*58b9f456SAndroid Build Coastguard Worker            for (; __j != __e && __pred(*__j); ++__j)
2171*58b9f456SAndroid Build Coastguard Worker                ;
2172*58b9f456SAndroid Build Coastguard Worker            __i = erase(__i, __j);
2173*58b9f456SAndroid Build Coastguard Worker            if (__i != __e)
2174*58b9f456SAndroid Build Coastguard Worker                ++__i;
2175*58b9f456SAndroid Build Coastguard Worker        }
2176*58b9f456SAndroid Build Coastguard Worker        else
2177*58b9f456SAndroid Build Coastguard Worker            ++__i;
2178*58b9f456SAndroid Build Coastguard Worker    }
2179*58b9f456SAndroid Build Coastguard Worker}
2180*58b9f456SAndroid Build Coastguard Worker
2181*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
2182*58b9f456SAndroid Build Coastguard Workerinline
2183*58b9f456SAndroid Build Coastguard Workervoid
2184*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::unique()
2185*58b9f456SAndroid Build Coastguard Worker{
2186*58b9f456SAndroid Build Coastguard Worker    unique(__equal_to<value_type>());
2187*58b9f456SAndroid Build Coastguard Worker}
2188*58b9f456SAndroid Build Coastguard Worker
2189*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
2190*58b9f456SAndroid Build Coastguard Workertemplate <class _BinaryPred>
2191*58b9f456SAndroid Build Coastguard Workervoid
2192*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::unique(_BinaryPred __binary_pred)
2193*58b9f456SAndroid Build Coastguard Worker{
2194*58b9f456SAndroid Build Coastguard Worker    for (iterator __i = begin(), __e = end(); __i != __e;)
2195*58b9f456SAndroid Build Coastguard Worker    {
2196*58b9f456SAndroid Build Coastguard Worker        iterator __j = _VSTD::next(__i);
2197*58b9f456SAndroid Build Coastguard Worker        for (; __j != __e && __binary_pred(*__i, *__j); ++__j)
2198*58b9f456SAndroid Build Coastguard Worker            ;
2199*58b9f456SAndroid Build Coastguard Worker        if (++__i != __j)
2200*58b9f456SAndroid Build Coastguard Worker            __i = erase(__i, __j);
2201*58b9f456SAndroid Build Coastguard Worker    }
2202*58b9f456SAndroid Build Coastguard Worker}
2203*58b9f456SAndroid Build Coastguard Worker
2204*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
2205*58b9f456SAndroid Build Coastguard Workerinline
2206*58b9f456SAndroid Build Coastguard Workervoid
2207*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::merge(list& __c)
2208*58b9f456SAndroid Build Coastguard Worker{
2209*58b9f456SAndroid Build Coastguard Worker    merge(__c, __less<value_type>());
2210*58b9f456SAndroid Build Coastguard Worker}
2211*58b9f456SAndroid Build Coastguard Worker
2212*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
2213*58b9f456SAndroid Build Coastguard Workertemplate <class _Comp>
2214*58b9f456SAndroid Build Coastguard Workervoid
2215*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::merge(list& __c, _Comp __comp)
2216*58b9f456SAndroid Build Coastguard Worker{
2217*58b9f456SAndroid Build Coastguard Worker    if (this != _VSTD::addressof(__c))
2218*58b9f456SAndroid Build Coastguard Worker    {
2219*58b9f456SAndroid Build Coastguard Worker        iterator __f1 = begin();
2220*58b9f456SAndroid Build Coastguard Worker        iterator __e1 = end();
2221*58b9f456SAndroid Build Coastguard Worker        iterator __f2 = __c.begin();
2222*58b9f456SAndroid Build Coastguard Worker        iterator __e2 = __c.end();
2223*58b9f456SAndroid Build Coastguard Worker        while (__f1 != __e1 && __f2 != __e2)
2224*58b9f456SAndroid Build Coastguard Worker        {
2225*58b9f456SAndroid Build Coastguard Worker            if (__comp(*__f2, *__f1))
2226*58b9f456SAndroid Build Coastguard Worker            {
2227*58b9f456SAndroid Build Coastguard Worker                size_type __ds = 1;
2228*58b9f456SAndroid Build Coastguard Worker                iterator __m2 = _VSTD::next(__f2);
2229*58b9f456SAndroid Build Coastguard Worker                for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2, ++__ds)
2230*58b9f456SAndroid Build Coastguard Worker                    ;
2231*58b9f456SAndroid Build Coastguard Worker                base::__sz() += __ds;
2232*58b9f456SAndroid Build Coastguard Worker                __c.__sz() -= __ds;
2233*58b9f456SAndroid Build Coastguard Worker                __link_pointer __f = __f2.__ptr_;
2234*58b9f456SAndroid Build Coastguard Worker                __link_pointer __l = __m2.__ptr_->__prev_;
2235*58b9f456SAndroid Build Coastguard Worker                __f2 = __m2;
2236*58b9f456SAndroid Build Coastguard Worker                base::__unlink_nodes(__f, __l);
2237*58b9f456SAndroid Build Coastguard Worker                __m2 = _VSTD::next(__f1);
2238*58b9f456SAndroid Build Coastguard Worker                __link_nodes(__f1.__ptr_, __f, __l);
2239*58b9f456SAndroid Build Coastguard Worker                __f1 = __m2;
2240*58b9f456SAndroid Build Coastguard Worker            }
2241*58b9f456SAndroid Build Coastguard Worker            else
2242*58b9f456SAndroid Build Coastguard Worker                ++__f1;
2243*58b9f456SAndroid Build Coastguard Worker        }
2244*58b9f456SAndroid Build Coastguard Worker        splice(__e1, __c);
2245*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2246*58b9f456SAndroid Build Coastguard Worker        __libcpp_db* __db = __get_db();
2247*58b9f456SAndroid Build Coastguard Worker        __c_node* __cn1 = __db->__find_c_and_lock(this);
2248*58b9f456SAndroid Build Coastguard Worker        __c_node* __cn2 = __db->__find_c(&__c);
2249*58b9f456SAndroid Build Coastguard Worker        for (__i_node** __p = __cn2->end_; __p != __cn2->beg_;)
2250*58b9f456SAndroid Build Coastguard Worker        {
2251*58b9f456SAndroid Build Coastguard Worker            --__p;
2252*58b9f456SAndroid Build Coastguard Worker            iterator* __i = static_cast<iterator*>((*__p)->__i_);
2253*58b9f456SAndroid Build Coastguard Worker            if (__i->__ptr_ != __c.__end_as_link())
2254*58b9f456SAndroid Build Coastguard Worker            {
2255*58b9f456SAndroid Build Coastguard Worker                __cn1->__add(*__p);
2256*58b9f456SAndroid Build Coastguard Worker                (*__p)->__c_ = __cn1;
2257*58b9f456SAndroid Build Coastguard Worker                if (--__cn2->end_ != __p)
2258*58b9f456SAndroid Build Coastguard Worker                    memmove(__p, __p+1, (__cn2->end_ - __p)*sizeof(__i_node*));
2259*58b9f456SAndroid Build Coastguard Worker            }
2260*58b9f456SAndroid Build Coastguard Worker        }
2261*58b9f456SAndroid Build Coastguard Worker        __db->unlock();
2262*58b9f456SAndroid Build Coastguard Worker#endif
2263*58b9f456SAndroid Build Coastguard Worker    }
2264*58b9f456SAndroid Build Coastguard Worker}
2265*58b9f456SAndroid Build Coastguard Worker
2266*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
2267*58b9f456SAndroid Build Coastguard Workerinline
2268*58b9f456SAndroid Build Coastguard Workervoid
2269*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::sort()
2270*58b9f456SAndroid Build Coastguard Worker{
2271*58b9f456SAndroid Build Coastguard Worker    sort(__less<value_type>());
2272*58b9f456SAndroid Build Coastguard Worker}
2273*58b9f456SAndroid Build Coastguard Worker
2274*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
2275*58b9f456SAndroid Build Coastguard Workertemplate <class _Comp>
2276*58b9f456SAndroid Build Coastguard Workerinline
2277*58b9f456SAndroid Build Coastguard Workervoid
2278*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::sort(_Comp __comp)
2279*58b9f456SAndroid Build Coastguard Worker{
2280*58b9f456SAndroid Build Coastguard Worker    __sort(begin(), end(), base::__sz(), __comp);
2281*58b9f456SAndroid Build Coastguard Worker}
2282*58b9f456SAndroid Build Coastguard Worker
2283*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
2284*58b9f456SAndroid Build Coastguard Workertemplate <class _Comp>
2285*58b9f456SAndroid Build Coastguard Workertypename list<_Tp, _Alloc>::iterator
2286*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp)
2287*58b9f456SAndroid Build Coastguard Worker{
2288*58b9f456SAndroid Build Coastguard Worker    switch (__n)
2289*58b9f456SAndroid Build Coastguard Worker    {
2290*58b9f456SAndroid Build Coastguard Worker    case 0:
2291*58b9f456SAndroid Build Coastguard Worker    case 1:
2292*58b9f456SAndroid Build Coastguard Worker        return __f1;
2293*58b9f456SAndroid Build Coastguard Worker    case 2:
2294*58b9f456SAndroid Build Coastguard Worker        if (__comp(*--__e2, *__f1))
2295*58b9f456SAndroid Build Coastguard Worker        {
2296*58b9f456SAndroid Build Coastguard Worker            __link_pointer __f = __e2.__ptr_;
2297*58b9f456SAndroid Build Coastguard Worker            base::__unlink_nodes(__f, __f);
2298*58b9f456SAndroid Build Coastguard Worker            __link_nodes(__f1.__ptr_, __f, __f);
2299*58b9f456SAndroid Build Coastguard Worker            return __e2;
2300*58b9f456SAndroid Build Coastguard Worker        }
2301*58b9f456SAndroid Build Coastguard Worker        return __f1;
2302*58b9f456SAndroid Build Coastguard Worker    }
2303*58b9f456SAndroid Build Coastguard Worker    size_type __n2 = __n / 2;
2304*58b9f456SAndroid Build Coastguard Worker    iterator __e1 = _VSTD::next(__f1, __n2);
2305*58b9f456SAndroid Build Coastguard Worker    iterator  __r = __f1 = __sort(__f1, __e1, __n2, __comp);
2306*58b9f456SAndroid Build Coastguard Worker    iterator __f2 = __e1 = __sort(__e1, __e2, __n - __n2, __comp);
2307*58b9f456SAndroid Build Coastguard Worker    if (__comp(*__f2, *__f1))
2308*58b9f456SAndroid Build Coastguard Worker    {
2309*58b9f456SAndroid Build Coastguard Worker        iterator __m2 = _VSTD::next(__f2);
2310*58b9f456SAndroid Build Coastguard Worker        for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2)
2311*58b9f456SAndroid Build Coastguard Worker            ;
2312*58b9f456SAndroid Build Coastguard Worker        __link_pointer __f = __f2.__ptr_;
2313*58b9f456SAndroid Build Coastguard Worker        __link_pointer __l = __m2.__ptr_->__prev_;
2314*58b9f456SAndroid Build Coastguard Worker        __r = __f2;
2315*58b9f456SAndroid Build Coastguard Worker        __e1 = __f2 = __m2;
2316*58b9f456SAndroid Build Coastguard Worker        base::__unlink_nodes(__f, __l);
2317*58b9f456SAndroid Build Coastguard Worker        __m2 = _VSTD::next(__f1);
2318*58b9f456SAndroid Build Coastguard Worker        __link_nodes(__f1.__ptr_, __f, __l);
2319*58b9f456SAndroid Build Coastguard Worker        __f1 = __m2;
2320*58b9f456SAndroid Build Coastguard Worker    }
2321*58b9f456SAndroid Build Coastguard Worker    else
2322*58b9f456SAndroid Build Coastguard Worker        ++__f1;
2323*58b9f456SAndroid Build Coastguard Worker    while (__f1 != __e1 && __f2 != __e2)
2324*58b9f456SAndroid Build Coastguard Worker    {
2325*58b9f456SAndroid Build Coastguard Worker        if (__comp(*__f2, *__f1))
2326*58b9f456SAndroid Build Coastguard Worker        {
2327*58b9f456SAndroid Build Coastguard Worker            iterator __m2 = _VSTD::next(__f2);
2328*58b9f456SAndroid Build Coastguard Worker            for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2)
2329*58b9f456SAndroid Build Coastguard Worker                ;
2330*58b9f456SAndroid Build Coastguard Worker            __link_pointer __f = __f2.__ptr_;
2331*58b9f456SAndroid Build Coastguard Worker            __link_pointer __l = __m2.__ptr_->__prev_;
2332*58b9f456SAndroid Build Coastguard Worker            if (__e1 == __f2)
2333*58b9f456SAndroid Build Coastguard Worker                __e1 = __m2;
2334*58b9f456SAndroid Build Coastguard Worker            __f2 = __m2;
2335*58b9f456SAndroid Build Coastguard Worker            base::__unlink_nodes(__f, __l);
2336*58b9f456SAndroid Build Coastguard Worker            __m2 = _VSTD::next(__f1);
2337*58b9f456SAndroid Build Coastguard Worker            __link_nodes(__f1.__ptr_, __f, __l);
2338*58b9f456SAndroid Build Coastguard Worker            __f1 = __m2;
2339*58b9f456SAndroid Build Coastguard Worker        }
2340*58b9f456SAndroid Build Coastguard Worker        else
2341*58b9f456SAndroid Build Coastguard Worker            ++__f1;
2342*58b9f456SAndroid Build Coastguard Worker    }
2343*58b9f456SAndroid Build Coastguard Worker    return __r;
2344*58b9f456SAndroid Build Coastguard Worker}
2345*58b9f456SAndroid Build Coastguard Worker
2346*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
2347*58b9f456SAndroid Build Coastguard Workervoid
2348*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::reverse() _NOEXCEPT
2349*58b9f456SAndroid Build Coastguard Worker{
2350*58b9f456SAndroid Build Coastguard Worker    if (base::__sz() > 1)
2351*58b9f456SAndroid Build Coastguard Worker    {
2352*58b9f456SAndroid Build Coastguard Worker        iterator __e = end();
2353*58b9f456SAndroid Build Coastguard Worker        for (iterator __i = begin(); __i.__ptr_ != __e.__ptr_;)
2354*58b9f456SAndroid Build Coastguard Worker        {
2355*58b9f456SAndroid Build Coastguard Worker            _VSTD::swap(__i.__ptr_->__prev_, __i.__ptr_->__next_);
2356*58b9f456SAndroid Build Coastguard Worker            __i.__ptr_ = __i.__ptr_->__prev_;
2357*58b9f456SAndroid Build Coastguard Worker        }
2358*58b9f456SAndroid Build Coastguard Worker        _VSTD::swap(__e.__ptr_->__prev_, __e.__ptr_->__next_);
2359*58b9f456SAndroid Build Coastguard Worker    }
2360*58b9f456SAndroid Build Coastguard Worker}
2361*58b9f456SAndroid Build Coastguard Worker
2362*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
2363*58b9f456SAndroid Build Coastguard Workerbool
2364*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::__invariants() const
2365*58b9f456SAndroid Build Coastguard Worker{
2366*58b9f456SAndroid Build Coastguard Worker    return size() == _VSTD::distance(begin(), end());
2367*58b9f456SAndroid Build Coastguard Worker}
2368*58b9f456SAndroid Build Coastguard Worker
2369*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2370*58b9f456SAndroid Build Coastguard Worker
2371*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
2372*58b9f456SAndroid Build Coastguard Workerbool
2373*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::__dereferenceable(const const_iterator* __i) const
2374*58b9f456SAndroid Build Coastguard Worker{
2375*58b9f456SAndroid Build Coastguard Worker    return __i->__ptr_ != this->__end_as_link();
2376*58b9f456SAndroid Build Coastguard Worker}
2377*58b9f456SAndroid Build Coastguard Worker
2378*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
2379*58b9f456SAndroid Build Coastguard Workerbool
2380*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::__decrementable(const const_iterator* __i) const
2381*58b9f456SAndroid Build Coastguard Worker{
2382*58b9f456SAndroid Build Coastguard Worker    return !empty() &&  __i->__ptr_ != base::__end_.__next_;
2383*58b9f456SAndroid Build Coastguard Worker}
2384*58b9f456SAndroid Build Coastguard Worker
2385*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
2386*58b9f456SAndroid Build Coastguard Workerbool
2387*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::__addable(const const_iterator*, ptrdiff_t) const
2388*58b9f456SAndroid Build Coastguard Worker{
2389*58b9f456SAndroid Build Coastguard Worker    return false;
2390*58b9f456SAndroid Build Coastguard Worker}
2391*58b9f456SAndroid Build Coastguard Worker
2392*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
2393*58b9f456SAndroid Build Coastguard Workerbool
2394*58b9f456SAndroid Build Coastguard Workerlist<_Tp, _Alloc>::__subscriptable(const const_iterator*, ptrdiff_t) const
2395*58b9f456SAndroid Build Coastguard Worker{
2396*58b9f456SAndroid Build Coastguard Worker    return false;
2397*58b9f456SAndroid Build Coastguard Worker}
2398*58b9f456SAndroid Build Coastguard Worker
2399*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_DEBUG_LEVEL >= 2
2400*58b9f456SAndroid Build Coastguard Worker
2401*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
2402*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
2403*58b9f456SAndroid Build Coastguard Workerbool
2404*58b9f456SAndroid Build Coastguard Workeroperator==(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
2405*58b9f456SAndroid Build Coastguard Worker{
2406*58b9f456SAndroid Build Coastguard Worker    return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
2407*58b9f456SAndroid Build Coastguard Worker}
2408*58b9f456SAndroid Build Coastguard Worker
2409*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
2410*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
2411*58b9f456SAndroid Build Coastguard Workerbool
2412*58b9f456SAndroid Build Coastguard Workeroperator< (const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
2413*58b9f456SAndroid Build Coastguard Worker{
2414*58b9f456SAndroid Build Coastguard Worker    return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
2415*58b9f456SAndroid Build Coastguard Worker}
2416*58b9f456SAndroid Build Coastguard Worker
2417*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
2418*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
2419*58b9f456SAndroid Build Coastguard Workerbool
2420*58b9f456SAndroid Build Coastguard Workeroperator!=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
2421*58b9f456SAndroid Build Coastguard Worker{
2422*58b9f456SAndroid Build Coastguard Worker    return !(__x == __y);
2423*58b9f456SAndroid Build Coastguard Worker}
2424*58b9f456SAndroid Build Coastguard Worker
2425*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
2426*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
2427*58b9f456SAndroid Build Coastguard Workerbool
2428*58b9f456SAndroid Build Coastguard Workeroperator> (const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
2429*58b9f456SAndroid Build Coastguard Worker{
2430*58b9f456SAndroid Build Coastguard Worker    return __y < __x;
2431*58b9f456SAndroid Build Coastguard Worker}
2432*58b9f456SAndroid Build Coastguard Worker
2433*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
2434*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
2435*58b9f456SAndroid Build Coastguard Workerbool
2436*58b9f456SAndroid Build Coastguard Workeroperator>=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
2437*58b9f456SAndroid Build Coastguard Worker{
2438*58b9f456SAndroid Build Coastguard Worker    return !(__x < __y);
2439*58b9f456SAndroid Build Coastguard Worker}
2440*58b9f456SAndroid Build Coastguard Worker
2441*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
2442*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
2443*58b9f456SAndroid Build Coastguard Workerbool
2444*58b9f456SAndroid Build Coastguard Workeroperator<=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
2445*58b9f456SAndroid Build Coastguard Worker{
2446*58b9f456SAndroid Build Coastguard Worker    return !(__y < __x);
2447*58b9f456SAndroid Build Coastguard Worker}
2448*58b9f456SAndroid Build Coastguard Worker
2449*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Alloc>
2450*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
2451*58b9f456SAndroid Build Coastguard Workervoid
2452*58b9f456SAndroid Build Coastguard Workerswap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y)
2453*58b9f456SAndroid Build Coastguard Worker    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
2454*58b9f456SAndroid Build Coastguard Worker{
2455*58b9f456SAndroid Build Coastguard Worker    __x.swap(__y);
2456*58b9f456SAndroid Build Coastguard Worker}
2457*58b9f456SAndroid Build Coastguard Worker
2458*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 17
2459*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator, class _Predicate>
2460*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
2461*58b9f456SAndroid Build Coastguard Workervoid erase_if(list<_Tp, _Allocator>& __c, _Predicate __pred)
2462*58b9f456SAndroid Build Coastguard Worker{ __c.remove_if(__pred); }
2463*58b9f456SAndroid Build Coastguard Worker
2464*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Allocator, class _Up>
2465*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
2466*58b9f456SAndroid Build Coastguard Workervoid erase(list<_Tp, _Allocator>& __c, const _Up& __v)
2467*58b9f456SAndroid Build Coastguard Worker{ _VSTD::erase_if(__c, [&](auto& __elem) { return __elem == __v; }); }
2468*58b9f456SAndroid Build Coastguard Worker#endif
2469*58b9f456SAndroid Build Coastguard Worker
2470*58b9f456SAndroid Build Coastguard Worker_LIBCPP_END_NAMESPACE_STD
2471*58b9f456SAndroid Build Coastguard Worker
2472*58b9f456SAndroid Build Coastguard Worker_LIBCPP_POP_MACROS
2473*58b9f456SAndroid Build Coastguard Worker
2474*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_LIST
2475