xref: /aosp_15_r20/external/libcxx/test/support/nasty_containers.hpp (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1*58b9f456SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
2*58b9f456SAndroid Build Coastguard Worker //
3*58b9f456SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*58b9f456SAndroid Build Coastguard Worker //
5*58b9f456SAndroid Build Coastguard Worker // This file is dual licensed under the MIT and the University of Illinois Open
6*58b9f456SAndroid Build Coastguard Worker // Source Licenses. See LICENSE.TXT for details.
7*58b9f456SAndroid Build Coastguard Worker //
8*58b9f456SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*58b9f456SAndroid Build Coastguard Worker 
10*58b9f456SAndroid Build Coastguard Worker #ifndef NASTY_CONTAINERS_H
11*58b9f456SAndroid Build Coastguard Worker #define NASTY_CONTAINERS_H
12*58b9f456SAndroid Build Coastguard Worker 
13*58b9f456SAndroid Build Coastguard Worker #include <cassert>
14*58b9f456SAndroid Build Coastguard Worker #include <vector>
15*58b9f456SAndroid Build Coastguard Worker #include <list>
16*58b9f456SAndroid Build Coastguard Worker 
17*58b9f456SAndroid Build Coastguard Worker #include "test_macros.h"
18*58b9f456SAndroid Build Coastguard Worker 
19*58b9f456SAndroid Build Coastguard Worker template <class T>
20*58b9f456SAndroid Build Coastguard Worker class nasty_vector
21*58b9f456SAndroid Build Coastguard Worker {
22*58b9f456SAndroid Build Coastguard Worker public:
23*58b9f456SAndroid Build Coastguard Worker     typedef typename std::vector<T>                           nested_container;
24*58b9f456SAndroid Build Coastguard Worker     typedef typename nested_container::value_type             value_type;
25*58b9f456SAndroid Build Coastguard Worker     typedef typename nested_container::reference              reference;
26*58b9f456SAndroid Build Coastguard Worker     typedef typename nested_container::const_reference        const_reference;
27*58b9f456SAndroid Build Coastguard Worker     typedef typename nested_container::iterator               iterator;
28*58b9f456SAndroid Build Coastguard Worker     typedef typename nested_container::const_iterator         const_iterator;
29*58b9f456SAndroid Build Coastguard Worker 
30*58b9f456SAndroid Build Coastguard Worker     typedef typename nested_container::size_type              size_type;
31*58b9f456SAndroid Build Coastguard Worker     typedef typename nested_container::difference_type        difference_type;
32*58b9f456SAndroid Build Coastguard Worker     typedef typename nested_container::pointer                pointer;
33*58b9f456SAndroid Build Coastguard Worker     typedef typename nested_container::const_pointer          const_pointer;
34*58b9f456SAndroid Build Coastguard Worker 
35*58b9f456SAndroid Build Coastguard Worker     typedef typename nested_container::reverse_iterator       reverse_iterator;
36*58b9f456SAndroid Build Coastguard Worker     typedef typename nested_container::const_reverse_iterator const_reverse_iterator;
37*58b9f456SAndroid Build Coastguard Worker 
nasty_vector()38*58b9f456SAndroid Build Coastguard Worker     nasty_vector() : v_() {}
nasty_vector(size_type n)39*58b9f456SAndroid Build Coastguard Worker     explicit nasty_vector(size_type n) : v_(n) {}
nasty_vector(size_type n,const value_type & value)40*58b9f456SAndroid Build Coastguard Worker     nasty_vector(size_type n, const value_type& value) : v_(n, value) {}
nasty_vector(InputIterator first,InputIterator last)41*58b9f456SAndroid Build Coastguard Worker     template <class InputIterator> nasty_vector(InputIterator first, InputIterator last) : v_(first, last) {}
42*58b9f456SAndroid Build Coastguard Worker #if TEST_STD_VER >= 11
nasty_vector(std::initializer_list<value_type> il)43*58b9f456SAndroid Build Coastguard Worker     nasty_vector(std::initializer_list<value_type> il) : v_(il) {}
44*58b9f456SAndroid Build Coastguard Worker #endif
~nasty_vector()45*58b9f456SAndroid Build Coastguard Worker     ~nasty_vector() {}
46*58b9f456SAndroid Build Coastguard Worker 
47*58b9f456SAndroid Build Coastguard Worker     template <class InputIterator>
assign(InputIterator first,InputIterator last)48*58b9f456SAndroid Build Coastguard Worker         void assign(InputIterator first, InputIterator last) { v_.assign(first, last); }
assign(size_type n,const value_type & u)49*58b9f456SAndroid Build Coastguard Worker     void assign(size_type n, const value_type& u) { v_.assign(n, u); }
50*58b9f456SAndroid Build Coastguard Worker #if TEST_STD_VER >= 11
assign(std::initializer_list<value_type> il)51*58b9f456SAndroid Build Coastguard Worker     void assign(std::initializer_list<value_type> il)  { v_.assign(il); }
52*58b9f456SAndroid Build Coastguard Worker #endif
53*58b9f456SAndroid Build Coastguard Worker 
begin()54*58b9f456SAndroid Build Coastguard Worker     iterator               begin() TEST_NOEXCEPT         { return v_.begin(); }
begin() const55*58b9f456SAndroid Build Coastguard Worker     const_iterator         begin()   const TEST_NOEXCEPT { return v_.begin(); }
end()56*58b9f456SAndroid Build Coastguard Worker     iterator               end() TEST_NOEXCEPT           { return v_.end(); }
end() const57*58b9f456SAndroid Build Coastguard Worker     const_iterator         end()     const TEST_NOEXCEPT { return v_.end(); }
58*58b9f456SAndroid Build Coastguard Worker 
rbegin()59*58b9f456SAndroid Build Coastguard Worker     reverse_iterator       rbegin() TEST_NOEXCEPT        { return v_.rbegin(); }
rbegin() const60*58b9f456SAndroid Build Coastguard Worker     const_reverse_iterator rbegin()  const TEST_NOEXCEPT { return v_.rbegin(); }
rend()61*58b9f456SAndroid Build Coastguard Worker     reverse_iterator       rend() TEST_NOEXCEPT          { return v_.rend(); }
rend() const62*58b9f456SAndroid Build Coastguard Worker     const_reverse_iterator rend()    const TEST_NOEXCEPT { return v_.rend(); }
63*58b9f456SAndroid Build Coastguard Worker 
cbegin() const64*58b9f456SAndroid Build Coastguard Worker     const_iterator         cbegin()  const TEST_NOEXCEPT { return v_.cbegin(); }
cend() const65*58b9f456SAndroid Build Coastguard Worker     const_iterator         cend()    const TEST_NOEXCEPT { return v_.cend(); }
crbegin() const66*58b9f456SAndroid Build Coastguard Worker     const_reverse_iterator crbegin() const TEST_NOEXCEPT { return v_.crbegin(); }
crend() const67*58b9f456SAndroid Build Coastguard Worker     const_reverse_iterator crend()   const TEST_NOEXCEPT { return v_.crend(); }
68*58b9f456SAndroid Build Coastguard Worker 
size() const69*58b9f456SAndroid Build Coastguard Worker     size_type size() const TEST_NOEXCEPT      { return v_.size(); }
max_size() const70*58b9f456SAndroid Build Coastguard Worker     size_type max_size() const TEST_NOEXCEPT  { return v_.max_size(); }
capacity() const71*58b9f456SAndroid Build Coastguard Worker     size_type capacity() const TEST_NOEXCEPT  { return v_.capacity(); }
empty() const72*58b9f456SAndroid Build Coastguard Worker     bool empty() const TEST_NOEXCEPT          { return v_.empty(); }
reserve(size_type n)73*58b9f456SAndroid Build Coastguard Worker     void reserve(size_type n)             { v_.reserve(n); };
shrink_to_fit()74*58b9f456SAndroid Build Coastguard Worker     void shrink_to_fit() TEST_NOEXCEPT        { v_.shrink_to_fit(); }
75*58b9f456SAndroid Build Coastguard Worker 
operator [](size_type n)76*58b9f456SAndroid Build Coastguard Worker     reference       operator[](size_type n)       { return v_[n]; }
operator [](size_type n) const77*58b9f456SAndroid Build Coastguard Worker     const_reference operator[](size_type n) const { return v_[n]; }
at(size_type n)78*58b9f456SAndroid Build Coastguard Worker     reference       at(size_type n)               { return v_.at(n); }
at(size_type n) const79*58b9f456SAndroid Build Coastguard Worker     const_reference at(size_type n) const         { return v_.at(n); }
80*58b9f456SAndroid Build Coastguard Worker 
front()81*58b9f456SAndroid Build Coastguard Worker     reference       front()       { return v_.front(); }
front() const82*58b9f456SAndroid Build Coastguard Worker     const_reference front() const { return v_.front(); }
back()83*58b9f456SAndroid Build Coastguard Worker     reference       back()        { return v_.back(); }
back() const84*58b9f456SAndroid Build Coastguard Worker     const_reference back() const  { return v_.back(); }
85*58b9f456SAndroid Build Coastguard Worker 
data()86*58b9f456SAndroid Build Coastguard Worker     value_type*       data() TEST_NOEXCEPT       { return v_.data(); }
data() const87*58b9f456SAndroid Build Coastguard Worker     const value_type* data() const TEST_NOEXCEPT { return v_.data(); }
88*58b9f456SAndroid Build Coastguard Worker 
push_back(const value_type & x)89*58b9f456SAndroid Build Coastguard Worker     void push_back(const value_type& x)     { v_.push_back(x); }
90*58b9f456SAndroid Build Coastguard Worker #if TEST_STD_VER >= 11
push_back(value_type && x)91*58b9f456SAndroid Build Coastguard Worker     void push_back(value_type&& x)          { v_.push_back(std::forward<value_type&&>(x)); }
92*58b9f456SAndroid Build Coastguard Worker     template <class... Args>
emplace_back(Args &&...args)93*58b9f456SAndroid Build Coastguard Worker         void emplace_back(Args&&... args)   { v_.emplace_back(std::forward<Args>(args)...); }
94*58b9f456SAndroid Build Coastguard Worker #endif
pop_back()95*58b9f456SAndroid Build Coastguard Worker     void pop_back()                         { v_.pop_back(); }
96*58b9f456SAndroid Build Coastguard Worker 
97*58b9f456SAndroid Build Coastguard Worker #if TEST_STD_VER >= 11
emplace(const_iterator pos,Args &&...args)98*58b9f456SAndroid Build Coastguard Worker     template <class... Args> iterator emplace(const_iterator pos, Args&&... args)
99*58b9f456SAndroid Build Coastguard Worker     { return v_.emplace(pos, std::forward<Args>(args)...); }
100*58b9f456SAndroid Build Coastguard Worker #endif
101*58b9f456SAndroid Build Coastguard Worker 
insert(const_iterator pos,const value_type & x)102*58b9f456SAndroid Build Coastguard Worker     iterator insert(const_iterator pos, const value_type& x) { return v_.insert(pos, x); }
103*58b9f456SAndroid Build Coastguard Worker #if TEST_STD_VER >= 11
insert(const_iterator pos,value_type && x)104*58b9f456SAndroid Build Coastguard Worker     iterator insert(const_iterator pos, value_type&& x)      { return v_.insert(pos, std::forward<value_type>(x)); }
105*58b9f456SAndroid Build Coastguard Worker #endif
insert(const_iterator pos,size_type n,const value_type & x)106*58b9f456SAndroid Build Coastguard Worker     iterator insert(const_iterator pos, size_type n, const value_type& x) { return v_.insert(pos, n, x); }
107*58b9f456SAndroid Build Coastguard Worker     template <class InputIterator>
insert(const_iterator pos,InputIterator first,InputIterator last)108*58b9f456SAndroid Build Coastguard Worker         iterator insert(const_iterator pos, InputIterator first, InputIterator last)
109*58b9f456SAndroid Build Coastguard Worker     { return v_.insert(pos, first, last); }
110*58b9f456SAndroid Build Coastguard Worker 
111*58b9f456SAndroid Build Coastguard Worker #if TEST_STD_VER >= 11
insert(const_iterator pos,std::initializer_list<value_type> il)112*58b9f456SAndroid Build Coastguard Worker     iterator insert(const_iterator pos, std::initializer_list<value_type> il) { return v_.insert(pos, il); }
113*58b9f456SAndroid Build Coastguard Worker #endif
114*58b9f456SAndroid Build Coastguard Worker 
erase(const_iterator pos)115*58b9f456SAndroid Build Coastguard Worker     iterator erase(const_iterator pos)                        { return v_.erase(pos); }
erase(const_iterator first,const_iterator last)116*58b9f456SAndroid Build Coastguard Worker     iterator erase(const_iterator first, const_iterator last) { return v_.erase(first, last); }
117*58b9f456SAndroid Build Coastguard Worker 
clear()118*58b9f456SAndroid Build Coastguard Worker     void clear() TEST_NOEXCEPT { v_.clear(); }
119*58b9f456SAndroid Build Coastguard Worker 
resize(size_type sz)120*58b9f456SAndroid Build Coastguard Worker     void resize(size_type sz)                      { v_.resize(sz); }
resize(size_type sz,const value_type & c)121*58b9f456SAndroid Build Coastguard Worker     void resize(size_type sz, const value_type& c) { v_.resize(sz, c); }
122*58b9f456SAndroid Build Coastguard Worker 
swap(nasty_vector & nv)123*58b9f456SAndroid Build Coastguard Worker     void swap(nasty_vector &nv)
124*58b9f456SAndroid Build Coastguard Worker #if TEST_STD_VER > 14
125*58b9f456SAndroid Build Coastguard Worker     noexcept(std::is_nothrow_swappable<nested_container>::value)
126*58b9f456SAndroid Build Coastguard Worker #elif defined(_LIBCPP_VERSION)
127*58b9f456SAndroid Build Coastguard Worker     TEST_NOEXCEPT_COND(std::__is_nothrow_swappable<nested_container>::value)
128*58b9f456SAndroid Build Coastguard Worker #endif
129*58b9f456SAndroid Build Coastguard Worker     { v_.swap(nv.v_); }
130*58b9f456SAndroid Build Coastguard Worker 
operator &()131*58b9f456SAndroid Build Coastguard Worker     nasty_vector *operator &()             { assert(false); return nullptr; }  // nasty
operator &() const132*58b9f456SAndroid Build Coastguard Worker     const nasty_vector *operator &() const { assert(false); return nullptr; }  // nasty
133*58b9f456SAndroid Build Coastguard Worker 
134*58b9f456SAndroid Build Coastguard Worker     nested_container v_;
135*58b9f456SAndroid Build Coastguard Worker };
136*58b9f456SAndroid Build Coastguard Worker 
137*58b9f456SAndroid Build Coastguard Worker template <class T>
operator ==(const nasty_vector<T> & x,const nasty_vector<T> & y)138*58b9f456SAndroid Build Coastguard Worker bool operator==(const nasty_vector<T>& x, const nasty_vector<T>& y) { return x.v_ == y.v_; }
139*58b9f456SAndroid Build Coastguard Worker 
140*58b9f456SAndroid Build Coastguard Worker template <class T>
141*58b9f456SAndroid Build Coastguard Worker class nasty_list
142*58b9f456SAndroid Build Coastguard Worker {
143*58b9f456SAndroid Build Coastguard Worker public:
144*58b9f456SAndroid Build Coastguard Worker 
145*58b9f456SAndroid Build Coastguard Worker     typedef typename std::list<T>                             nested_container;
146*58b9f456SAndroid Build Coastguard Worker     typedef typename nested_container::value_type             value_type;
147*58b9f456SAndroid Build Coastguard Worker     typedef typename nested_container::reference              reference;
148*58b9f456SAndroid Build Coastguard Worker     typedef typename nested_container::const_reference        const_reference;
149*58b9f456SAndroid Build Coastguard Worker     typedef typename nested_container::iterator               iterator;
150*58b9f456SAndroid Build Coastguard Worker     typedef typename nested_container::const_iterator         const_iterator;
151*58b9f456SAndroid Build Coastguard Worker 
152*58b9f456SAndroid Build Coastguard Worker     typedef typename nested_container::size_type              size_type;
153*58b9f456SAndroid Build Coastguard Worker     typedef typename nested_container::difference_type        difference_type;
154*58b9f456SAndroid Build Coastguard Worker     typedef typename nested_container::pointer                pointer;
155*58b9f456SAndroid Build Coastguard Worker     typedef typename nested_container::const_pointer          const_pointer;
156*58b9f456SAndroid Build Coastguard Worker 
157*58b9f456SAndroid Build Coastguard Worker     typedef typename nested_container::reverse_iterator       reverse_iterator;
158*58b9f456SAndroid Build Coastguard Worker     typedef typename nested_container::const_reverse_iterator const_reverse_iterator;
159*58b9f456SAndroid Build Coastguard Worker 
nasty_list()160*58b9f456SAndroid Build Coastguard Worker     nasty_list() : l_() {}
nasty_list(size_type n)161*58b9f456SAndroid Build Coastguard Worker     explicit nasty_list(size_type n)  : l_(n) {}
nasty_list(size_type n,const value_type & value)162*58b9f456SAndroid Build Coastguard Worker     nasty_list(size_type n, const value_type& value)  : l_(n,value) {}
163*58b9f456SAndroid Build Coastguard Worker     template <class Iter>
nasty_list(Iter first,Iter last)164*58b9f456SAndroid Build Coastguard Worker         nasty_list(Iter first, Iter last)  : l_(first, last) {}
165*58b9f456SAndroid Build Coastguard Worker #if TEST_STD_VER >= 11
nasty_list(std::initializer_list<value_type> il)166*58b9f456SAndroid Build Coastguard Worker     nasty_list(std::initializer_list<value_type> il) : l_(il) {}
167*58b9f456SAndroid Build Coastguard Worker #endif
168*58b9f456SAndroid Build Coastguard Worker 
~nasty_list()169*58b9f456SAndroid Build Coastguard Worker     ~nasty_list() {}
170*58b9f456SAndroid Build Coastguard Worker 
171*58b9f456SAndroid Build Coastguard Worker #if TEST_STD_VER >= 11
operator =(std::initializer_list<value_type> il)172*58b9f456SAndroid Build Coastguard Worker     nasty_list& operator=(std::initializer_list<value_type> il) { l_ = il; return *this; }
173*58b9f456SAndroid Build Coastguard Worker #endif
174*58b9f456SAndroid Build Coastguard Worker     template <class Iter>
assign(Iter first,Iter last)175*58b9f456SAndroid Build Coastguard Worker         void assign(Iter first, Iter last) { l_.assign(first, last); }
assign(size_type n,const value_type & t)176*58b9f456SAndroid Build Coastguard Worker     void assign(size_type n, const value_type& t) { l_.assign(n, t); }
177*58b9f456SAndroid Build Coastguard Worker #if TEST_STD_VER >= 11
assign(std::initializer_list<value_type> il)178*58b9f456SAndroid Build Coastguard Worker     void assign(std::initializer_list<value_type> il) { l_.assign(il); }
179*58b9f456SAndroid Build Coastguard Worker #endif
180*58b9f456SAndroid Build Coastguard Worker 
181*58b9f456SAndroid Build Coastguard Worker 
begin()182*58b9f456SAndroid Build Coastguard Worker     iterator               begin() TEST_NOEXCEPT         { return l_.begin(); }
begin() const183*58b9f456SAndroid Build Coastguard Worker     const_iterator         begin()   const TEST_NOEXCEPT { return l_.begin(); }
end()184*58b9f456SAndroid Build Coastguard Worker     iterator               end() TEST_NOEXCEPT           { return l_.end(); }
end() const185*58b9f456SAndroid Build Coastguard Worker     const_iterator         end()     const TEST_NOEXCEPT { return l_.end(); }
186*58b9f456SAndroid Build Coastguard Worker 
rbegin()187*58b9f456SAndroid Build Coastguard Worker     reverse_iterator       rbegin() TEST_NOEXCEPT        { return l_.rbegin(); }
rbegin() const188*58b9f456SAndroid Build Coastguard Worker     const_reverse_iterator rbegin()  const TEST_NOEXCEPT { return l_.rbegin(); }
rend()189*58b9f456SAndroid Build Coastguard Worker     reverse_iterator       rend() TEST_NOEXCEPT          { return l_.rend(); }
rend() const190*58b9f456SAndroid Build Coastguard Worker     const_reverse_iterator rend()    const TEST_NOEXCEPT { return l_.rend(); }
191*58b9f456SAndroid Build Coastguard Worker 
cbegin() const192*58b9f456SAndroid Build Coastguard Worker     const_iterator         cbegin()  const TEST_NOEXCEPT { return l_.cbegin(); }
cend() const193*58b9f456SAndroid Build Coastguard Worker     const_iterator         cend()    const TEST_NOEXCEPT { return l_.cend(); }
crbegin() const194*58b9f456SAndroid Build Coastguard Worker     const_reverse_iterator crbegin() const TEST_NOEXCEPT { return l_.crbegin(); }
crend() const195*58b9f456SAndroid Build Coastguard Worker     const_reverse_iterator crend()   const TEST_NOEXCEPT { return l_.crend(); }
196*58b9f456SAndroid Build Coastguard Worker 
front()197*58b9f456SAndroid Build Coastguard Worker     reference       front()       { return l_.front(); }
front() const198*58b9f456SAndroid Build Coastguard Worker     const_reference front() const { return l_.front(); }
back()199*58b9f456SAndroid Build Coastguard Worker     reference       back()        { return l_.back(); }
back() const200*58b9f456SAndroid Build Coastguard Worker     const_reference back() const  { return l_.back(); }
201*58b9f456SAndroid Build Coastguard Worker 
size() const202*58b9f456SAndroid Build Coastguard Worker     size_type size() const TEST_NOEXCEPT      { return l_.size(); }
max_size() const203*58b9f456SAndroid Build Coastguard Worker     size_type max_size() const TEST_NOEXCEPT  { return l_.max_size(); }
empty() const204*58b9f456SAndroid Build Coastguard Worker     bool empty() const TEST_NOEXCEPT          { return l_.empty(); }
205*58b9f456SAndroid Build Coastguard Worker 
push_front(const value_type & x)206*58b9f456SAndroid Build Coastguard Worker     void push_front(const value_type& x)    { l_.push_front(x); }
push_back(const value_type & x)207*58b9f456SAndroid Build Coastguard Worker     void push_back(const value_type& x)     { l_.push_back(x); }
208*58b9f456SAndroid Build Coastguard Worker #if TEST_STD_VER >= 11
push_back(value_type && x)209*58b9f456SAndroid Build Coastguard Worker     void push_back(value_type&& x)          { l_.push_back(std::forward<value_type&&>(x)); }
push_front(value_type && x)210*58b9f456SAndroid Build Coastguard Worker     void push_front(value_type&& x)         { l_.push_back(std::forward<value_type&&>(x)); }
211*58b9f456SAndroid Build Coastguard Worker     template <class... Args>
emplace_back(Args &&...args)212*58b9f456SAndroid Build Coastguard Worker         void emplace_back(Args&&... args)   { l_.emplace_back(std::forward<Args>(args)...); }
213*58b9f456SAndroid Build Coastguard Worker     template <class... Args>
emplace_front(Args &&...args)214*58b9f456SAndroid Build Coastguard Worker         void emplace_front(Args&&... args)  { l_.emplace_front(std::forward<Args>(args)...); }
215*58b9f456SAndroid Build Coastguard Worker #endif
pop_front()216*58b9f456SAndroid Build Coastguard Worker     void pop_front()                        { l_.pop_front(); }
pop_back()217*58b9f456SAndroid Build Coastguard Worker     void pop_back()                         { l_.pop_back(); }
218*58b9f456SAndroid Build Coastguard Worker 
219*58b9f456SAndroid Build Coastguard Worker #if TEST_STD_VER >= 11
emplace(const_iterator pos,Args &&...args)220*58b9f456SAndroid Build Coastguard Worker     template <class... Args> iterator emplace(const_iterator pos, Args&&... args)
221*58b9f456SAndroid Build Coastguard Worker     { return l_.emplace(pos, std::forward<Args>(args)...); }
222*58b9f456SAndroid Build Coastguard Worker #endif
223*58b9f456SAndroid Build Coastguard Worker 
insert(const_iterator pos,const value_type & x)224*58b9f456SAndroid Build Coastguard Worker     iterator insert(const_iterator pos, const value_type& x) { return l_.insert(pos, x); }
225*58b9f456SAndroid Build Coastguard Worker #if TEST_STD_VER >= 11
insert(const_iterator pos,value_type && x)226*58b9f456SAndroid Build Coastguard Worker     iterator insert(const_iterator pos, value_type&& x)      { return l_.insert(pos, std::forward<value_type>(x)); }
227*58b9f456SAndroid Build Coastguard Worker #endif
insert(const_iterator pos,size_type n,const value_type & x)228*58b9f456SAndroid Build Coastguard Worker     iterator insert(const_iterator pos, size_type n, const value_type& x) { return l_.insert(pos, n, x); }
229*58b9f456SAndroid Build Coastguard Worker     template <class InputIterator>
insert(const_iterator pos,InputIterator first,InputIterator last)230*58b9f456SAndroid Build Coastguard Worker         iterator insert(const_iterator pos, InputIterator first, InputIterator last)
231*58b9f456SAndroid Build Coastguard Worker     { return l_.insert(pos, first, last); }
232*58b9f456SAndroid Build Coastguard Worker 
233*58b9f456SAndroid Build Coastguard Worker #if TEST_STD_VER >= 11
insert(const_iterator pos,std::initializer_list<value_type> il)234*58b9f456SAndroid Build Coastguard Worker     iterator insert(const_iterator pos, std::initializer_list<value_type> il) { return l_.insert(pos, il); }
235*58b9f456SAndroid Build Coastguard Worker #endif
236*58b9f456SAndroid Build Coastguard Worker 
erase(const_iterator pos)237*58b9f456SAndroid Build Coastguard Worker     iterator erase(const_iterator pos)                      { return l_.erase(pos); }
erase(const_iterator pos,const_iterator last)238*58b9f456SAndroid Build Coastguard Worker     iterator erase(const_iterator pos, const_iterator last) { return l_.erase(pos, last); }
239*58b9f456SAndroid Build Coastguard Worker 
resize(size_type)240*58b9f456SAndroid Build Coastguard Worker     void resize(size_type)                      { l_.resize(); }
resize(size_type,const value_type & c)241*58b9f456SAndroid Build Coastguard Worker     void resize(size_type, const value_type& c) { l_.resize(c); }
242*58b9f456SAndroid Build Coastguard Worker 
swap(nasty_list & nl)243*58b9f456SAndroid Build Coastguard Worker     void swap(nasty_list &nl)
244*58b9f456SAndroid Build Coastguard Worker #if TEST_STD_VER > 14
245*58b9f456SAndroid Build Coastguard Worker     noexcept(std::is_nothrow_swappable<nested_container>::value)
246*58b9f456SAndroid Build Coastguard Worker #elif defined(_LIBCPP_VERSION)
247*58b9f456SAndroid Build Coastguard Worker     TEST_NOEXCEPT_COND(std::__is_nothrow_swappable<nested_container>::value)
248*58b9f456SAndroid Build Coastguard Worker #endif
249*58b9f456SAndroid Build Coastguard Worker     { l_.swap(nl.l_); }
250*58b9f456SAndroid Build Coastguard Worker 
clear()251*58b9f456SAndroid Build Coastguard Worker     void clear() TEST_NOEXCEPT { l_.clear(); }
252*58b9f456SAndroid Build Coastguard Worker 
253*58b9f456SAndroid Build Coastguard Worker //     void splice(const_iterator position, list& x);
254*58b9f456SAndroid Build Coastguard Worker //     void splice(const_iterator position, list&& x);
255*58b9f456SAndroid Build Coastguard Worker //     void splice(const_iterator position, list& x, const_iterator i);
256*58b9f456SAndroid Build Coastguard Worker //     void splice(const_iterator position, list&& x, const_iterator i);
257*58b9f456SAndroid Build Coastguard Worker //     void splice(const_iterator position, list& x, const_iterator first,
258*58b9f456SAndroid Build Coastguard Worker //                                                   const_iterator last);
259*58b9f456SAndroid Build Coastguard Worker //     void splice(const_iterator position, list&& x, const_iterator first,
260*58b9f456SAndroid Build Coastguard Worker //                                                   const_iterator last);
261*58b9f456SAndroid Build Coastguard Worker //
262*58b9f456SAndroid Build Coastguard Worker //     void remove(const value_type& value);
263*58b9f456SAndroid Build Coastguard Worker //     template <class Pred> void remove_if(Pred pred);
264*58b9f456SAndroid Build Coastguard Worker //     void unique();
265*58b9f456SAndroid Build Coastguard Worker //     template <class BinaryPredicate>
266*58b9f456SAndroid Build Coastguard Worker //         void unique(BinaryPredicate binary_pred);
267*58b9f456SAndroid Build Coastguard Worker //     void merge(list& x);
268*58b9f456SAndroid Build Coastguard Worker //     void merge(list&& x);
269*58b9f456SAndroid Build Coastguard Worker //     template <class Compare>
270*58b9f456SAndroid Build Coastguard Worker //         void merge(list& x, Compare comp);
271*58b9f456SAndroid Build Coastguard Worker //     template <class Compare>
272*58b9f456SAndroid Build Coastguard Worker //         void merge(list&& x, Compare comp);
273*58b9f456SAndroid Build Coastguard Worker //     void sort();
274*58b9f456SAndroid Build Coastguard Worker //     template <class Compare>
275*58b9f456SAndroid Build Coastguard Worker //         void sort(Compare comp);
276*58b9f456SAndroid Build Coastguard Worker //     void reverse() noexcept;
277*58b9f456SAndroid Build Coastguard Worker 
operator &()278*58b9f456SAndroid Build Coastguard Worker     nasty_list *operator &()             { assert(false); return nullptr; }  // nasty
operator &() const279*58b9f456SAndroid Build Coastguard Worker     const nasty_list *operator &() const { assert(false); return nullptr; }  // nasty
280*58b9f456SAndroid Build Coastguard Worker 
281*58b9f456SAndroid Build Coastguard Worker     nested_container l_;
282*58b9f456SAndroid Build Coastguard Worker };
283*58b9f456SAndroid Build Coastguard Worker 
284*58b9f456SAndroid Build Coastguard Worker template <class T>
operator ==(const nasty_list<T> & x,const nasty_list<T> & y)285*58b9f456SAndroid Build Coastguard Worker bool operator==(const nasty_list<T>& x, const nasty_list<T>& y) { return x.l_ == y.l_; }
286*58b9f456SAndroid Build Coastguard Worker 
287*58b9f456SAndroid Build Coastguard Worker // Not really a mutex, but can play one in tests
288*58b9f456SAndroid Build Coastguard Worker class nasty_mutex
289*58b9f456SAndroid Build Coastguard Worker {
290*58b9f456SAndroid Build Coastguard Worker public:
nasty_mutex()291*58b9f456SAndroid Build Coastguard Worker      nasty_mutex() TEST_NOEXCEPT {}
~nasty_mutex()292*58b9f456SAndroid Build Coastguard Worker      ~nasty_mutex() {}
293*58b9f456SAndroid Build Coastguard Worker 
operator &()294*58b9f456SAndroid Build Coastguard Worker     nasty_mutex *operator& ()   { assert(false); return nullptr; }
295*58b9f456SAndroid Build Coastguard Worker     template <typename T>
operator ,(const T &)296*58b9f456SAndroid Build Coastguard Worker     void operator, (const T &) { assert(false); }
297*58b9f456SAndroid Build Coastguard Worker 
298*58b9f456SAndroid Build Coastguard Worker private:
nasty_mutex(const nasty_mutex &)299*58b9f456SAndroid Build Coastguard Worker     nasty_mutex(const nasty_mutex&)            { assert(false); }
operator =(const nasty_mutex &)300*58b9f456SAndroid Build Coastguard Worker     nasty_mutex& operator=(const nasty_mutex&) { assert(false); return *this; }
301*58b9f456SAndroid Build Coastguard Worker 
302*58b9f456SAndroid Build Coastguard Worker public:
lock()303*58b9f456SAndroid Build Coastguard Worker     void lock()               {}
try_lock()304*58b9f456SAndroid Build Coastguard Worker     bool try_lock() TEST_NOEXCEPT { return true; }
unlock()305*58b9f456SAndroid Build Coastguard Worker     void unlock() TEST_NOEXCEPT   {}
306*58b9f456SAndroid Build Coastguard Worker 
307*58b9f456SAndroid Build Coastguard Worker     // Shared ownership
lock_shared()308*58b9f456SAndroid Build Coastguard Worker     void lock_shared()     {}
try_lock_shared()309*58b9f456SAndroid Build Coastguard Worker     bool try_lock_shared() { return true; }
unlock_shared()310*58b9f456SAndroid Build Coastguard Worker     void unlock_shared()   {}
311*58b9f456SAndroid Build Coastguard Worker };
312*58b9f456SAndroid Build Coastguard Worker 
313*58b9f456SAndroid Build Coastguard Worker #endif
314