xref: /aosp_15_r20/external/libcxx/include/string (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1*58b9f456SAndroid Build Coastguard Worker// -*- C++ -*-
2*58b9f456SAndroid Build Coastguard Worker//===--------------------------- string -----------------------------------===//
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 distributed under the University of Illinois Open Source
7*58b9f456SAndroid Build Coastguard Worker// License. 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_STRING
12*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP_STRING
13*58b9f456SAndroid Build Coastguard Worker
14*58b9f456SAndroid Build Coastguard Worker/*
15*58b9f456SAndroid Build Coastguard Worker    string 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 stateT>
21*58b9f456SAndroid Build Coastguard Workerclass fpos
22*58b9f456SAndroid Build Coastguard Worker{
23*58b9f456SAndroid Build Coastguard Workerprivate:
24*58b9f456SAndroid Build Coastguard Worker    stateT st;
25*58b9f456SAndroid Build Coastguard Workerpublic:
26*58b9f456SAndroid Build Coastguard Worker    fpos(streamoff = streamoff());
27*58b9f456SAndroid Build Coastguard Worker
28*58b9f456SAndroid Build Coastguard Worker    operator streamoff() const;
29*58b9f456SAndroid Build Coastguard Worker
30*58b9f456SAndroid Build Coastguard Worker    stateT state() const;
31*58b9f456SAndroid Build Coastguard Worker    void state(stateT);
32*58b9f456SAndroid Build Coastguard Worker
33*58b9f456SAndroid Build Coastguard Worker    fpos& operator+=(streamoff);
34*58b9f456SAndroid Build Coastguard Worker    fpos  operator+ (streamoff) const;
35*58b9f456SAndroid Build Coastguard Worker    fpos& operator-=(streamoff);
36*58b9f456SAndroid Build Coastguard Worker    fpos  operator- (streamoff) const;
37*58b9f456SAndroid Build Coastguard Worker};
38*58b9f456SAndroid Build Coastguard Worker
39*58b9f456SAndroid Build Coastguard Workertemplate <class stateT> streamoff operator-(const fpos<stateT>& x, const fpos<stateT>& y);
40*58b9f456SAndroid Build Coastguard Worker
41*58b9f456SAndroid Build Coastguard Workertemplate <class stateT> bool operator==(const fpos<stateT>& x, const fpos<stateT>& y);
42*58b9f456SAndroid Build Coastguard Workertemplate <class stateT> bool operator!=(const fpos<stateT>& x, const fpos<stateT>& y);
43*58b9f456SAndroid Build Coastguard Worker
44*58b9f456SAndroid Build Coastguard Workertemplate <class charT>
45*58b9f456SAndroid Build Coastguard Workerstruct char_traits
46*58b9f456SAndroid Build Coastguard Worker{
47*58b9f456SAndroid Build Coastguard Worker    typedef charT     char_type;
48*58b9f456SAndroid Build Coastguard Worker    typedef ...       int_type;
49*58b9f456SAndroid Build Coastguard Worker    typedef streamoff off_type;
50*58b9f456SAndroid Build Coastguard Worker    typedef streampos pos_type;
51*58b9f456SAndroid Build Coastguard Worker    typedef mbstate_t state_type;
52*58b9f456SAndroid Build Coastguard Worker
53*58b9f456SAndroid Build Coastguard Worker    static void assign(char_type& c1, const char_type& c2) noexcept;
54*58b9f456SAndroid Build Coastguard Worker    static constexpr bool eq(char_type c1, char_type c2) noexcept;
55*58b9f456SAndroid Build Coastguard Worker    static constexpr bool lt(char_type c1, char_type c2) noexcept;
56*58b9f456SAndroid Build Coastguard Worker
57*58b9f456SAndroid Build Coastguard Worker    static int              compare(const char_type* s1, const char_type* s2, size_t n);
58*58b9f456SAndroid Build Coastguard Worker    static size_t           length(const char_type* s);
59*58b9f456SAndroid Build Coastguard Worker    static const char_type* find(const char_type* s, size_t n, const char_type& a);
60*58b9f456SAndroid Build Coastguard Worker    static char_type*       move(char_type* s1, const char_type* s2, size_t n);
61*58b9f456SAndroid Build Coastguard Worker    static char_type*       copy(char_type* s1, const char_type* s2, size_t n);
62*58b9f456SAndroid Build Coastguard Worker    static char_type*       assign(char_type* s, size_t n, char_type a);
63*58b9f456SAndroid Build Coastguard Worker
64*58b9f456SAndroid Build Coastguard Worker    static constexpr int_type  not_eof(int_type c) noexcept;
65*58b9f456SAndroid Build Coastguard Worker    static constexpr char_type to_char_type(int_type c) noexcept;
66*58b9f456SAndroid Build Coastguard Worker    static constexpr int_type  to_int_type(char_type c) noexcept;
67*58b9f456SAndroid Build Coastguard Worker    static constexpr bool      eq_int_type(int_type c1, int_type c2) noexcept;
68*58b9f456SAndroid Build Coastguard Worker    static constexpr int_type  eof() noexcept;
69*58b9f456SAndroid Build Coastguard Worker};
70*58b9f456SAndroid Build Coastguard Worker
71*58b9f456SAndroid Build Coastguard Workertemplate <> struct char_traits<char>;
72*58b9f456SAndroid Build Coastguard Workertemplate <> struct char_traits<wchar_t>;
73*58b9f456SAndroid Build Coastguard Worker
74*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
75*58b9f456SAndroid Build Coastguard Workerclass basic_string
76*58b9f456SAndroid Build Coastguard Worker{
77*58b9f456SAndroid Build Coastguard Workerpublic:
78*58b9f456SAndroid Build Coastguard Worker// types:
79*58b9f456SAndroid Build Coastguard Worker    typedef traits traits_type;
80*58b9f456SAndroid Build Coastguard Worker    typedef typename traits_type::char_type value_type;
81*58b9f456SAndroid Build Coastguard Worker    typedef Allocator allocator_type;
82*58b9f456SAndroid Build Coastguard Worker    typedef typename allocator_type::size_type size_type;
83*58b9f456SAndroid Build Coastguard Worker    typedef typename allocator_type::difference_type difference_type;
84*58b9f456SAndroid Build Coastguard Worker    typedef typename allocator_type::reference reference;
85*58b9f456SAndroid Build Coastguard Worker    typedef typename allocator_type::const_reference const_reference;
86*58b9f456SAndroid Build Coastguard Worker    typedef typename allocator_type::pointer pointer;
87*58b9f456SAndroid Build Coastguard Worker    typedef typename allocator_type::const_pointer const_pointer;
88*58b9f456SAndroid Build Coastguard Worker    typedef implementation-defined iterator;
89*58b9f456SAndroid Build Coastguard Worker    typedef implementation-defined const_iterator;
90*58b9f456SAndroid Build Coastguard Worker    typedef std::reverse_iterator<iterator> reverse_iterator;
91*58b9f456SAndroid Build Coastguard Worker    typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
92*58b9f456SAndroid Build Coastguard Worker
93*58b9f456SAndroid Build Coastguard Worker    static const size_type npos = -1;
94*58b9f456SAndroid Build Coastguard Worker
95*58b9f456SAndroid Build Coastguard Worker    basic_string()
96*58b9f456SAndroid Build Coastguard Worker        noexcept(is_nothrow_default_constructible<allocator_type>::value);
97*58b9f456SAndroid Build Coastguard Worker    explicit basic_string(const allocator_type& a);
98*58b9f456SAndroid Build Coastguard Worker    basic_string(const basic_string& str);
99*58b9f456SAndroid Build Coastguard Worker    basic_string(basic_string&& str)
100*58b9f456SAndroid Build Coastguard Worker        noexcept(is_nothrow_move_constructible<allocator_type>::value);
101*58b9f456SAndroid Build Coastguard Worker    basic_string(const basic_string& str, size_type pos,
102*58b9f456SAndroid Build Coastguard Worker                 const allocator_type& a = allocator_type());
103*58b9f456SAndroid Build Coastguard Worker    basic_string(const basic_string& str, size_type pos, size_type n,
104*58b9f456SAndroid Build Coastguard Worker                 const Allocator& a = Allocator());
105*58b9f456SAndroid Build Coastguard Worker    template<class T>
106*58b9f456SAndroid Build Coastguard Worker        basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator()); // C++17
107*58b9f456SAndroid Build Coastguard Worker    template <class T>
108*58b9f456SAndroid Build Coastguard Worker        explicit basic_string(const T& t, const Allocator& a = Allocator()); // C++17
109*58b9f456SAndroid Build Coastguard Worker    basic_string(const value_type* s, const allocator_type& a = allocator_type());
110*58b9f456SAndroid Build Coastguard Worker    basic_string(const value_type* s, size_type n, const allocator_type& a = allocator_type());
111*58b9f456SAndroid Build Coastguard Worker    basic_string(size_type n, value_type c, const allocator_type& a = allocator_type());
112*58b9f456SAndroid Build Coastguard Worker    template<class InputIterator>
113*58b9f456SAndroid Build Coastguard Worker        basic_string(InputIterator begin, InputIterator end,
114*58b9f456SAndroid Build Coastguard Worker                     const allocator_type& a = allocator_type());
115*58b9f456SAndroid Build Coastguard Worker    basic_string(initializer_list<value_type>, const Allocator& = Allocator());
116*58b9f456SAndroid Build Coastguard Worker    basic_string(const basic_string&, const Allocator&);
117*58b9f456SAndroid Build Coastguard Worker    basic_string(basic_string&&, const Allocator&);
118*58b9f456SAndroid Build Coastguard Worker
119*58b9f456SAndroid Build Coastguard Worker    ~basic_string();
120*58b9f456SAndroid Build Coastguard Worker
121*58b9f456SAndroid Build Coastguard Worker    operator basic_string_view<charT, traits>() const noexcept;
122*58b9f456SAndroid Build Coastguard Worker
123*58b9f456SAndroid Build Coastguard Worker    basic_string& operator=(const basic_string& str);
124*58b9f456SAndroid Build Coastguard Worker    template <class T>
125*58b9f456SAndroid Build Coastguard Worker        basic_string& operator=(const T& t); // C++17
126*58b9f456SAndroid Build Coastguard Worker    basic_string& operator=(basic_string&& str)
127*58b9f456SAndroid Build Coastguard Worker        noexcept(
128*58b9f456SAndroid Build Coastguard Worker             allocator_type::propagate_on_container_move_assignment::value ||
129*58b9f456SAndroid Build Coastguard Worker             allocator_type::is_always_equal::value ); // C++17
130*58b9f456SAndroid Build Coastguard Worker    basic_string& operator=(const value_type* s);
131*58b9f456SAndroid Build Coastguard Worker    basic_string& operator=(value_type c);
132*58b9f456SAndroid Build Coastguard Worker    basic_string& operator=(initializer_list<value_type>);
133*58b9f456SAndroid Build Coastguard Worker
134*58b9f456SAndroid Build Coastguard Worker    iterator       begin() noexcept;
135*58b9f456SAndroid Build Coastguard Worker    const_iterator begin() const noexcept;
136*58b9f456SAndroid Build Coastguard Worker    iterator       end() noexcept;
137*58b9f456SAndroid Build Coastguard Worker    const_iterator end() const noexcept;
138*58b9f456SAndroid Build Coastguard Worker
139*58b9f456SAndroid Build Coastguard Worker    reverse_iterator       rbegin() noexcept;
140*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator rbegin() const noexcept;
141*58b9f456SAndroid Build Coastguard Worker    reverse_iterator       rend() noexcept;
142*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator rend() const noexcept;
143*58b9f456SAndroid Build Coastguard Worker
144*58b9f456SAndroid Build Coastguard Worker    const_iterator         cbegin() const noexcept;
145*58b9f456SAndroid Build Coastguard Worker    const_iterator         cend() const noexcept;
146*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator crbegin() const noexcept;
147*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator crend() const noexcept;
148*58b9f456SAndroid Build Coastguard Worker
149*58b9f456SAndroid Build Coastguard Worker    size_type size() const noexcept;
150*58b9f456SAndroid Build Coastguard Worker    size_type length() const noexcept;
151*58b9f456SAndroid Build Coastguard Worker    size_type max_size() const noexcept;
152*58b9f456SAndroid Build Coastguard Worker    size_type capacity() const noexcept;
153*58b9f456SAndroid Build Coastguard Worker
154*58b9f456SAndroid Build Coastguard Worker    void resize(size_type n, value_type c);
155*58b9f456SAndroid Build Coastguard Worker    void resize(size_type n);
156*58b9f456SAndroid Build Coastguard Worker
157*58b9f456SAndroid Build Coastguard Worker    void reserve(size_type res_arg = 0);
158*58b9f456SAndroid Build Coastguard Worker    void shrink_to_fit();
159*58b9f456SAndroid Build Coastguard Worker    void clear() noexcept;
160*58b9f456SAndroid Build Coastguard Worker    bool empty() const noexcept;
161*58b9f456SAndroid Build Coastguard Worker
162*58b9f456SAndroid Build Coastguard Worker    const_reference operator[](size_type pos) const;
163*58b9f456SAndroid Build Coastguard Worker    reference       operator[](size_type pos);
164*58b9f456SAndroid Build Coastguard Worker
165*58b9f456SAndroid Build Coastguard Worker    const_reference at(size_type n) const;
166*58b9f456SAndroid Build Coastguard Worker    reference       at(size_type n);
167*58b9f456SAndroid Build Coastguard Worker
168*58b9f456SAndroid Build Coastguard Worker    basic_string& operator+=(const basic_string& str);
169*58b9f456SAndroid Build Coastguard Worker    template <class T>
170*58b9f456SAndroid Build Coastguard Worker        basic_string& operator+=(const T& t);              // C++17
171*58b9f456SAndroid Build Coastguard Worker    basic_string& operator+=(const value_type* s);
172*58b9f456SAndroid Build Coastguard Worker    basic_string& operator+=(value_type c);
173*58b9f456SAndroid Build Coastguard Worker    basic_string& operator+=(initializer_list<value_type>);
174*58b9f456SAndroid Build Coastguard Worker
175*58b9f456SAndroid Build Coastguard Worker    basic_string& append(const basic_string& str);
176*58b9f456SAndroid Build Coastguard Worker    template <class T>
177*58b9f456SAndroid Build Coastguard Worker        basic_string& append(const T& t);                 // C++17
178*58b9f456SAndroid Build Coastguard Worker    basic_string& append(const basic_string& str, size_type pos, size_type n=npos); //C++14
179*58b9f456SAndroid Build Coastguard Worker    template <class T>
180*58b9f456SAndroid Build Coastguard Worker        basic_string& append(const T& t, size_type pos, size_type n=npos); // C++17
181*58b9f456SAndroid Build Coastguard Worker    basic_string& append(const value_type* s, size_type n);
182*58b9f456SAndroid Build Coastguard Worker    basic_string& append(const value_type* s);
183*58b9f456SAndroid Build Coastguard Worker    basic_string& append(size_type n, value_type c);
184*58b9f456SAndroid Build Coastguard Worker    template<class InputIterator>
185*58b9f456SAndroid Build Coastguard Worker        basic_string& append(InputIterator first, InputIterator last);
186*58b9f456SAndroid Build Coastguard Worker    basic_string& append(initializer_list<value_type>);
187*58b9f456SAndroid Build Coastguard Worker
188*58b9f456SAndroid Build Coastguard Worker    void push_back(value_type c);
189*58b9f456SAndroid Build Coastguard Worker    void pop_back();
190*58b9f456SAndroid Build Coastguard Worker    reference       front();
191*58b9f456SAndroid Build Coastguard Worker    const_reference front() const;
192*58b9f456SAndroid Build Coastguard Worker    reference       back();
193*58b9f456SAndroid Build Coastguard Worker    const_reference back() const;
194*58b9f456SAndroid Build Coastguard Worker
195*58b9f456SAndroid Build Coastguard Worker    basic_string& assign(const basic_string& str);
196*58b9f456SAndroid Build Coastguard Worker    template <class T>
197*58b9f456SAndroid Build Coastguard Worker        basic_string& assign(const T& t);  // C++17
198*58b9f456SAndroid Build Coastguard Worker    basic_string& assign(basic_string&& str);
199*58b9f456SAndroid Build Coastguard Worker    basic_string& assign(const basic_string& str, size_type pos, size_type n=npos); // C++14
200*58b9f456SAndroid Build Coastguard Worker    template <class T>
201*58b9f456SAndroid Build Coastguard Worker        basic_string& assign(const T& t, size_type pos, size_type n=npos); // C++17
202*58b9f456SAndroid Build Coastguard Worker    basic_string& assign(const value_type* s, size_type n);
203*58b9f456SAndroid Build Coastguard Worker    basic_string& assign(const value_type* s);
204*58b9f456SAndroid Build Coastguard Worker    basic_string& assign(size_type n, value_type c);
205*58b9f456SAndroid Build Coastguard Worker    template<class InputIterator>
206*58b9f456SAndroid Build Coastguard Worker        basic_string& assign(InputIterator first, InputIterator last);
207*58b9f456SAndroid Build Coastguard Worker    basic_string& assign(initializer_list<value_type>);
208*58b9f456SAndroid Build Coastguard Worker
209*58b9f456SAndroid Build Coastguard Worker    basic_string& insert(size_type pos1, const basic_string& str);
210*58b9f456SAndroid Build Coastguard Worker    template <class T>
211*58b9f456SAndroid Build Coastguard Worker        basic_string& insert(size_type pos1, const T& t);
212*58b9f456SAndroid Build Coastguard Worker    basic_string& insert(size_type pos1, const basic_string& str,
213*58b9f456SAndroid Build Coastguard Worker                         size_type pos2, size_type n);
214*58b9f456SAndroid Build Coastguard Worker    template <class T>
215*58b9f456SAndroid Build Coastguard Worker        basic_string& insert(size_type pos1, const T& t, size_type pos2, size_type n); // C++17
216*58b9f456SAndroid Build Coastguard Worker    basic_string& insert(size_type pos, const value_type* s, size_type n=npos); //C++14
217*58b9f456SAndroid Build Coastguard Worker    basic_string& insert(size_type pos, const value_type* s);
218*58b9f456SAndroid Build Coastguard Worker    basic_string& insert(size_type pos, size_type n, value_type c);
219*58b9f456SAndroid Build Coastguard Worker    iterator      insert(const_iterator p, value_type c);
220*58b9f456SAndroid Build Coastguard Worker    iterator      insert(const_iterator p, size_type n, value_type c);
221*58b9f456SAndroid Build Coastguard Worker    template<class InputIterator>
222*58b9f456SAndroid Build Coastguard Worker        iterator insert(const_iterator p, InputIterator first, InputIterator last);
223*58b9f456SAndroid Build Coastguard Worker    iterator      insert(const_iterator p, initializer_list<value_type>);
224*58b9f456SAndroid Build Coastguard Worker
225*58b9f456SAndroid Build Coastguard Worker    basic_string& erase(size_type pos = 0, size_type n = npos);
226*58b9f456SAndroid Build Coastguard Worker    iterator      erase(const_iterator position);
227*58b9f456SAndroid Build Coastguard Worker    iterator      erase(const_iterator first, const_iterator last);
228*58b9f456SAndroid Build Coastguard Worker
229*58b9f456SAndroid Build Coastguard Worker    basic_string& replace(size_type pos1, size_type n1, const basic_string& str);
230*58b9f456SAndroid Build Coastguard Worker    template <class T>
231*58b9f456SAndroid Build Coastguard Worker    basic_string& replace(size_type pos1, size_type n1, const T& t);  // C++17
232*58b9f456SAndroid Build Coastguard Worker    basic_string& replace(size_type pos1, size_type n1, const basic_string& str,
233*58b9f456SAndroid Build Coastguard Worker                          size_type pos2, size_type n2=npos); // C++14
234*58b9f456SAndroid Build Coastguard Worker    template <class T>
235*58b9f456SAndroid Build Coastguard Worker        basic_string& replace(size_type pos1, size_type n1, const T& t,
236*58b9f456SAndroid Build Coastguard Worker                              size_type pos2, size_type n); // C++17
237*58b9f456SAndroid Build Coastguard Worker    basic_string& replace(size_type pos, size_type n1, const value_type* s, size_type n2);
238*58b9f456SAndroid Build Coastguard Worker    basic_string& replace(size_type pos, size_type n1, const value_type* s);
239*58b9f456SAndroid Build Coastguard Worker    basic_string& replace(size_type pos, size_type n1, size_type n2, value_type c);
240*58b9f456SAndroid Build Coastguard Worker    basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str);
241*58b9f456SAndroid Build Coastguard Worker    template <class T>
242*58b9f456SAndroid Build Coastguard Worker        basic_string& replace(const_iterator i1, const_iterator i2, const T& t);  // C++17
243*58b9f456SAndroid Build Coastguard Worker    basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s, size_type n);
244*58b9f456SAndroid Build Coastguard Worker    basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s);
245*58b9f456SAndroid Build Coastguard Worker    basic_string& replace(const_iterator i1, const_iterator i2, size_type n, value_type c);
246*58b9f456SAndroid Build Coastguard Worker    template<class InputIterator>
247*58b9f456SAndroid Build Coastguard Worker        basic_string& replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2);
248*58b9f456SAndroid Build Coastguard Worker    basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<value_type>);
249*58b9f456SAndroid Build Coastguard Worker
250*58b9f456SAndroid Build Coastguard Worker    size_type copy(value_type* s, size_type n, size_type pos = 0) const;
251*58b9f456SAndroid Build Coastguard Worker    basic_string substr(size_type pos = 0, size_type n = npos) const;
252*58b9f456SAndroid Build Coastguard Worker
253*58b9f456SAndroid Build Coastguard Worker    void swap(basic_string& str)
254*58b9f456SAndroid Build Coastguard Worker        noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||
255*58b9f456SAndroid Build Coastguard Worker                 allocator_traits<allocator_type>::is_always_equal::value);  // C++17
256*58b9f456SAndroid Build Coastguard Worker
257*58b9f456SAndroid Build Coastguard Worker    const value_type* c_str() const noexcept;
258*58b9f456SAndroid Build Coastguard Worker    const value_type* data() const noexcept;
259*58b9f456SAndroid Build Coastguard Worker          value_type* data()       noexcept;   // C++17
260*58b9f456SAndroid Build Coastguard Worker
261*58b9f456SAndroid Build Coastguard Worker    allocator_type get_allocator() const noexcept;
262*58b9f456SAndroid Build Coastguard Worker
263*58b9f456SAndroid Build Coastguard Worker    size_type find(const basic_string& str, size_type pos = 0) const noexcept;
264*58b9f456SAndroid Build Coastguard Worker    template <class T>
265*58b9f456SAndroid Build Coastguard Worker        size_type find(const T& t, size_type pos = 0) const;  // C++17
266*58b9f456SAndroid Build Coastguard Worker    size_type find(const value_type* s, size_type pos, size_type n) const noexcept;
267*58b9f456SAndroid Build Coastguard Worker    size_type find(const value_type* s, size_type pos = 0) const noexcept;
268*58b9f456SAndroid Build Coastguard Worker    size_type find(value_type c, size_type pos = 0) const noexcept;
269*58b9f456SAndroid Build Coastguard Worker
270*58b9f456SAndroid Build Coastguard Worker    size_type rfind(const basic_string& str, size_type pos = npos) const noexcept;
271*58b9f456SAndroid Build Coastguard Worker    template <class T>
272*58b9f456SAndroid Build Coastguard Worker        size_type rfind(const T& t, size_type pos = npos) const;  // C++17
273*58b9f456SAndroid Build Coastguard Worker    size_type rfind(const value_type* s, size_type pos, size_type n) const noexcept;
274*58b9f456SAndroid Build Coastguard Worker    size_type rfind(const value_type* s, size_type pos = npos) const noexcept;
275*58b9f456SAndroid Build Coastguard Worker    size_type rfind(value_type c, size_type pos = npos) const noexcept;
276*58b9f456SAndroid Build Coastguard Worker
277*58b9f456SAndroid Build Coastguard Worker    size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept;
278*58b9f456SAndroid Build Coastguard Worker    template <class T>
279*58b9f456SAndroid Build Coastguard Worker        size_type find_first_of(const T& t, size_type pos = 0) const; // C++17
280*58b9f456SAndroid Build Coastguard Worker    size_type find_first_of(const value_type* s, size_type pos, size_type n) const noexcept;
281*58b9f456SAndroid Build Coastguard Worker    size_type find_first_of(const value_type* s, size_type pos = 0) const noexcept;
282*58b9f456SAndroid Build Coastguard Worker    size_type find_first_of(value_type c, size_type pos = 0) const noexcept;
283*58b9f456SAndroid Build Coastguard Worker
284*58b9f456SAndroid Build Coastguard Worker    size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept;
285*58b9f456SAndroid Build Coastguard Worker    template <class T>
286*58b9f456SAndroid Build Coastguard Worker        size_type find_last_of(const T& t, size_type pos = npos) const noexcept;  // C++17
287*58b9f456SAndroid Build Coastguard Worker    size_type find_last_of(const value_type* s, size_type pos, size_type n) const noexcept;
288*58b9f456SAndroid Build Coastguard Worker    size_type find_last_of(const value_type* s, size_type pos = npos) const noexcept;
289*58b9f456SAndroid Build Coastguard Worker    size_type find_last_of(value_type c, size_type pos = npos) const noexcept;
290*58b9f456SAndroid Build Coastguard Worker
291*58b9f456SAndroid Build Coastguard Worker    size_type find_first_not_of(const basic_string& str, size_type pos = 0) const noexcept;
292*58b9f456SAndroid Build Coastguard Worker    template <class T>
293*58b9f456SAndroid Build Coastguard Worker        size_type find_first_not_of(const T& t, size_type pos = 0) const; // C++17
294*58b9f456SAndroid Build Coastguard Worker    size_type find_first_not_of(const value_type* s, size_type pos, size_type n) const noexcept;
295*58b9f456SAndroid Build Coastguard Worker    size_type find_first_not_of(const value_type* s, size_type pos = 0) const noexcept;
296*58b9f456SAndroid Build Coastguard Worker    size_type find_first_not_of(value_type c, size_type pos = 0) const noexcept;
297*58b9f456SAndroid Build Coastguard Worker
298*58b9f456SAndroid Build Coastguard Worker    size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept;
299*58b9f456SAndroid Build Coastguard Worker    template <class T>
300*58b9f456SAndroid Build Coastguard Worker        size_type find_last_not_of(const T& t, size_type pos = npos) const; // C++17
301*58b9f456SAndroid Build Coastguard Worker    size_type find_last_not_of(const value_type* s, size_type pos, size_type n) const noexcept;
302*58b9f456SAndroid Build Coastguard Worker    size_type find_last_not_of(const value_type* s, size_type pos = npos) const noexcept;
303*58b9f456SAndroid Build Coastguard Worker    size_type find_last_not_of(value_type c, size_type pos = npos) const noexcept;
304*58b9f456SAndroid Build Coastguard Worker
305*58b9f456SAndroid Build Coastguard Worker    int compare(const basic_string& str) const noexcept;
306*58b9f456SAndroid Build Coastguard Worker    template <class T>
307*58b9f456SAndroid Build Coastguard Worker        int compare(const T& t) const noexcept;  // C++17
308*58b9f456SAndroid Build Coastguard Worker    int compare(size_type pos1, size_type n1, const basic_string& str) const;
309*58b9f456SAndroid Build Coastguard Worker    template <class T>
310*58b9f456SAndroid Build Coastguard Worker        int compare(size_type pos1, size_type n1, const T& t) const;  // C++17
311*58b9f456SAndroid Build Coastguard Worker    int compare(size_type pos1, size_type n1, const basic_string& str,
312*58b9f456SAndroid Build Coastguard Worker                size_type pos2, size_type n2=npos) const; // C++14
313*58b9f456SAndroid Build Coastguard Worker    template <class T>
314*58b9f456SAndroid Build Coastguard Worker        int compare(size_type pos1, size_type n1, const T& t,
315*58b9f456SAndroid Build Coastguard Worker                    size_type pos2, size_type n2=npos) const; // C++17
316*58b9f456SAndroid Build Coastguard Worker    int compare(const value_type* s) const noexcept;
317*58b9f456SAndroid Build Coastguard Worker    int compare(size_type pos1, size_type n1, const value_type* s) const;
318*58b9f456SAndroid Build Coastguard Worker    int compare(size_type pos1, size_type n1, const value_type* s, size_type n2) const;
319*58b9f456SAndroid Build Coastguard Worker
320*58b9f456SAndroid Build Coastguard Worker    bool starts_with(basic_string_view<charT, traits> sv) const noexcept; // C++2a
321*58b9f456SAndroid Build Coastguard Worker    bool starts_with(charT c) const noexcept;                             // C++2a
322*58b9f456SAndroid Build Coastguard Worker    bool starts_with(const charT* s) const;                               // C++2a
323*58b9f456SAndroid Build Coastguard Worker    bool ends_with(basic_string_view<charT, traits> sv) const noexcept;   // C++2a
324*58b9f456SAndroid Build Coastguard Worker    bool ends_with(charT c) const noexcept;                               // C++2a
325*58b9f456SAndroid Build Coastguard Worker    bool ends_with(const charT* s) const;                                 // C++2a
326*58b9f456SAndroid Build Coastguard Worker
327*58b9f456SAndroid Build Coastguard Worker    bool __invariants() const;
328*58b9f456SAndroid Build Coastguard Worker};
329*58b9f456SAndroid Build Coastguard Worker
330*58b9f456SAndroid Build Coastguard Workertemplate<class InputIterator,
331*58b9f456SAndroid Build Coastguard Worker         class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
332*58b9f456SAndroid Build Coastguard Workerbasic_string(InputIterator, InputIterator, Allocator = Allocator())
333*58b9f456SAndroid Build Coastguard Worker   -> basic_string<typename iterator_traits<InputIterator>::value_type,
334*58b9f456SAndroid Build Coastguard Worker                  char_traits<typename iterator_traits<InputIterator>::value_type>,
335*58b9f456SAndroid Build Coastguard Worker                  Allocator>;   // C++17
336*58b9f456SAndroid Build Coastguard Worker
337*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
338*58b9f456SAndroid Build Coastguard Workerbasic_string<charT, traits, Allocator>
339*58b9f456SAndroid Build Coastguard Workeroperator+(const basic_string<charT, traits, Allocator>& lhs,
340*58b9f456SAndroid Build Coastguard Worker          const basic_string<charT, traits, Allocator>& rhs);
341*58b9f456SAndroid Build Coastguard Worker
342*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
343*58b9f456SAndroid Build Coastguard Workerbasic_string<charT, traits, Allocator>
344*58b9f456SAndroid Build Coastguard Workeroperator+(const charT* lhs , const basic_string<charT,traits,Allocator>&rhs);
345*58b9f456SAndroid Build Coastguard Worker
346*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
347*58b9f456SAndroid Build Coastguard Workerbasic_string<charT, traits, Allocator>
348*58b9f456SAndroid Build Coastguard Workeroperator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs);
349*58b9f456SAndroid Build Coastguard Worker
350*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
351*58b9f456SAndroid Build Coastguard Workerbasic_string<charT, traits, Allocator>
352*58b9f456SAndroid Build Coastguard Workeroperator+(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs);
353*58b9f456SAndroid Build Coastguard Worker
354*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
355*58b9f456SAndroid Build Coastguard Workerbasic_string<charT, traits, Allocator>
356*58b9f456SAndroid Build Coastguard Workeroperator+(const basic_string<charT, traits, Allocator>& lhs, charT rhs);
357*58b9f456SAndroid Build Coastguard Worker
358*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
359*58b9f456SAndroid Build Coastguard Workerbool operator==(const basic_string<charT, traits, Allocator>& lhs,
360*58b9f456SAndroid Build Coastguard Worker                const basic_string<charT, traits, Allocator>& rhs) noexcept;
361*58b9f456SAndroid Build Coastguard Worker
362*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
363*58b9f456SAndroid Build Coastguard Workerbool operator==(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
364*58b9f456SAndroid Build Coastguard Worker
365*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
366*58b9f456SAndroid Build Coastguard Workerbool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs) noexcept;
367*58b9f456SAndroid Build Coastguard Worker
368*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
369*58b9f456SAndroid Build Coastguard Workerbool operator!=(const basic_string<charT,traits,Allocator>& lhs,
370*58b9f456SAndroid Build Coastguard Worker                const basic_string<charT, traits, Allocator>& rhs) noexcept;
371*58b9f456SAndroid Build Coastguard Worker
372*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
373*58b9f456SAndroid Build Coastguard Workerbool operator!=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
374*58b9f456SAndroid Build Coastguard Worker
375*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
376*58b9f456SAndroid Build Coastguard Workerbool operator!=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;
377*58b9f456SAndroid Build Coastguard Worker
378*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
379*58b9f456SAndroid Build Coastguard Workerbool operator< (const basic_string<charT, traits, Allocator>& lhs,
380*58b9f456SAndroid Build Coastguard Worker                const basic_string<charT, traits, Allocator>& rhs) noexcept;
381*58b9f456SAndroid Build Coastguard Worker
382*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
383*58b9f456SAndroid Build Coastguard Workerbool operator< (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;
384*58b9f456SAndroid Build Coastguard Worker
385*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
386*58b9f456SAndroid Build Coastguard Workerbool operator< (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
387*58b9f456SAndroid Build Coastguard Worker
388*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
389*58b9f456SAndroid Build Coastguard Workerbool operator> (const basic_string<charT, traits, Allocator>& lhs,
390*58b9f456SAndroid Build Coastguard Worker                const basic_string<charT, traits, Allocator>& rhs) noexcept;
391*58b9f456SAndroid Build Coastguard Worker
392*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
393*58b9f456SAndroid Build Coastguard Workerbool operator> (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;
394*58b9f456SAndroid Build Coastguard Worker
395*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
396*58b9f456SAndroid Build Coastguard Workerbool operator> (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
397*58b9f456SAndroid Build Coastguard Worker
398*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
399*58b9f456SAndroid Build Coastguard Workerbool operator<=(const basic_string<charT, traits, Allocator>& lhs,
400*58b9f456SAndroid Build Coastguard Worker                const basic_string<charT, traits, Allocator>& rhs) noexcept;
401*58b9f456SAndroid Build Coastguard Worker
402*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
403*58b9f456SAndroid Build Coastguard Workerbool operator<=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;
404*58b9f456SAndroid Build Coastguard Worker
405*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
406*58b9f456SAndroid Build Coastguard Workerbool operator<=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
407*58b9f456SAndroid Build Coastguard Worker
408*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
409*58b9f456SAndroid Build Coastguard Workerbool operator>=(const basic_string<charT, traits, Allocator>& lhs,
410*58b9f456SAndroid Build Coastguard Worker                const basic_string<charT, traits, Allocator>& rhs) noexcept;
411*58b9f456SAndroid Build Coastguard Worker
412*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
413*58b9f456SAndroid Build Coastguard Workerbool operator>=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;
414*58b9f456SAndroid Build Coastguard Worker
415*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
416*58b9f456SAndroid Build Coastguard Workerbool operator>=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
417*58b9f456SAndroid Build Coastguard Worker
418*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
419*58b9f456SAndroid Build Coastguard Workervoid swap(basic_string<charT, traits, Allocator>& lhs,
420*58b9f456SAndroid Build Coastguard Worker          basic_string<charT, traits, Allocator>& rhs)
421*58b9f456SAndroid Build Coastguard Worker            noexcept(noexcept(lhs.swap(rhs)));
422*58b9f456SAndroid Build Coastguard Worker
423*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
424*58b9f456SAndroid Build Coastguard Workerbasic_istream<charT, traits>&
425*58b9f456SAndroid Build Coastguard Workeroperator>>(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str);
426*58b9f456SAndroid Build Coastguard Worker
427*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
428*58b9f456SAndroid Build Coastguard Workerbasic_ostream<charT, traits>&
429*58b9f456SAndroid Build Coastguard Workeroperator<<(basic_ostream<charT, traits>& os, const basic_string<charT, traits, Allocator>& str);
430*58b9f456SAndroid Build Coastguard Worker
431*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
432*58b9f456SAndroid Build Coastguard Workerbasic_istream<charT, traits>&
433*58b9f456SAndroid Build Coastguard Workergetline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str,
434*58b9f456SAndroid Build Coastguard Worker        charT delim);
435*58b9f456SAndroid Build Coastguard Worker
436*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator>
437*58b9f456SAndroid Build Coastguard Workerbasic_istream<charT, traits>&
438*58b9f456SAndroid Build Coastguard Workergetline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str);
439*58b9f456SAndroid Build Coastguard Worker
440*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator, class U>
441*58b9f456SAndroid Build Coastguard Workervoid erase(basic_string<charT, traits, Allocator>& c, const U& value); // C++20
442*58b9f456SAndroid Build Coastguard Workertemplate<class charT, class traits, class Allocator, class Predicate>
443*58b9f456SAndroid Build Coastguard Workervoid erase_if(basic_string<charT, traits, Allocator>& c, Predicate pred); // C++20
444*58b9f456SAndroid Build Coastguard Worker
445*58b9f456SAndroid Build Coastguard Workertypedef basic_string<char>    string;
446*58b9f456SAndroid Build Coastguard Workertypedef basic_string<wchar_t> wstring;
447*58b9f456SAndroid Build Coastguard Workertypedef basic_string<char16_t> u16string;
448*58b9f456SAndroid Build Coastguard Workertypedef basic_string<char32_t> u32string;
449*58b9f456SAndroid Build Coastguard Worker
450*58b9f456SAndroid Build Coastguard Workerint                stoi  (const string& str, size_t* idx = 0, int base = 10);
451*58b9f456SAndroid Build Coastguard Workerlong               stol  (const string& str, size_t* idx = 0, int base = 10);
452*58b9f456SAndroid Build Coastguard Workerunsigned long      stoul (const string& str, size_t* idx = 0, int base = 10);
453*58b9f456SAndroid Build Coastguard Workerlong long          stoll (const string& str, size_t* idx = 0, int base = 10);
454*58b9f456SAndroid Build Coastguard Workerunsigned long long stoull(const string& str, size_t* idx = 0, int base = 10);
455*58b9f456SAndroid Build Coastguard Worker
456*58b9f456SAndroid Build Coastguard Workerfloat       stof (const string& str, size_t* idx = 0);
457*58b9f456SAndroid Build Coastguard Workerdouble      stod (const string& str, size_t* idx = 0);
458*58b9f456SAndroid Build Coastguard Workerlong double stold(const string& str, size_t* idx = 0);
459*58b9f456SAndroid Build Coastguard Worker
460*58b9f456SAndroid Build Coastguard Workerstring to_string(int val);
461*58b9f456SAndroid Build Coastguard Workerstring to_string(unsigned val);
462*58b9f456SAndroid Build Coastguard Workerstring to_string(long val);
463*58b9f456SAndroid Build Coastguard Workerstring to_string(unsigned long val);
464*58b9f456SAndroid Build Coastguard Workerstring to_string(long long val);
465*58b9f456SAndroid Build Coastguard Workerstring to_string(unsigned long long val);
466*58b9f456SAndroid Build Coastguard Workerstring to_string(float val);
467*58b9f456SAndroid Build Coastguard Workerstring to_string(double val);
468*58b9f456SAndroid Build Coastguard Workerstring to_string(long double val);
469*58b9f456SAndroid Build Coastguard Worker
470*58b9f456SAndroid Build Coastguard Workerint                stoi  (const wstring& str, size_t* idx = 0, int base = 10);
471*58b9f456SAndroid Build Coastguard Workerlong               stol  (const wstring& str, size_t* idx = 0, int base = 10);
472*58b9f456SAndroid Build Coastguard Workerunsigned long      stoul (const wstring& str, size_t* idx = 0, int base = 10);
473*58b9f456SAndroid Build Coastguard Workerlong long          stoll (const wstring& str, size_t* idx = 0, int base = 10);
474*58b9f456SAndroid Build Coastguard Workerunsigned long long stoull(const wstring& str, size_t* idx = 0, int base = 10);
475*58b9f456SAndroid Build Coastguard Worker
476*58b9f456SAndroid Build Coastguard Workerfloat       stof (const wstring& str, size_t* idx = 0);
477*58b9f456SAndroid Build Coastguard Workerdouble      stod (const wstring& str, size_t* idx = 0);
478*58b9f456SAndroid Build Coastguard Workerlong double stold(const wstring& str, size_t* idx = 0);
479*58b9f456SAndroid Build Coastguard Worker
480*58b9f456SAndroid Build Coastguard Workerwstring to_wstring(int val);
481*58b9f456SAndroid Build Coastguard Workerwstring to_wstring(unsigned val);
482*58b9f456SAndroid Build Coastguard Workerwstring to_wstring(long val);
483*58b9f456SAndroid Build Coastguard Workerwstring to_wstring(unsigned long val);
484*58b9f456SAndroid Build Coastguard Workerwstring to_wstring(long long val);
485*58b9f456SAndroid Build Coastguard Workerwstring to_wstring(unsigned long long val);
486*58b9f456SAndroid Build Coastguard Workerwstring to_wstring(float val);
487*58b9f456SAndroid Build Coastguard Workerwstring to_wstring(double val);
488*58b9f456SAndroid Build Coastguard Workerwstring to_wstring(long double val);
489*58b9f456SAndroid Build Coastguard Worker
490*58b9f456SAndroid Build Coastguard Workertemplate <> struct hash<string>;
491*58b9f456SAndroid Build Coastguard Workertemplate <> struct hash<u16string>;
492*58b9f456SAndroid Build Coastguard Workertemplate <> struct hash<u32string>;
493*58b9f456SAndroid Build Coastguard Workertemplate <> struct hash<wstring>;
494*58b9f456SAndroid Build Coastguard Worker
495*58b9f456SAndroid Build Coastguard Workerbasic_string<char>     operator "" s( const char *str,     size_t len ); // C++14
496*58b9f456SAndroid Build Coastguard Workerbasic_string<wchar_t>  operator "" s( const wchar_t *str,  size_t len ); // C++14
497*58b9f456SAndroid Build Coastguard Workerbasic_string<char16_t> operator "" s( const char16_t *str, size_t len ); // C++14
498*58b9f456SAndroid Build Coastguard Workerbasic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++14
499*58b9f456SAndroid Build Coastguard Worker
500*58b9f456SAndroid Build Coastguard Worker}  // std
501*58b9f456SAndroid Build Coastguard Worker
502*58b9f456SAndroid Build Coastguard Worker*/
503*58b9f456SAndroid Build Coastguard Worker
504*58b9f456SAndroid Build Coastguard Worker#include <__config>
505*58b9f456SAndroid Build Coastguard Worker#include <string_view>
506*58b9f456SAndroid Build Coastguard Worker#include <iosfwd>
507*58b9f456SAndroid Build Coastguard Worker#include <cstring>
508*58b9f456SAndroid Build Coastguard Worker#include <cstdio>  // For EOF.
509*58b9f456SAndroid Build Coastguard Worker#include <cwchar>
510*58b9f456SAndroid Build Coastguard Worker#include <algorithm>
511*58b9f456SAndroid Build Coastguard Worker#include <iterator>
512*58b9f456SAndroid Build Coastguard Worker#include <utility>
513*58b9f456SAndroid Build Coastguard Worker#include <memory>
514*58b9f456SAndroid Build Coastguard Worker#include <stdexcept>
515*58b9f456SAndroid Build Coastguard Worker#include <type_traits>
516*58b9f456SAndroid Build Coastguard Worker#include <initializer_list>
517*58b9f456SAndroid Build Coastguard Worker#include <__functional_base>
518*58b9f456SAndroid Build Coastguard Worker#include <version>
519*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
520*58b9f456SAndroid Build Coastguard Worker#include <cstdint>
521*58b9f456SAndroid Build Coastguard Worker#endif
522*58b9f456SAndroid Build Coastguard Worker
523*58b9f456SAndroid Build Coastguard Worker#include <__debug>
524*58b9f456SAndroid Build Coastguard Worker
525*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
526*58b9f456SAndroid Build Coastguard Worker#pragma GCC system_header
527*58b9f456SAndroid Build Coastguard Worker#endif
528*58b9f456SAndroid Build Coastguard Worker
529*58b9f456SAndroid Build Coastguard Worker_LIBCPP_PUSH_MACROS
530*58b9f456SAndroid Build Coastguard Worker#include <__undef_macros>
531*58b9f456SAndroid Build Coastguard Worker
532*58b9f456SAndroid Build Coastguard Worker
533*58b9f456SAndroid Build Coastguard Worker_LIBCPP_BEGIN_NAMESPACE_STD
534*58b9f456SAndroid Build Coastguard Worker
535*58b9f456SAndroid Build Coastguard Worker// fpos
536*58b9f456SAndroid Build Coastguard Worker
537*58b9f456SAndroid Build Coastguard Workertemplate <class _StateT>
538*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS fpos
539*58b9f456SAndroid Build Coastguard Worker{
540*58b9f456SAndroid Build Coastguard Workerprivate:
541*58b9f456SAndroid Build Coastguard Worker    _StateT __st_;
542*58b9f456SAndroid Build Coastguard Worker    streamoff __off_;
543*58b9f456SAndroid Build Coastguard Workerpublic:
544*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY fpos(streamoff __off = streamoff()) : __st_(), __off_(__off) {}
545*58b9f456SAndroid Build Coastguard Worker
546*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY operator streamoff() const {return __off_;}
547*58b9f456SAndroid Build Coastguard Worker
548*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _StateT state() const {return __st_;}
549*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY void state(_StateT __st) {__st_ = __st;}
550*58b9f456SAndroid Build Coastguard Worker
551*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY fpos& operator+=(streamoff __off) {__off_ += __off; return *this;}
552*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY fpos  operator+ (streamoff __off) const {fpos __t(*this); __t += __off; return __t;}
553*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY fpos& operator-=(streamoff __off) {__off_ -= __off; return *this;}
554*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY fpos  operator- (streamoff __off) const {fpos __t(*this); __t -= __off; return __t;}
555*58b9f456SAndroid Build Coastguard Worker};
556*58b9f456SAndroid Build Coastguard Worker
557*58b9f456SAndroid Build Coastguard Workertemplate <class _StateT>
558*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
559*58b9f456SAndroid Build Coastguard Workerstreamoff operator-(const fpos<_StateT>& __x, const fpos<_StateT>& __y)
560*58b9f456SAndroid Build Coastguard Worker    {return streamoff(__x) - streamoff(__y);}
561*58b9f456SAndroid Build Coastguard Worker
562*58b9f456SAndroid Build Coastguard Workertemplate <class _StateT>
563*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
564*58b9f456SAndroid Build Coastguard Workerbool operator==(const fpos<_StateT>& __x, const fpos<_StateT>& __y)
565*58b9f456SAndroid Build Coastguard Worker    {return streamoff(__x) == streamoff(__y);}
566*58b9f456SAndroid Build Coastguard Worker
567*58b9f456SAndroid Build Coastguard Workertemplate <class _StateT>
568*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
569*58b9f456SAndroid Build Coastguard Workerbool operator!=(const fpos<_StateT>& __x, const fpos<_StateT>& __y)
570*58b9f456SAndroid Build Coastguard Worker    {return streamoff(__x) != streamoff(__y);}
571*58b9f456SAndroid Build Coastguard Worker
572*58b9f456SAndroid Build Coastguard Worker// basic_string
573*58b9f456SAndroid Build Coastguard Worker
574*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
575*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>
576*58b9f456SAndroid Build Coastguard Workeroperator+(const basic_string<_CharT, _Traits, _Allocator>& __x,
577*58b9f456SAndroid Build Coastguard Worker          const basic_string<_CharT, _Traits, _Allocator>& __y);
578*58b9f456SAndroid Build Coastguard Worker
579*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
580*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>
581*58b9f456SAndroid Build Coastguard Workeroperator+(const _CharT* __x, const basic_string<_CharT,_Traits,_Allocator>& __y);
582*58b9f456SAndroid Build Coastguard Worker
583*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
584*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>
585*58b9f456SAndroid Build Coastguard Workeroperator+(_CharT __x, const basic_string<_CharT,_Traits,_Allocator>& __y);
586*58b9f456SAndroid Build Coastguard Worker
587*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
588*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
589*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>
590*58b9f456SAndroid Build Coastguard Workeroperator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const _CharT* __y);
591*58b9f456SAndroid Build Coastguard Worker
592*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
593*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>
594*58b9f456SAndroid Build Coastguard Workeroperator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y);
595*58b9f456SAndroid Build Coastguard Worker
596*58b9f456SAndroid Build Coastguard Worker_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&))
597*58b9f456SAndroid Build Coastguard Worker
598*58b9f456SAndroid Build Coastguard Workertemplate <bool>
599*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS __basic_string_common
600*58b9f456SAndroid Build Coastguard Worker{
601*58b9f456SAndroid Build Coastguard Workerprotected:
602*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_NORETURN void __throw_length_error() const;
603*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_NORETURN void __throw_out_of_range() const;
604*58b9f456SAndroid Build Coastguard Worker};
605*58b9f456SAndroid Build Coastguard Worker
606*58b9f456SAndroid Build Coastguard Workertemplate <bool __b>
607*58b9f456SAndroid Build Coastguard Workervoid
608*58b9f456SAndroid Build Coastguard Worker__basic_string_common<__b>::__throw_length_error() const
609*58b9f456SAndroid Build Coastguard Worker{
610*58b9f456SAndroid Build Coastguard Worker    _VSTD::__throw_length_error("basic_string");
611*58b9f456SAndroid Build Coastguard Worker}
612*58b9f456SAndroid Build Coastguard Worker
613*58b9f456SAndroid Build Coastguard Workertemplate <bool __b>
614*58b9f456SAndroid Build Coastguard Workervoid
615*58b9f456SAndroid Build Coastguard Worker__basic_string_common<__b>::__throw_out_of_range() const
616*58b9f456SAndroid Build Coastguard Worker{
617*58b9f456SAndroid Build Coastguard Worker    _VSTD::__throw_out_of_range("basic_string");
618*58b9f456SAndroid Build Coastguard Worker}
619*58b9f456SAndroid Build Coastguard Worker
620*58b9f456SAndroid Build Coastguard Worker_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __basic_string_common<true>)
621*58b9f456SAndroid Build Coastguard Worker
622*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_NO_EXCEPTIONS
623*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter>
624*58b9f456SAndroid Build Coastguard Workerstruct __libcpp_string_gets_noexcept_iterator_impl : public true_type {};
625*58b9f456SAndroid Build Coastguard Worker#elif defined(_LIBCPP_HAS_NO_NOEXCEPT)
626*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter>
627*58b9f456SAndroid Build Coastguard Workerstruct __libcpp_string_gets_noexcept_iterator_impl : public false_type {};
628*58b9f456SAndroid Build Coastguard Worker#else
629*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter, bool = __is_forward_iterator<_Iter>::value>
630*58b9f456SAndroid Build Coastguard Workerstruct __libcpp_string_gets_noexcept_iterator_impl : public _LIBCPP_BOOL_CONSTANT((
631*58b9f456SAndroid Build Coastguard Worker    noexcept(++(declval<_Iter&>())) &&
632*58b9f456SAndroid Build Coastguard Worker    is_nothrow_assignable<_Iter&, _Iter>::value &&
633*58b9f456SAndroid Build Coastguard Worker    noexcept(declval<_Iter>() == declval<_Iter>()) &&
634*58b9f456SAndroid Build Coastguard Worker    noexcept(*declval<_Iter>())
635*58b9f456SAndroid Build Coastguard Worker)) {};
636*58b9f456SAndroid Build Coastguard Worker
637*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter>
638*58b9f456SAndroid Build Coastguard Workerstruct __libcpp_string_gets_noexcept_iterator_impl<_Iter, false> : public false_type {};
639*58b9f456SAndroid Build Coastguard Worker#endif
640*58b9f456SAndroid Build Coastguard Worker
641*58b9f456SAndroid Build Coastguard Worker
642*58b9f456SAndroid Build Coastguard Workertemplate <class _Iter>
643*58b9f456SAndroid Build Coastguard Workerstruct __libcpp_string_gets_noexcept_iterator
644*58b9f456SAndroid Build Coastguard Worker    : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value || __libcpp_string_gets_noexcept_iterator_impl<_Iter>::value) {};
645*58b9f456SAndroid Build Coastguard Worker
646*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Tp>
647*58b9f456SAndroid Build Coastguard Workerstruct __can_be_converted_to_string_view : public _LIBCPP_BOOL_CONSTANT(
648*58b9f456SAndroid Build Coastguard Worker    ( is_convertible<const _Tp&, basic_string_view<_CharT, _Traits> >::value &&
649*58b9f456SAndroid Build Coastguard Worker     !is_convertible<const _Tp&, const _CharT*>::value)) {};
650*58b9f456SAndroid Build Coastguard Worker
651*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
652*58b9f456SAndroid Build Coastguard Worker
653*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, size_t = sizeof(_CharT)>
654*58b9f456SAndroid Build Coastguard Workerstruct __padding
655*58b9f456SAndroid Build Coastguard Worker{
656*58b9f456SAndroid Build Coastguard Worker    unsigned char __xx[sizeof(_CharT)-1];
657*58b9f456SAndroid Build Coastguard Worker};
658*58b9f456SAndroid Build Coastguard Worker
659*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT>
660*58b9f456SAndroid Build Coastguard Workerstruct __padding<_CharT, 1>
661*58b9f456SAndroid Build Coastguard Worker{
662*58b9f456SAndroid Build Coastguard Worker};
663*58b9f456SAndroid Build Coastguard Worker
664*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
665*58b9f456SAndroid Build Coastguard Worker
666*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
667*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS basic_string
668*58b9f456SAndroid Build Coastguard Worker    : private __basic_string_common<true>
669*58b9f456SAndroid Build Coastguard Worker{
670*58b9f456SAndroid Build Coastguard Workerpublic:
671*58b9f456SAndroid Build Coastguard Worker    typedef basic_string                                 __self;
672*58b9f456SAndroid Build Coastguard Worker    typedef basic_string_view<_CharT, _Traits>           __self_view;
673*58b9f456SAndroid Build Coastguard Worker    typedef _Traits                                      traits_type;
674*58b9f456SAndroid Build Coastguard Worker    typedef _CharT                                       value_type;
675*58b9f456SAndroid Build Coastguard Worker    typedef _Allocator                                   allocator_type;
676*58b9f456SAndroid Build Coastguard Worker    typedef allocator_traits<allocator_type>             __alloc_traits;
677*58b9f456SAndroid Build Coastguard Worker    typedef typename __alloc_traits::size_type           size_type;
678*58b9f456SAndroid Build Coastguard Worker    typedef typename __alloc_traits::difference_type     difference_type;
679*58b9f456SAndroid Build Coastguard Worker    typedef value_type&                                  reference;
680*58b9f456SAndroid Build Coastguard Worker    typedef const value_type&                            const_reference;
681*58b9f456SAndroid Build Coastguard Worker    typedef typename __alloc_traits::pointer             pointer;
682*58b9f456SAndroid Build Coastguard Worker    typedef typename __alloc_traits::const_pointer       const_pointer;
683*58b9f456SAndroid Build Coastguard Worker
684*58b9f456SAndroid Build Coastguard Worker    static_assert((!is_array<value_type>::value), "Character type of basic_string must not be an array");
685*58b9f456SAndroid Build Coastguard Worker    static_assert(( is_standard_layout<value_type>::value), "Character type of basic_string must be standard-layout");
686*58b9f456SAndroid Build Coastguard Worker    static_assert(( is_trivial<value_type>::value), "Character type of basic_string must be trivial");
687*58b9f456SAndroid Build Coastguard Worker    static_assert(( is_same<_CharT, typename traits_type::char_type>::value),
688*58b9f456SAndroid Build Coastguard Worker                  "traits_type::char_type must be the same type as CharT");
689*58b9f456SAndroid Build Coastguard Worker    static_assert(( is_same<typename allocator_type::value_type, value_type>::value),
690*58b9f456SAndroid Build Coastguard Worker                  "Allocator::value_type must be same type as value_type");
691*58b9f456SAndroid Build Coastguard Worker
692*58b9f456SAndroid Build Coastguard Worker#if defined(_LIBCPP_RAW_ITERATORS)
693*58b9f456SAndroid Build Coastguard Worker    typedef pointer                                      iterator;
694*58b9f456SAndroid Build Coastguard Worker    typedef const_pointer                                const_iterator;
695*58b9f456SAndroid Build Coastguard Worker#else  // defined(_LIBCPP_RAW_ITERATORS)
696*58b9f456SAndroid Build Coastguard Worker    typedef __wrap_iter<pointer>                         iterator;
697*58b9f456SAndroid Build Coastguard Worker    typedef __wrap_iter<const_pointer>                   const_iterator;
698*58b9f456SAndroid Build Coastguard Worker#endif  // defined(_LIBCPP_RAW_ITERATORS)
699*58b9f456SAndroid Build Coastguard Worker    typedef _VSTD::reverse_iterator<iterator>             reverse_iterator;
700*58b9f456SAndroid Build Coastguard Worker    typedef _VSTD::reverse_iterator<const_iterator>       const_reverse_iterator;
701*58b9f456SAndroid Build Coastguard Worker
702*58b9f456SAndroid Build Coastguard Workerprivate:
703*58b9f456SAndroid Build Coastguard Worker
704*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
705*58b9f456SAndroid Build Coastguard Worker
706*58b9f456SAndroid Build Coastguard Worker    struct __long
707*58b9f456SAndroid Build Coastguard Worker    {
708*58b9f456SAndroid Build Coastguard Worker        pointer   __data_;
709*58b9f456SAndroid Build Coastguard Worker        size_type __size_;
710*58b9f456SAndroid Build Coastguard Worker        size_type __cap_;
711*58b9f456SAndroid Build Coastguard Worker    };
712*58b9f456SAndroid Build Coastguard Worker
713*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_BIG_ENDIAN
714*58b9f456SAndroid Build Coastguard Worker    static const size_type __short_mask = 0x01;
715*58b9f456SAndroid Build Coastguard Worker    static const size_type __long_mask  = 0x1ul;
716*58b9f456SAndroid Build Coastguard Worker#else  // _LIBCPP_BIG_ENDIAN
717*58b9f456SAndroid Build Coastguard Worker    static const size_type __short_mask = 0x80;
718*58b9f456SAndroid Build Coastguard Worker    static const size_type __long_mask  = ~(size_type(~0) >> 1);
719*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_BIG_ENDIAN
720*58b9f456SAndroid Build Coastguard Worker
721*58b9f456SAndroid Build Coastguard Worker    enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ?
722*58b9f456SAndroid Build Coastguard Worker                      (sizeof(__long) - 1)/sizeof(value_type) : 2};
723*58b9f456SAndroid Build Coastguard Worker
724*58b9f456SAndroid Build Coastguard Worker    struct __short
725*58b9f456SAndroid Build Coastguard Worker    {
726*58b9f456SAndroid Build Coastguard Worker        value_type __data_[__min_cap];
727*58b9f456SAndroid Build Coastguard Worker        struct
728*58b9f456SAndroid Build Coastguard Worker            : __padding<value_type>
729*58b9f456SAndroid Build Coastguard Worker        {
730*58b9f456SAndroid Build Coastguard Worker            unsigned char __size_;
731*58b9f456SAndroid Build Coastguard Worker        };
732*58b9f456SAndroid Build Coastguard Worker    };
733*58b9f456SAndroid Build Coastguard Worker
734*58b9f456SAndroid Build Coastguard Worker#else
735*58b9f456SAndroid Build Coastguard Worker
736*58b9f456SAndroid Build Coastguard Worker    struct __long
737*58b9f456SAndroid Build Coastguard Worker    {
738*58b9f456SAndroid Build Coastguard Worker        size_type __cap_;
739*58b9f456SAndroid Build Coastguard Worker        size_type __size_;
740*58b9f456SAndroid Build Coastguard Worker        pointer   __data_;
741*58b9f456SAndroid Build Coastguard Worker    };
742*58b9f456SAndroid Build Coastguard Worker
743*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_BIG_ENDIAN
744*58b9f456SAndroid Build Coastguard Worker    static const size_type __short_mask = 0x80;
745*58b9f456SAndroid Build Coastguard Worker    static const size_type __long_mask  = ~(size_type(~0) >> 1);
746*58b9f456SAndroid Build Coastguard Worker#else  // _LIBCPP_BIG_ENDIAN
747*58b9f456SAndroid Build Coastguard Worker    static const size_type __short_mask = 0x01;
748*58b9f456SAndroid Build Coastguard Worker    static const size_type __long_mask  = 0x1ul;
749*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_BIG_ENDIAN
750*58b9f456SAndroid Build Coastguard Worker
751*58b9f456SAndroid Build Coastguard Worker    enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ?
752*58b9f456SAndroid Build Coastguard Worker                      (sizeof(__long) - 1)/sizeof(value_type) : 2};
753*58b9f456SAndroid Build Coastguard Worker
754*58b9f456SAndroid Build Coastguard Worker    struct __short
755*58b9f456SAndroid Build Coastguard Worker    {
756*58b9f456SAndroid Build Coastguard Worker        union
757*58b9f456SAndroid Build Coastguard Worker        {
758*58b9f456SAndroid Build Coastguard Worker            unsigned char __size_;
759*58b9f456SAndroid Build Coastguard Worker            value_type __lx;
760*58b9f456SAndroid Build Coastguard Worker        };
761*58b9f456SAndroid Build Coastguard Worker        value_type __data_[__min_cap];
762*58b9f456SAndroid Build Coastguard Worker    };
763*58b9f456SAndroid Build Coastguard Worker
764*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
765*58b9f456SAndroid Build Coastguard Worker
766*58b9f456SAndroid Build Coastguard Worker    union __ulx{__long __lx; __short __lxx;};
767*58b9f456SAndroid Build Coastguard Worker
768*58b9f456SAndroid Build Coastguard Worker    enum {__n_words = sizeof(__ulx) / sizeof(size_type)};
769*58b9f456SAndroid Build Coastguard Worker
770*58b9f456SAndroid Build Coastguard Worker    struct __raw
771*58b9f456SAndroid Build Coastguard Worker    {
772*58b9f456SAndroid Build Coastguard Worker        size_type __words[__n_words];
773*58b9f456SAndroid Build Coastguard Worker    };
774*58b9f456SAndroid Build Coastguard Worker
775*58b9f456SAndroid Build Coastguard Worker    struct __rep
776*58b9f456SAndroid Build Coastguard Worker    {
777*58b9f456SAndroid Build Coastguard Worker        union
778*58b9f456SAndroid Build Coastguard Worker        {
779*58b9f456SAndroid Build Coastguard Worker            __long  __l;
780*58b9f456SAndroid Build Coastguard Worker            __short __s;
781*58b9f456SAndroid Build Coastguard Worker            __raw   __r;
782*58b9f456SAndroid Build Coastguard Worker        };
783*58b9f456SAndroid Build Coastguard Worker    };
784*58b9f456SAndroid Build Coastguard Worker
785*58b9f456SAndroid Build Coastguard Worker    __compressed_pair<__rep, allocator_type> __r_;
786*58b9f456SAndroid Build Coastguard Worker
787*58b9f456SAndroid Build Coastguard Workerpublic:
788*58b9f456SAndroid Build Coastguard Worker    static const size_type npos = -1;
789*58b9f456SAndroid Build Coastguard Worker
790*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY basic_string()
791*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
792*58b9f456SAndroid Build Coastguard Worker
793*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a)
794*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER <= 14
795*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);
796*58b9f456SAndroid Build Coastguard Worker#else
797*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT;
798*58b9f456SAndroid Build Coastguard Worker#endif
799*58b9f456SAndroid Build Coastguard Worker
800*58b9f456SAndroid Build Coastguard Worker    basic_string(const basic_string& __str);
801*58b9f456SAndroid Build Coastguard Worker    basic_string(const basic_string& __str, const allocator_type& __a);
802*58b9f456SAndroid Build Coastguard Worker
803*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
804*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
805*58b9f456SAndroid Build Coastguard Worker    basic_string(basic_string&& __str)
806*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER <= 14
807*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
808*58b9f456SAndroid Build Coastguard Worker#else
809*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT;
810*58b9f456SAndroid Build Coastguard Worker#endif
811*58b9f456SAndroid Build Coastguard Worker
812*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
813*58b9f456SAndroid Build Coastguard Worker    basic_string(basic_string&& __str, const allocator_type& __a);
814*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
815*58b9f456SAndroid Build Coastguard Worker
816*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
817*58b9f456SAndroid Build Coastguard Worker    template <class = typename enable_if<__is_allocator<_Allocator>::value, nullptr_t>::type>
818*58b9f456SAndroid Build Coastguard Worker#endif
819*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
820*58b9f456SAndroid Build Coastguard Worker    basic_string(const _CharT* __s) {
821*58b9f456SAndroid Build Coastguard Worker      _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr");
822*58b9f456SAndroid Build Coastguard Worker      __init(__s, traits_type::length(__s));
823*58b9f456SAndroid Build Coastguard Worker#   if _LIBCPP_DEBUG_LEVEL >= 2
824*58b9f456SAndroid Build Coastguard Worker      __get_db()->__insert_c(this);
825*58b9f456SAndroid Build Coastguard Worker#   endif
826*58b9f456SAndroid Build Coastguard Worker    }
827*58b9f456SAndroid Build Coastguard Worker
828*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
829*58b9f456SAndroid Build Coastguard Worker    template <class = typename enable_if<__is_allocator<_Allocator>::value, nullptr_t>::type>
830*58b9f456SAndroid Build Coastguard Worker#endif
831*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
832*58b9f456SAndroid Build Coastguard Worker        basic_string(const _CharT* __s, const _Allocator& __a);
833*58b9f456SAndroid Build Coastguard Worker
834*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
835*58b9f456SAndroid Build Coastguard Worker    basic_string(const _CharT* __s, size_type __n);
836*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
837*58b9f456SAndroid Build Coastguard Worker    basic_string(const _CharT* __s, size_type __n, const _Allocator& __a);
838*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
839*58b9f456SAndroid Build Coastguard Worker    basic_string(size_type __n, _CharT __c);
840*58b9f456SAndroid Build Coastguard Worker
841*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
842*58b9f456SAndroid Build Coastguard Worker    template <class = typename enable_if<__is_allocator<_Allocator>::value, nullptr_t>::type>
843*58b9f456SAndroid Build Coastguard Worker#endif
844*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
845*58b9f456SAndroid Build Coastguard Worker        basic_string(size_type __n, _CharT __c, const _Allocator& __a);
846*58b9f456SAndroid Build Coastguard Worker
847*58b9f456SAndroid Build Coastguard Worker    basic_string(const basic_string& __str, size_type __pos, size_type __n,
848*58b9f456SAndroid Build Coastguard Worker                 const _Allocator& __a = _Allocator());
849*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
850*58b9f456SAndroid Build Coastguard Worker    basic_string(const basic_string& __str, size_type __pos,
851*58b9f456SAndroid Build Coastguard Worker                 const _Allocator& __a = _Allocator());
852*58b9f456SAndroid Build Coastguard Worker
853*58b9f456SAndroid Build Coastguard Worker    template<class _Tp, class = typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type>
854*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
855*58b9f456SAndroid Build Coastguard Worker        basic_string(const _Tp& __t, size_type __pos, size_type __n,
856*58b9f456SAndroid Build Coastguard Worker                              const allocator_type& __a = allocator_type());
857*58b9f456SAndroid Build Coastguard Worker
858*58b9f456SAndroid Build Coastguard Worker    template<class _Tp, class = typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type>
859*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
860*58b9f456SAndroid Build Coastguard Worker        explicit basic_string(const _Tp& __t);
861*58b9f456SAndroid Build Coastguard Worker
862*58b9f456SAndroid Build Coastguard Worker    template<class _Tp, class = typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type>
863*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
864*58b9f456SAndroid Build Coastguard Worker        explicit basic_string(const _Tp& __t, const allocator_type& __a);
865*58b9f456SAndroid Build Coastguard Worker
866*58b9f456SAndroid Build Coastguard Worker    template<class _InputIterator>
867*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
868*58b9f456SAndroid Build Coastguard Worker        basic_string(_InputIterator __first, _InputIterator __last);
869*58b9f456SAndroid Build Coastguard Worker    template<class _InputIterator>
870*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
871*58b9f456SAndroid Build Coastguard Worker        basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a);
872*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
873*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
874*58b9f456SAndroid Build Coastguard Worker    basic_string(initializer_list<_CharT> __il);
875*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
876*58b9f456SAndroid Build Coastguard Worker    basic_string(initializer_list<_CharT> __il, const _Allocator& __a);
877*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
878*58b9f456SAndroid Build Coastguard Worker
879*58b9f456SAndroid Build Coastguard Worker    inline ~basic_string();
880*58b9f456SAndroid Build Coastguard Worker
881*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
882*58b9f456SAndroid Build Coastguard Worker    operator __self_view() const _NOEXCEPT { return __self_view(data(), size()); }
883*58b9f456SAndroid Build Coastguard Worker
884*58b9f456SAndroid Build Coastguard Worker    basic_string& operator=(const basic_string& __str);
885*58b9f456SAndroid Build Coastguard Worker
886*58b9f456SAndroid Build Coastguard Worker    template <class _Tp, class = typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type>
887*58b9f456SAndroid Build Coastguard Worker    basic_string& operator=(const _Tp& __t)
888*58b9f456SAndroid Build Coastguard Worker        {__self_view __sv = __t; return assign(__sv);}
889*58b9f456SAndroid Build Coastguard Worker
890*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
891*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
892*58b9f456SAndroid Build Coastguard Worker    basic_string& operator=(basic_string&& __str)
893*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
894*58b9f456SAndroid Build Coastguard Worker     _LIBCPP_INLINE_VISIBILITY
895*58b9f456SAndroid Build Coastguard Worker    basic_string& operator=(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());}
896*58b9f456SAndroid Build Coastguard Worker#endif
897*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY basic_string& operator=(const value_type* __s) {return assign(__s);}
898*58b9f456SAndroid Build Coastguard Worker    basic_string& operator=(value_type __c);
899*58b9f456SAndroid Build Coastguard Worker
900*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
901*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
902*58b9f456SAndroid Build Coastguard Worker    iterator begin() _NOEXCEPT
903*58b9f456SAndroid Build Coastguard Worker        {return iterator(this, __get_pointer());}
904*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
905*58b9f456SAndroid Build Coastguard Worker    const_iterator begin() const _NOEXCEPT
906*58b9f456SAndroid Build Coastguard Worker        {return const_iterator(this, __get_pointer());}
907*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
908*58b9f456SAndroid Build Coastguard Worker    iterator end() _NOEXCEPT
909*58b9f456SAndroid Build Coastguard Worker        {return iterator(this, __get_pointer() + size());}
910*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
911*58b9f456SAndroid Build Coastguard Worker    const_iterator end() const _NOEXCEPT
912*58b9f456SAndroid Build Coastguard Worker        {return const_iterator(this, __get_pointer() + size());}
913*58b9f456SAndroid Build Coastguard Worker#else
914*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
915*58b9f456SAndroid Build Coastguard Worker    iterator begin() _NOEXCEPT
916*58b9f456SAndroid Build Coastguard Worker        {return iterator(__get_pointer());}
917*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
918*58b9f456SAndroid Build Coastguard Worker    const_iterator begin() const _NOEXCEPT
919*58b9f456SAndroid Build Coastguard Worker        {return const_iterator(__get_pointer());}
920*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
921*58b9f456SAndroid Build Coastguard Worker    iterator end() _NOEXCEPT
922*58b9f456SAndroid Build Coastguard Worker        {return iterator(__get_pointer() + size());}
923*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
924*58b9f456SAndroid Build Coastguard Worker    const_iterator end() const _NOEXCEPT
925*58b9f456SAndroid Build Coastguard Worker        {return const_iterator(__get_pointer() + size());}
926*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_DEBUG_LEVEL >= 2
927*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
928*58b9f456SAndroid Build Coastguard Worker    reverse_iterator rbegin() _NOEXCEPT
929*58b9f456SAndroid Build Coastguard Worker        {return reverse_iterator(end());}
930*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
931*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator rbegin() const _NOEXCEPT
932*58b9f456SAndroid Build Coastguard Worker        {return const_reverse_iterator(end());}
933*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
934*58b9f456SAndroid Build Coastguard Worker    reverse_iterator rend() _NOEXCEPT
935*58b9f456SAndroid Build Coastguard Worker        {return reverse_iterator(begin());}
936*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
937*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator rend() const _NOEXCEPT
938*58b9f456SAndroid Build Coastguard Worker        {return const_reverse_iterator(begin());}
939*58b9f456SAndroid Build Coastguard Worker
940*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
941*58b9f456SAndroid Build Coastguard Worker    const_iterator cbegin() const _NOEXCEPT
942*58b9f456SAndroid Build Coastguard Worker        {return begin();}
943*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
944*58b9f456SAndroid Build Coastguard Worker    const_iterator cend() const _NOEXCEPT
945*58b9f456SAndroid Build Coastguard Worker        {return end();}
946*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
947*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator crbegin() const _NOEXCEPT
948*58b9f456SAndroid Build Coastguard Worker        {return rbegin();}
949*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
950*58b9f456SAndroid Build Coastguard Worker    const_reverse_iterator crend() const _NOEXCEPT
951*58b9f456SAndroid Build Coastguard Worker        {return rend();}
952*58b9f456SAndroid Build Coastguard Worker
953*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY size_type size() const _NOEXCEPT
954*58b9f456SAndroid Build Coastguard Worker        {return __is_long() ? __get_long_size() : __get_short_size();}
955*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY size_type length() const _NOEXCEPT {return size();}
956*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT;
957*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY size_type capacity() const _NOEXCEPT
958*58b9f456SAndroid Build Coastguard Worker        {return (__is_long() ? __get_long_cap()
959*58b9f456SAndroid Build Coastguard Worker                             : static_cast<size_type>(__min_cap)) - 1;}
960*58b9f456SAndroid Build Coastguard Worker
961*58b9f456SAndroid Build Coastguard Worker    void resize(size_type __n, value_type __c);
962*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY void resize(size_type __n) {resize(__n, value_type());}
963*58b9f456SAndroid Build Coastguard Worker
964*58b9f456SAndroid Build Coastguard Worker    void reserve(size_type __res_arg);
965*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY void __resize_default_init(size_type __n);
966*58b9f456SAndroid Build Coastguard Worker
967*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
968*58b9f456SAndroid Build Coastguard Worker    void reserve() _NOEXCEPT {reserve(0);}
969*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
970*58b9f456SAndroid Build Coastguard Worker    void shrink_to_fit() _NOEXCEPT {reserve();}
971*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
972*58b9f456SAndroid Build Coastguard Worker    void clear() _NOEXCEPT;
973*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
974*58b9f456SAndroid Build Coastguard Worker    bool empty() const _NOEXCEPT {return size() == 0;}
975*58b9f456SAndroid Build Coastguard Worker
976*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __pos) const _NOEXCEPT;
977*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY reference       operator[](size_type __pos)       _NOEXCEPT;
978*58b9f456SAndroid Build Coastguard Worker
979*58b9f456SAndroid Build Coastguard Worker    const_reference at(size_type __n) const;
980*58b9f456SAndroid Build Coastguard Worker    reference       at(size_type __n);
981*58b9f456SAndroid Build Coastguard Worker
982*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const basic_string& __str) {return append(__str);}
983*58b9f456SAndroid Build Coastguard Worker
984*58b9f456SAndroid Build Coastguard Worker    template <class _Tp>
985*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
986*58b9f456SAndroid Build Coastguard Worker    typename enable_if
987*58b9f456SAndroid Build Coastguard Worker        <
988*58b9f456SAndroid Build Coastguard Worker            __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
989*58b9f456SAndroid Build Coastguard Worker            basic_string&
990*58b9f456SAndroid Build Coastguard Worker        >::type
991*58b9f456SAndroid Build Coastguard Worker                                            operator+=(const _Tp& __t)            {__self_view __sv = __t; return append(__sv);}
992*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const value_type* __s)     {return append(__s);}
993*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(value_type __c)            {push_back(__c); return *this;}
994*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
995*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(initializer_list<value_type> __il) {return append(__il);}
996*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
997*58b9f456SAndroid Build Coastguard Worker
998*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
999*58b9f456SAndroid Build Coastguard Worker    basic_string& append(const basic_string& __str);
1000*58b9f456SAndroid Build Coastguard Worker
1001*58b9f456SAndroid Build Coastguard Worker    template <class _Tp>
1002*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1003*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1004*58b9f456SAndroid Build Coastguard Worker        <
1005*58b9f456SAndroid Build Coastguard Worker            __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1006*58b9f456SAndroid Build Coastguard Worker            basic_string&
1007*58b9f456SAndroid Build Coastguard Worker        >::type
1008*58b9f456SAndroid Build Coastguard Worker                  append(const _Tp& __t) { __self_view __sv = __t; return append(__sv.data(), __sv.size()); }
1009*58b9f456SAndroid Build Coastguard Worker    basic_string& append(const basic_string& __str, size_type __pos, size_type __n=npos);
1010*58b9f456SAndroid Build Coastguard Worker
1011*58b9f456SAndroid Build Coastguard Worker    template <class _Tp>
1012*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1013*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1014*58b9f456SAndroid Build Coastguard Worker        <
1015*58b9f456SAndroid Build Coastguard Worker            __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1016*58b9f456SAndroid Build Coastguard Worker            basic_string&
1017*58b9f456SAndroid Build Coastguard Worker        >::type
1018*58b9f456SAndroid Build Coastguard Worker                  append(const _Tp& __t, size_type __pos, size_type __n=npos);
1019*58b9f456SAndroid Build Coastguard Worker    basic_string& append(const value_type* __s, size_type __n);
1020*58b9f456SAndroid Build Coastguard Worker    basic_string& append(const value_type* __s);
1021*58b9f456SAndroid Build Coastguard Worker    basic_string& append(size_type __n, value_type __c);
1022*58b9f456SAndroid Build Coastguard Worker
1023*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1024*58b9f456SAndroid Build Coastguard Worker    void __append_default_init(size_type __n);
1025*58b9f456SAndroid Build Coastguard Worker
1026*58b9f456SAndroid Build Coastguard Worker    template <class _ForwardIterator>
1027*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1028*58b9f456SAndroid Build Coastguard Worker    basic_string& __append_forward_unsafe(_ForwardIterator, _ForwardIterator);
1029*58b9f456SAndroid Build Coastguard Worker    template<class _InputIterator>
1030*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1031*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1032*58b9f456SAndroid Build Coastguard Worker        <
1033*58b9f456SAndroid Build Coastguard Worker            __is_exactly_input_iterator<_InputIterator>::value
1034*58b9f456SAndroid Build Coastguard Worker                || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
1035*58b9f456SAndroid Build Coastguard Worker            basic_string&
1036*58b9f456SAndroid Build Coastguard Worker        >::type
1037*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1038*58b9f456SAndroid Build Coastguard Worker    append(_InputIterator __first, _InputIterator __last) {
1039*58b9f456SAndroid Build Coastguard Worker      const basic_string __temp (__first, __last, __alloc());
1040*58b9f456SAndroid Build Coastguard Worker      append(__temp.data(), __temp.size());
1041*58b9f456SAndroid Build Coastguard Worker      return *this;
1042*58b9f456SAndroid Build Coastguard Worker    }
1043*58b9f456SAndroid Build Coastguard Worker    template<class _ForwardIterator>
1044*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1045*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1046*58b9f456SAndroid Build Coastguard Worker        <
1047*58b9f456SAndroid Build Coastguard Worker            __is_forward_iterator<_ForwardIterator>::value
1048*58b9f456SAndroid Build Coastguard Worker                && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,
1049*58b9f456SAndroid Build Coastguard Worker            basic_string&
1050*58b9f456SAndroid Build Coastguard Worker        >::type
1051*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1052*58b9f456SAndroid Build Coastguard Worker    append(_ForwardIterator __first, _ForwardIterator __last) {
1053*58b9f456SAndroid Build Coastguard Worker      return __append_forward_unsafe(__first, __last);
1054*58b9f456SAndroid Build Coastguard Worker    }
1055*58b9f456SAndroid Build Coastguard Worker
1056*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1057*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1058*58b9f456SAndroid Build Coastguard Worker    basic_string& append(initializer_list<value_type> __il) {return append(__il.begin(), __il.size());}
1059*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
1060*58b9f456SAndroid Build Coastguard Worker
1061*58b9f456SAndroid Build Coastguard Worker    void push_back(value_type __c);
1062*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1063*58b9f456SAndroid Build Coastguard Worker    void pop_back();
1064*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY reference       front();
1065*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY const_reference front() const;
1066*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY reference       back();
1067*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY const_reference back() const;
1068*58b9f456SAndroid Build Coastguard Worker
1069*58b9f456SAndroid Build Coastguard Worker    template <class _Tp>
1070*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1071*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1072*58b9f456SAndroid Build Coastguard Worker        <
1073*58b9f456SAndroid Build Coastguard Worker            __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1074*58b9f456SAndroid Build Coastguard Worker            basic_string&
1075*58b9f456SAndroid Build Coastguard Worker        >::type
1076*58b9f456SAndroid Build Coastguard Worker                 assign(const _Tp & __t) { __self_view __sv = __t; return assign(__sv.data(), __sv.size()); }
1077*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1078*58b9f456SAndroid Build Coastguard Worker    basic_string& assign(const basic_string& __str) { return *this = __str; }
1079*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1080*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1081*58b9f456SAndroid Build Coastguard Worker    basic_string& assign(basic_string&& __str)
1082*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
1083*58b9f456SAndroid Build Coastguard Worker        {*this = _VSTD::move(__str); return *this;}
1084*58b9f456SAndroid Build Coastguard Worker#endif
1085*58b9f456SAndroid Build Coastguard Worker    basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos);
1086*58b9f456SAndroid Build Coastguard Worker    template <class _Tp>
1087*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1088*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1089*58b9f456SAndroid Build Coastguard Worker        <
1090*58b9f456SAndroid Build Coastguard Worker            __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1091*58b9f456SAndroid Build Coastguard Worker            basic_string&
1092*58b9f456SAndroid Build Coastguard Worker        >::type
1093*58b9f456SAndroid Build Coastguard Worker                  assign(const _Tp & __t, size_type __pos, size_type __n=npos);
1094*58b9f456SAndroid Build Coastguard Worker    basic_string& assign(const value_type* __s, size_type __n);
1095*58b9f456SAndroid Build Coastguard Worker    basic_string& assign(const value_type* __s);
1096*58b9f456SAndroid Build Coastguard Worker    basic_string& assign(size_type __n, value_type __c);
1097*58b9f456SAndroid Build Coastguard Worker    template<class _InputIterator>
1098*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1099*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1100*58b9f456SAndroid Build Coastguard Worker        <
1101*58b9f456SAndroid Build Coastguard Worker           __is_exactly_input_iterator<_InputIterator>::value
1102*58b9f456SAndroid Build Coastguard Worker                || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
1103*58b9f456SAndroid Build Coastguard Worker            basic_string&
1104*58b9f456SAndroid Build Coastguard Worker        >::type
1105*58b9f456SAndroid Build Coastguard Worker        assign(_InputIterator __first, _InputIterator __last);
1106*58b9f456SAndroid Build Coastguard Worker    template<class _ForwardIterator>
1107*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1108*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1109*58b9f456SAndroid Build Coastguard Worker        <
1110*58b9f456SAndroid Build Coastguard Worker            __is_forward_iterator<_ForwardIterator>::value
1111*58b9f456SAndroid Build Coastguard Worker                 && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,
1112*58b9f456SAndroid Build Coastguard Worker            basic_string&
1113*58b9f456SAndroid Build Coastguard Worker        >::type
1114*58b9f456SAndroid Build Coastguard Worker        assign(_ForwardIterator __first, _ForwardIterator __last);
1115*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1116*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1117*58b9f456SAndroid Build Coastguard Worker    basic_string& assign(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());}
1118*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
1119*58b9f456SAndroid Build Coastguard Worker
1120*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1121*58b9f456SAndroid Build Coastguard Worker    basic_string& insert(size_type __pos1, const basic_string& __str);
1122*58b9f456SAndroid Build Coastguard Worker
1123*58b9f456SAndroid Build Coastguard Worker    template <class _Tp>
1124*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1125*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1126*58b9f456SAndroid Build Coastguard Worker        <
1127*58b9f456SAndroid Build Coastguard Worker            __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1128*58b9f456SAndroid Build Coastguard Worker            basic_string&
1129*58b9f456SAndroid Build Coastguard Worker        >::type
1130*58b9f456SAndroid Build Coastguard Worker                 insert(size_type __pos1, const _Tp& __t)
1131*58b9f456SAndroid Build Coastguard Worker    { __self_view __sv = __t; return insert(__pos1, __sv.data(), __sv.size()); }
1132*58b9f456SAndroid Build Coastguard Worker
1133*58b9f456SAndroid Build Coastguard Worker    template <class _Tp>
1134*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1135*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1136*58b9f456SAndroid Build Coastguard Worker        <
1137*58b9f456SAndroid Build Coastguard Worker            __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1138*58b9f456SAndroid Build Coastguard Worker            basic_string&
1139*58b9f456SAndroid Build Coastguard Worker        >::type
1140*58b9f456SAndroid Build Coastguard Worker                  insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n=npos);
1141*58b9f456SAndroid Build Coastguard Worker    basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n=npos);
1142*58b9f456SAndroid Build Coastguard Worker    basic_string& insert(size_type __pos, const value_type* __s, size_type __n);
1143*58b9f456SAndroid Build Coastguard Worker    basic_string& insert(size_type __pos, const value_type* __s);
1144*58b9f456SAndroid Build Coastguard Worker    basic_string& insert(size_type __pos, size_type __n, value_type __c);
1145*58b9f456SAndroid Build Coastguard Worker    iterator      insert(const_iterator __pos, value_type __c);
1146*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1147*58b9f456SAndroid Build Coastguard Worker    iterator      insert(const_iterator __pos, size_type __n, value_type __c);
1148*58b9f456SAndroid Build Coastguard Worker    template<class _InputIterator>
1149*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1150*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1151*58b9f456SAndroid Build Coastguard Worker        <
1152*58b9f456SAndroid Build Coastguard Worker           __is_exactly_input_iterator<_InputIterator>::value
1153*58b9f456SAndroid Build Coastguard Worker                || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
1154*58b9f456SAndroid Build Coastguard Worker            iterator
1155*58b9f456SAndroid Build Coastguard Worker        >::type
1156*58b9f456SAndroid Build Coastguard Worker        insert(const_iterator __pos, _InputIterator __first, _InputIterator __last);
1157*58b9f456SAndroid Build Coastguard Worker    template<class _ForwardIterator>
1158*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1159*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1160*58b9f456SAndroid Build Coastguard Worker        <
1161*58b9f456SAndroid Build Coastguard Worker            __is_forward_iterator<_ForwardIterator>::value
1162*58b9f456SAndroid Build Coastguard Worker                 && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,
1163*58b9f456SAndroid Build Coastguard Worker            iterator
1164*58b9f456SAndroid Build Coastguard Worker        >::type
1165*58b9f456SAndroid Build Coastguard Worker        insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last);
1166*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1167*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1168*58b9f456SAndroid Build Coastguard Worker    iterator insert(const_iterator __pos, initializer_list<value_type> __il)
1169*58b9f456SAndroid Build Coastguard Worker                    {return insert(__pos, __il.begin(), __il.end());}
1170*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
1171*58b9f456SAndroid Build Coastguard Worker
1172*58b9f456SAndroid Build Coastguard Worker    basic_string& erase(size_type __pos = 0, size_type __n = npos);
1173*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1174*58b9f456SAndroid Build Coastguard Worker    iterator      erase(const_iterator __pos);
1175*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1176*58b9f456SAndroid Build Coastguard Worker    iterator      erase(const_iterator __first, const_iterator __last);
1177*58b9f456SAndroid Build Coastguard Worker
1178*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1179*58b9f456SAndroid Build Coastguard Worker    basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str);
1180*58b9f456SAndroid Build Coastguard Worker
1181*58b9f456SAndroid Build Coastguard Worker    template <class _Tp>
1182*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1183*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1184*58b9f456SAndroid Build Coastguard Worker        <
1185*58b9f456SAndroid Build Coastguard Worker            __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1186*58b9f456SAndroid Build Coastguard Worker            basic_string&
1187*58b9f456SAndroid Build Coastguard Worker        >::type
1188*58b9f456SAndroid Build Coastguard Worker                  replace(size_type __pos1, size_type __n1, const _Tp& __t) { __self_view __sv = __t; return replace(__pos1, __n1, __sv.data(), __sv.size()); }
1189*58b9f456SAndroid Build Coastguard Worker    basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos);
1190*58b9f456SAndroid Build Coastguard Worker    template <class _Tp>
1191*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1192*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1193*58b9f456SAndroid Build Coastguard Worker        <
1194*58b9f456SAndroid Build Coastguard Worker            __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1195*58b9f456SAndroid Build Coastguard Worker            basic_string&
1196*58b9f456SAndroid Build Coastguard Worker        >::type
1197*58b9f456SAndroid Build Coastguard Worker                  replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos);
1198*58b9f456SAndroid Build Coastguard Worker    basic_string& replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2);
1199*58b9f456SAndroid Build Coastguard Worker    basic_string& replace(size_type __pos, size_type __n1, const value_type* __s);
1200*58b9f456SAndroid Build Coastguard Worker    basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c);
1201*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1202*58b9f456SAndroid Build Coastguard Worker    basic_string& replace(const_iterator __i1, const_iterator __i2, const basic_string& __str);
1203*58b9f456SAndroid Build Coastguard Worker
1204*58b9f456SAndroid Build Coastguard Worker    template <class _Tp>
1205*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1206*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1207*58b9f456SAndroid Build Coastguard Worker        <
1208*58b9f456SAndroid Build Coastguard Worker            __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1209*58b9f456SAndroid Build Coastguard Worker            basic_string&
1210*58b9f456SAndroid Build Coastguard Worker        >::type
1211*58b9f456SAndroid Build Coastguard Worker                  replace(const_iterator __i1, const_iterator __i2, const _Tp& __t) { __self_view __sv = __t; return replace(__i1 - begin(), __i2 - __i1, __sv); }
1212*58b9f456SAndroid Build Coastguard Worker
1213*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1214*58b9f456SAndroid Build Coastguard Worker    basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n);
1215*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1216*58b9f456SAndroid Build Coastguard Worker    basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s);
1217*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1218*58b9f456SAndroid Build Coastguard Worker    basic_string& replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c);
1219*58b9f456SAndroid Build Coastguard Worker    template<class _InputIterator>
1220*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1221*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1222*58b9f456SAndroid Build Coastguard Worker        <
1223*58b9f456SAndroid Build Coastguard Worker            __is_input_iterator<_InputIterator>::value,
1224*58b9f456SAndroid Build Coastguard Worker            basic_string&
1225*58b9f456SAndroid Build Coastguard Worker        >::type
1226*58b9f456SAndroid Build Coastguard Worker        replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2);
1227*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1228*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1229*58b9f456SAndroid Build Coastguard Worker    basic_string& replace(const_iterator __i1, const_iterator __i2, initializer_list<value_type> __il)
1230*58b9f456SAndroid Build Coastguard Worker        {return replace(__i1, __i2, __il.begin(), __il.end());}
1231*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
1232*58b9f456SAndroid Build Coastguard Worker
1233*58b9f456SAndroid Build Coastguard Worker    size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const;
1234*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1235*58b9f456SAndroid Build Coastguard Worker    basic_string substr(size_type __pos = 0, size_type __n = npos) const;
1236*58b9f456SAndroid Build Coastguard Worker
1237*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1238*58b9f456SAndroid Build Coastguard Worker    void swap(basic_string& __str)
1239*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER >= 14
1240*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_DEBUG;
1241*58b9f456SAndroid Build Coastguard Worker#else
1242*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value ||
1243*58b9f456SAndroid Build Coastguard Worker                    __is_nothrow_swappable<allocator_type>::value);
1244*58b9f456SAndroid Build Coastguard Worker#endif
1245*58b9f456SAndroid Build Coastguard Worker
1246*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1247*58b9f456SAndroid Build Coastguard Worker    const value_type* c_str() const _NOEXCEPT {return data();}
1248*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1249*58b9f456SAndroid Build Coastguard Worker    const value_type* data() const _NOEXCEPT  {return _VSTD::__to_raw_pointer(__get_pointer());}
1250*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14 || defined(_LIBCPP_BUILDING_LIBRARY)
1251*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1252*58b9f456SAndroid Build Coastguard Worker    value_type* data()             _NOEXCEPT  {return _VSTD::__to_raw_pointer(__get_pointer());}
1253*58b9f456SAndroid Build Coastguard Worker#endif
1254*58b9f456SAndroid Build Coastguard Worker
1255*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1256*58b9f456SAndroid Build Coastguard Worker    allocator_type get_allocator() const _NOEXCEPT {return __alloc();}
1257*58b9f456SAndroid Build Coastguard Worker
1258*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1259*58b9f456SAndroid Build Coastguard Worker    size_type find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
1260*58b9f456SAndroid Build Coastguard Worker
1261*58b9f456SAndroid Build Coastguard Worker    template <class _Tp>
1262*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1263*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1264*58b9f456SAndroid Build Coastguard Worker        <
1265*58b9f456SAndroid Build Coastguard Worker            __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1266*58b9f456SAndroid Build Coastguard Worker            size_type
1267*58b9f456SAndroid Build Coastguard Worker        >::type
1268*58b9f456SAndroid Build Coastguard Worker              find(const _Tp& __t, size_type __pos = 0) const;
1269*58b9f456SAndroid Build Coastguard Worker    size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
1270*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1271*58b9f456SAndroid Build Coastguard Worker    size_type find(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
1272*58b9f456SAndroid Build Coastguard Worker    size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT;
1273*58b9f456SAndroid Build Coastguard Worker
1274*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1275*58b9f456SAndroid Build Coastguard Worker    size_type rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
1276*58b9f456SAndroid Build Coastguard Worker
1277*58b9f456SAndroid Build Coastguard Worker    template <class _Tp>
1278*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1279*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1280*58b9f456SAndroid Build Coastguard Worker        <
1281*58b9f456SAndroid Build Coastguard Worker            __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1282*58b9f456SAndroid Build Coastguard Worker            size_type
1283*58b9f456SAndroid Build Coastguard Worker        >::type
1284*58b9f456SAndroid Build Coastguard Worker              rfind(const _Tp& __t, size_type __pos = npos) const;
1285*58b9f456SAndroid Build Coastguard Worker    size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
1286*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1287*58b9f456SAndroid Build Coastguard Worker    size_type rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
1288*58b9f456SAndroid Build Coastguard Worker    size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT;
1289*58b9f456SAndroid Build Coastguard Worker
1290*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1291*58b9f456SAndroid Build Coastguard Worker    size_type find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
1292*58b9f456SAndroid Build Coastguard Worker
1293*58b9f456SAndroid Build Coastguard Worker    template <class _Tp>
1294*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1295*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1296*58b9f456SAndroid Build Coastguard Worker        <
1297*58b9f456SAndroid Build Coastguard Worker            __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1298*58b9f456SAndroid Build Coastguard Worker            size_type
1299*58b9f456SAndroid Build Coastguard Worker        >::type
1300*58b9f456SAndroid Build Coastguard Worker              find_first_of(const _Tp& __t, size_type __pos = 0) const;
1301*58b9f456SAndroid Build Coastguard Worker    size_type find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
1302*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1303*58b9f456SAndroid Build Coastguard Worker    size_type find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
1304*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1305*58b9f456SAndroid Build Coastguard Worker    size_type find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT;
1306*58b9f456SAndroid Build Coastguard Worker
1307*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1308*58b9f456SAndroid Build Coastguard Worker    size_type find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
1309*58b9f456SAndroid Build Coastguard Worker
1310*58b9f456SAndroid Build Coastguard Worker    template <class _Tp>
1311*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1312*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1313*58b9f456SAndroid Build Coastguard Worker        <
1314*58b9f456SAndroid Build Coastguard Worker            __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1315*58b9f456SAndroid Build Coastguard Worker            size_type
1316*58b9f456SAndroid Build Coastguard Worker        >::type
1317*58b9f456SAndroid Build Coastguard Worker              find_last_of(const _Tp& __t, size_type __pos = npos) const;
1318*58b9f456SAndroid Build Coastguard Worker    size_type find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
1319*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1320*58b9f456SAndroid Build Coastguard Worker    size_type find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
1321*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1322*58b9f456SAndroid Build Coastguard Worker    size_type find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT;
1323*58b9f456SAndroid Build Coastguard Worker
1324*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1325*58b9f456SAndroid Build Coastguard Worker    size_type find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
1326*58b9f456SAndroid Build Coastguard Worker
1327*58b9f456SAndroid Build Coastguard Worker    template <class _Tp>
1328*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1329*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1330*58b9f456SAndroid Build Coastguard Worker        <
1331*58b9f456SAndroid Build Coastguard Worker            __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1332*58b9f456SAndroid Build Coastguard Worker            size_type
1333*58b9f456SAndroid Build Coastguard Worker        >::type
1334*58b9f456SAndroid Build Coastguard Worker              find_first_not_of(const _Tp &__t, size_type __pos = 0) const;
1335*58b9f456SAndroid Build Coastguard Worker    size_type find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
1336*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1337*58b9f456SAndroid Build Coastguard Worker    size_type find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
1338*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1339*58b9f456SAndroid Build Coastguard Worker    size_type find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT;
1340*58b9f456SAndroid Build Coastguard Worker
1341*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1342*58b9f456SAndroid Build Coastguard Worker    size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
1343*58b9f456SAndroid Build Coastguard Worker
1344*58b9f456SAndroid Build Coastguard Worker    template <class _Tp>
1345*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1346*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1347*58b9f456SAndroid Build Coastguard Worker        <
1348*58b9f456SAndroid Build Coastguard Worker            __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1349*58b9f456SAndroid Build Coastguard Worker            size_type
1350*58b9f456SAndroid Build Coastguard Worker        >::type
1351*58b9f456SAndroid Build Coastguard Worker              find_last_not_of(const _Tp& __t, size_type __pos = npos) const;
1352*58b9f456SAndroid Build Coastguard Worker    size_type find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
1353*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1354*58b9f456SAndroid Build Coastguard Worker    size_type find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
1355*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1356*58b9f456SAndroid Build Coastguard Worker    size_type find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT;
1357*58b9f456SAndroid Build Coastguard Worker
1358*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1359*58b9f456SAndroid Build Coastguard Worker    int compare(const basic_string& __str) const _NOEXCEPT;
1360*58b9f456SAndroid Build Coastguard Worker
1361*58b9f456SAndroid Build Coastguard Worker    template <class _Tp>
1362*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1363*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1364*58b9f456SAndroid Build Coastguard Worker        <
1365*58b9f456SAndroid Build Coastguard Worker            __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1366*58b9f456SAndroid Build Coastguard Worker            int
1367*58b9f456SAndroid Build Coastguard Worker        >::type
1368*58b9f456SAndroid Build Coastguard Worker        compare(const _Tp &__t) const;
1369*58b9f456SAndroid Build Coastguard Worker
1370*58b9f456SAndroid Build Coastguard Worker    template <class _Tp>
1371*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1372*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1373*58b9f456SAndroid Build Coastguard Worker        <
1374*58b9f456SAndroid Build Coastguard Worker            __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1375*58b9f456SAndroid Build Coastguard Worker            int
1376*58b9f456SAndroid Build Coastguard Worker        >::type
1377*58b9f456SAndroid Build Coastguard Worker         compare(size_type __pos1, size_type __n1, const _Tp& __t) const;
1378*58b9f456SAndroid Build Coastguard Worker
1379*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1380*58b9f456SAndroid Build Coastguard Worker    int compare(size_type __pos1, size_type __n1, const basic_string& __str) const;
1381*58b9f456SAndroid Build Coastguard Worker    int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos) const;
1382*58b9f456SAndroid Build Coastguard Worker
1383*58b9f456SAndroid Build Coastguard Worker    template <class _Tp>
1384*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_INLINE_VISIBILITY
1385*58b9f456SAndroid Build Coastguard Worker        typename enable_if
1386*58b9f456SAndroid Build Coastguard Worker        <
1387*58b9f456SAndroid Build Coastguard Worker            __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1388*58b9f456SAndroid Build Coastguard Worker            int
1389*58b9f456SAndroid Build Coastguard Worker        >::type
1390*58b9f456SAndroid Build Coastguard Worker        compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos) const;
1391*58b9f456SAndroid Build Coastguard Worker    int compare(const value_type* __s) const _NOEXCEPT;
1392*58b9f456SAndroid Build Coastguard Worker    int compare(size_type __pos1, size_type __n1, const value_type* __s) const;
1393*58b9f456SAndroid Build Coastguard Worker    int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const;
1394*58b9f456SAndroid Build Coastguard Worker
1395*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 17
1396*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
1397*58b9f456SAndroid Build Coastguard Worker    bool starts_with(__self_view __sv) const _NOEXCEPT
1398*58b9f456SAndroid Build Coastguard Worker    { return __self_view(data(), size()).starts_with(__sv); }
1399*58b9f456SAndroid Build Coastguard Worker
1400*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
1401*58b9f456SAndroid Build Coastguard Worker    bool starts_with(value_type __c) const _NOEXCEPT
1402*58b9f456SAndroid Build Coastguard Worker    { return !empty() && _Traits::eq(front(), __c); }
1403*58b9f456SAndroid Build Coastguard Worker
1404*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
1405*58b9f456SAndroid Build Coastguard Worker    bool starts_with(const value_type* __s) const _NOEXCEPT
1406*58b9f456SAndroid Build Coastguard Worker    { return starts_with(__self_view(__s)); }
1407*58b9f456SAndroid Build Coastguard Worker
1408*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
1409*58b9f456SAndroid Build Coastguard Worker    bool ends_with(__self_view __sv) const _NOEXCEPT
1410*58b9f456SAndroid Build Coastguard Worker    { return __self_view(data(), size()).ends_with( __sv); }
1411*58b9f456SAndroid Build Coastguard Worker
1412*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
1413*58b9f456SAndroid Build Coastguard Worker    bool ends_with(value_type __c) const _NOEXCEPT
1414*58b9f456SAndroid Build Coastguard Worker    { return !empty() && _Traits::eq(back(), __c); }
1415*58b9f456SAndroid Build Coastguard Worker
1416*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
1417*58b9f456SAndroid Build Coastguard Worker    bool ends_with(const value_type* __s) const _NOEXCEPT
1418*58b9f456SAndroid Build Coastguard Worker    { return ends_with(__self_view(__s)); }
1419*58b9f456SAndroid Build Coastguard Worker#endif
1420*58b9f456SAndroid Build Coastguard Worker
1421*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY bool __invariants() const;
1422*58b9f456SAndroid Build Coastguard Worker
1423*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY void __clear_and_shrink() _NOEXCEPT;
1424*58b9f456SAndroid Build Coastguard Worker
1425*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1426*58b9f456SAndroid Build Coastguard Worker    bool __is_long() const _NOEXCEPT
1427*58b9f456SAndroid Build Coastguard Worker        {return bool(__r_.first().__s.__size_ & __short_mask);}
1428*58b9f456SAndroid Build Coastguard Worker
1429*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1430*58b9f456SAndroid Build Coastguard Worker
1431*58b9f456SAndroid Build Coastguard Worker    bool __dereferenceable(const const_iterator* __i) const;
1432*58b9f456SAndroid Build Coastguard Worker    bool __decrementable(const const_iterator* __i) const;
1433*58b9f456SAndroid Build Coastguard Worker    bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
1434*58b9f456SAndroid Build Coastguard Worker    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
1435*58b9f456SAndroid Build Coastguard Worker
1436*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_DEBUG_LEVEL >= 2
1437*58b9f456SAndroid Build Coastguard Worker
1438*58b9f456SAndroid Build Coastguard Workerprivate:
1439*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1440*58b9f456SAndroid Build Coastguard Worker    allocator_type& __alloc() _NOEXCEPT
1441*58b9f456SAndroid Build Coastguard Worker        {return __r_.second();}
1442*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1443*58b9f456SAndroid Build Coastguard Worker    const allocator_type& __alloc() const _NOEXCEPT
1444*58b9f456SAndroid Build Coastguard Worker        {return __r_.second();}
1445*58b9f456SAndroid Build Coastguard Worker
1446*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
1447*58b9f456SAndroid Build Coastguard Worker
1448*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1449*58b9f456SAndroid Build Coastguard Worker    void __set_short_size(size_type __s) _NOEXCEPT
1450*58b9f456SAndroid Build Coastguard Worker#   ifdef _LIBCPP_BIG_ENDIAN
1451*58b9f456SAndroid Build Coastguard Worker        {__r_.first().__s.__size_ = (unsigned char)(__s << 1);}
1452*58b9f456SAndroid Build Coastguard Worker#   else
1453*58b9f456SAndroid Build Coastguard Worker        {__r_.first().__s.__size_ = (unsigned char)(__s);}
1454*58b9f456SAndroid Build Coastguard Worker#   endif
1455*58b9f456SAndroid Build Coastguard Worker
1456*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1457*58b9f456SAndroid Build Coastguard Worker    size_type __get_short_size() const _NOEXCEPT
1458*58b9f456SAndroid Build Coastguard Worker#   ifdef _LIBCPP_BIG_ENDIAN
1459*58b9f456SAndroid Build Coastguard Worker        {return __r_.first().__s.__size_ >> 1;}
1460*58b9f456SAndroid Build Coastguard Worker#   else
1461*58b9f456SAndroid Build Coastguard Worker        {return __r_.first().__s.__size_;}
1462*58b9f456SAndroid Build Coastguard Worker#   endif
1463*58b9f456SAndroid Build Coastguard Worker
1464*58b9f456SAndroid Build Coastguard Worker#else  // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
1465*58b9f456SAndroid Build Coastguard Worker
1466*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1467*58b9f456SAndroid Build Coastguard Worker    void __set_short_size(size_type __s) _NOEXCEPT
1468*58b9f456SAndroid Build Coastguard Worker#   ifdef _LIBCPP_BIG_ENDIAN
1469*58b9f456SAndroid Build Coastguard Worker        {__r_.first().__s.__size_ = (unsigned char)(__s);}
1470*58b9f456SAndroid Build Coastguard Worker#   else
1471*58b9f456SAndroid Build Coastguard Worker        {__r_.first().__s.__size_ = (unsigned char)(__s << 1);}
1472*58b9f456SAndroid Build Coastguard Worker#   endif
1473*58b9f456SAndroid Build Coastguard Worker
1474*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1475*58b9f456SAndroid Build Coastguard Worker    size_type __get_short_size() const _NOEXCEPT
1476*58b9f456SAndroid Build Coastguard Worker#   ifdef _LIBCPP_BIG_ENDIAN
1477*58b9f456SAndroid Build Coastguard Worker        {return __r_.first().__s.__size_;}
1478*58b9f456SAndroid Build Coastguard Worker#   else
1479*58b9f456SAndroid Build Coastguard Worker        {return __r_.first().__s.__size_ >> 1;}
1480*58b9f456SAndroid Build Coastguard Worker#   endif
1481*58b9f456SAndroid Build Coastguard Worker
1482*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
1483*58b9f456SAndroid Build Coastguard Worker
1484*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1485*58b9f456SAndroid Build Coastguard Worker    void __set_long_size(size_type __s) _NOEXCEPT
1486*58b9f456SAndroid Build Coastguard Worker        {__r_.first().__l.__size_ = __s;}
1487*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1488*58b9f456SAndroid Build Coastguard Worker    size_type __get_long_size() const _NOEXCEPT
1489*58b9f456SAndroid Build Coastguard Worker        {return __r_.first().__l.__size_;}
1490*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1491*58b9f456SAndroid Build Coastguard Worker    void __set_size(size_type __s) _NOEXCEPT
1492*58b9f456SAndroid Build Coastguard Worker        {if (__is_long()) __set_long_size(__s); else __set_short_size(__s);}
1493*58b9f456SAndroid Build Coastguard Worker
1494*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1495*58b9f456SAndroid Build Coastguard Worker    void __set_long_cap(size_type __s) _NOEXCEPT
1496*58b9f456SAndroid Build Coastguard Worker        {__r_.first().__l.__cap_  = __long_mask | __s;}
1497*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1498*58b9f456SAndroid Build Coastguard Worker    size_type __get_long_cap() const _NOEXCEPT
1499*58b9f456SAndroid Build Coastguard Worker        {return __r_.first().__l.__cap_ & size_type(~__long_mask);}
1500*58b9f456SAndroid Build Coastguard Worker
1501*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1502*58b9f456SAndroid Build Coastguard Worker    void __set_long_pointer(pointer __p) _NOEXCEPT
1503*58b9f456SAndroid Build Coastguard Worker        {__r_.first().__l.__data_ = __p;}
1504*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1505*58b9f456SAndroid Build Coastguard Worker    pointer __get_long_pointer() _NOEXCEPT
1506*58b9f456SAndroid Build Coastguard Worker        {return __r_.first().__l.__data_;}
1507*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1508*58b9f456SAndroid Build Coastguard Worker    const_pointer __get_long_pointer() const _NOEXCEPT
1509*58b9f456SAndroid Build Coastguard Worker        {return __r_.first().__l.__data_;}
1510*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1511*58b9f456SAndroid Build Coastguard Worker    pointer __get_short_pointer() _NOEXCEPT
1512*58b9f456SAndroid Build Coastguard Worker        {return pointer_traits<pointer>::pointer_to(__r_.first().__s.__data_[0]);}
1513*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1514*58b9f456SAndroid Build Coastguard Worker    const_pointer __get_short_pointer() const _NOEXCEPT
1515*58b9f456SAndroid Build Coastguard Worker        {return pointer_traits<const_pointer>::pointer_to(__r_.first().__s.__data_[0]);}
1516*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1517*58b9f456SAndroid Build Coastguard Worker    pointer __get_pointer() _NOEXCEPT
1518*58b9f456SAndroid Build Coastguard Worker        {return __is_long() ? __get_long_pointer() : __get_short_pointer();}
1519*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1520*58b9f456SAndroid Build Coastguard Worker    const_pointer __get_pointer() const _NOEXCEPT
1521*58b9f456SAndroid Build Coastguard Worker        {return __is_long() ? __get_long_pointer() : __get_short_pointer();}
1522*58b9f456SAndroid Build Coastguard Worker
1523*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1524*58b9f456SAndroid Build Coastguard Worker    void __zero() _NOEXCEPT
1525*58b9f456SAndroid Build Coastguard Worker        {
1526*58b9f456SAndroid Build Coastguard Worker            size_type (&__a)[__n_words] = __r_.first().__r.__words;
1527*58b9f456SAndroid Build Coastguard Worker            for (unsigned __i = 0; __i < __n_words; ++__i)
1528*58b9f456SAndroid Build Coastguard Worker                __a[__i] = 0;
1529*58b9f456SAndroid Build Coastguard Worker        }
1530*58b9f456SAndroid Build Coastguard Worker
1531*58b9f456SAndroid Build Coastguard Worker    template <size_type __a> static
1532*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
1533*58b9f456SAndroid Build Coastguard Worker        size_type __align_it(size_type __s) _NOEXCEPT
1534*58b9f456SAndroid Build Coastguard Worker            {return (__s + (__a-1)) & ~(__a-1);}
1535*58b9f456SAndroid Build Coastguard Worker    enum {__alignment = 16};
1536*58b9f456SAndroid Build Coastguard Worker    static _LIBCPP_INLINE_VISIBILITY
1537*58b9f456SAndroid Build Coastguard Worker    size_type __recommend(size_type __s) _NOEXCEPT
1538*58b9f456SAndroid Build Coastguard Worker        {
1539*58b9f456SAndroid Build Coastguard Worker        if (__s < __min_cap) return static_cast<size_type>(__min_cap) - 1;
1540*58b9f456SAndroid Build Coastguard Worker        size_type __guess = __align_it<sizeof(value_type) < __alignment ?
1541*58b9f456SAndroid Build Coastguard Worker                     __alignment/sizeof(value_type) : 1 > (__s+1) - 1;
1542*58b9f456SAndroid Build Coastguard Worker        if (__guess == __min_cap) ++__guess;
1543*58b9f456SAndroid Build Coastguard Worker        return __guess;
1544*58b9f456SAndroid Build Coastguard Worker        }
1545*58b9f456SAndroid Build Coastguard Worker
1546*58b9f456SAndroid Build Coastguard Worker    inline
1547*58b9f456SAndroid Build Coastguard Worker    void __init(const value_type* __s, size_type __sz, size_type __reserve);
1548*58b9f456SAndroid Build Coastguard Worker    inline
1549*58b9f456SAndroid Build Coastguard Worker    void __init(const value_type* __s, size_type __sz);
1550*58b9f456SAndroid Build Coastguard Worker    inline
1551*58b9f456SAndroid Build Coastguard Worker    void __init(size_type __n, value_type __c);
1552*58b9f456SAndroid Build Coastguard Worker
1553*58b9f456SAndroid Build Coastguard Worker    template <class _InputIterator>
1554*58b9f456SAndroid Build Coastguard Worker    inline
1555*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1556*58b9f456SAndroid Build Coastguard Worker    <
1557*58b9f456SAndroid Build Coastguard Worker        __is_exactly_input_iterator<_InputIterator>::value,
1558*58b9f456SAndroid Build Coastguard Worker        void
1559*58b9f456SAndroid Build Coastguard Worker    >::type
1560*58b9f456SAndroid Build Coastguard Worker    __init(_InputIterator __first, _InputIterator __last);
1561*58b9f456SAndroid Build Coastguard Worker
1562*58b9f456SAndroid Build Coastguard Worker    template <class _ForwardIterator>
1563*58b9f456SAndroid Build Coastguard Worker    inline
1564*58b9f456SAndroid Build Coastguard Worker    typename enable_if
1565*58b9f456SAndroid Build Coastguard Worker    <
1566*58b9f456SAndroid Build Coastguard Worker        __is_forward_iterator<_ForwardIterator>::value,
1567*58b9f456SAndroid Build Coastguard Worker        void
1568*58b9f456SAndroid Build Coastguard Worker    >::type
1569*58b9f456SAndroid Build Coastguard Worker    __init(_ForwardIterator __first, _ForwardIterator __last);
1570*58b9f456SAndroid Build Coastguard Worker
1571*58b9f456SAndroid Build Coastguard Worker    void __grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz,
1572*58b9f456SAndroid Build Coastguard Worker                   size_type __n_copy,  size_type __n_del,     size_type __n_add = 0);
1573*58b9f456SAndroid Build Coastguard Worker    void __grow_by_and_replace(size_type __old_cap, size_type __delta_cap, size_type __old_sz,
1574*58b9f456SAndroid Build Coastguard Worker                               size_type __n_copy,  size_type __n_del,
1575*58b9f456SAndroid Build Coastguard Worker                               size_type __n_add, const value_type* __p_new_stuff);
1576*58b9f456SAndroid Build Coastguard Worker
1577*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1578*58b9f456SAndroid Build Coastguard Worker    void __erase_to_end(size_type __pos);
1579*58b9f456SAndroid Build Coastguard Worker
1580*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1581*58b9f456SAndroid Build Coastguard Worker    void __copy_assign_alloc(const basic_string& __str)
1582*58b9f456SAndroid Build Coastguard Worker        {__copy_assign_alloc(__str, integral_constant<bool,
1583*58b9f456SAndroid Build Coastguard Worker                      __alloc_traits::propagate_on_container_copy_assignment::value>());}
1584*58b9f456SAndroid Build Coastguard Worker
1585*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1586*58b9f456SAndroid Build Coastguard Worker    void __copy_assign_alloc(const basic_string& __str, true_type)
1587*58b9f456SAndroid Build Coastguard Worker        {
1588*58b9f456SAndroid Build Coastguard Worker            if (__alloc() == __str.__alloc())
1589*58b9f456SAndroid Build Coastguard Worker                __alloc() = __str.__alloc();
1590*58b9f456SAndroid Build Coastguard Worker            else
1591*58b9f456SAndroid Build Coastguard Worker            {
1592*58b9f456SAndroid Build Coastguard Worker                if (!__str.__is_long())
1593*58b9f456SAndroid Build Coastguard Worker                {
1594*58b9f456SAndroid Build Coastguard Worker                    __clear_and_shrink();
1595*58b9f456SAndroid Build Coastguard Worker                    __alloc() = __str.__alloc();
1596*58b9f456SAndroid Build Coastguard Worker                }
1597*58b9f456SAndroid Build Coastguard Worker                else
1598*58b9f456SAndroid Build Coastguard Worker                {
1599*58b9f456SAndroid Build Coastguard Worker                    allocator_type __a = __str.__alloc();
1600*58b9f456SAndroid Build Coastguard Worker                    pointer __p = __alloc_traits::allocate(__a, __str.__get_long_cap());
1601*58b9f456SAndroid Build Coastguard Worker                    __clear_and_shrink();
1602*58b9f456SAndroid Build Coastguard Worker                    __alloc() = _VSTD::move(__a);
1603*58b9f456SAndroid Build Coastguard Worker                    __set_long_pointer(__p);
1604*58b9f456SAndroid Build Coastguard Worker                    __set_long_cap(__str.__get_long_cap());
1605*58b9f456SAndroid Build Coastguard Worker                    __set_long_size(__str.size());
1606*58b9f456SAndroid Build Coastguard Worker                }
1607*58b9f456SAndroid Build Coastguard Worker            }
1608*58b9f456SAndroid Build Coastguard Worker        }
1609*58b9f456SAndroid Build Coastguard Worker
1610*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1611*58b9f456SAndroid Build Coastguard Worker    void __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT
1612*58b9f456SAndroid Build Coastguard Worker        {}
1613*58b9f456SAndroid Build Coastguard Worker
1614*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1615*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1616*58b9f456SAndroid Build Coastguard Worker    void __move_assign(basic_string& __str, false_type)
1617*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(__alloc_traits::is_always_equal::value);
1618*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1619*58b9f456SAndroid Build Coastguard Worker    void __move_assign(basic_string& __str, true_type)
1620*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14
1621*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT;
1622*58b9f456SAndroid Build Coastguard Worker#else
1623*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
1624*58b9f456SAndroid Build Coastguard Worker#endif
1625*58b9f456SAndroid Build Coastguard Worker#endif
1626*58b9f456SAndroid Build Coastguard Worker
1627*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1628*58b9f456SAndroid Build Coastguard Worker    void
1629*58b9f456SAndroid Build Coastguard Worker    __move_assign_alloc(basic_string& __str)
1630*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(
1631*58b9f456SAndroid Build Coastguard Worker            !__alloc_traits::propagate_on_container_move_assignment::value ||
1632*58b9f456SAndroid Build Coastguard Worker            is_nothrow_move_assignable<allocator_type>::value)
1633*58b9f456SAndroid Build Coastguard Worker    {__move_assign_alloc(__str, integral_constant<bool,
1634*58b9f456SAndroid Build Coastguard Worker                      __alloc_traits::propagate_on_container_move_assignment::value>());}
1635*58b9f456SAndroid Build Coastguard Worker
1636*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1637*58b9f456SAndroid Build Coastguard Worker    void __move_assign_alloc(basic_string& __c, true_type)
1638*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
1639*58b9f456SAndroid Build Coastguard Worker        {
1640*58b9f456SAndroid Build Coastguard Worker            __alloc() = _VSTD::move(__c.__alloc());
1641*58b9f456SAndroid Build Coastguard Worker        }
1642*58b9f456SAndroid Build Coastguard Worker
1643*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1644*58b9f456SAndroid Build Coastguard Worker    void __move_assign_alloc(basic_string&, false_type)
1645*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT
1646*58b9f456SAndroid Build Coastguard Worker        {}
1647*58b9f456SAndroid Build Coastguard Worker
1648*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
1649*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(size_type);
1650*58b9f456SAndroid Build Coastguard Worker
1651*58b9f456SAndroid Build Coastguard Worker    friend basic_string operator+<>(const basic_string&, const basic_string&);
1652*58b9f456SAndroid Build Coastguard Worker    friend basic_string operator+<>(const value_type*, const basic_string&);
1653*58b9f456SAndroid Build Coastguard Worker    friend basic_string operator+<>(value_type, const basic_string&);
1654*58b9f456SAndroid Build Coastguard Worker    friend basic_string operator+<>(const basic_string&, const value_type*);
1655*58b9f456SAndroid Build Coastguard Worker    friend basic_string operator+<>(const basic_string&, value_type);
1656*58b9f456SAndroid Build Coastguard Worker};
1657*58b9f456SAndroid Build Coastguard Worker
1658*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
1659*58b9f456SAndroid Build Coastguard Workertemplate<class _InputIterator,
1660*58b9f456SAndroid Build Coastguard Worker         class _CharT = typename iterator_traits<_InputIterator>::value_type,
1661*58b9f456SAndroid Build Coastguard Worker         class _Allocator = allocator<_CharT>,
1662*58b9f456SAndroid Build Coastguard Worker         class = typename enable_if<__is_input_iterator<_InputIterator>::value, void>::type,
1663*58b9f456SAndroid Build Coastguard Worker         class = typename enable_if<__is_allocator<_Allocator>::value, void>::type
1664*58b9f456SAndroid Build Coastguard Worker         >
1665*58b9f456SAndroid Build Coastguard Workerbasic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
1666*58b9f456SAndroid Build Coastguard Worker  -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
1667*58b9f456SAndroid Build Coastguard Worker
1668*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT,
1669*58b9f456SAndroid Build Coastguard Worker         class _Traits,
1670*58b9f456SAndroid Build Coastguard Worker         class _Allocator = allocator<_CharT>,
1671*58b9f456SAndroid Build Coastguard Worker         class = typename enable_if<__is_allocator<_Allocator>::value, void>::type
1672*58b9f456SAndroid Build Coastguard Worker         >
1673*58b9f456SAndroid Build Coastguard Workerexplicit basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _Allocator())
1674*58b9f456SAndroid Build Coastguard Worker  -> basic_string<_CharT, _Traits, _Allocator>;
1675*58b9f456SAndroid Build Coastguard Worker
1676*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT,
1677*58b9f456SAndroid Build Coastguard Worker         class _Traits,
1678*58b9f456SAndroid Build Coastguard Worker         class _Allocator = allocator<_CharT>,
1679*58b9f456SAndroid Build Coastguard Worker         class = typename enable_if<__is_allocator<_Allocator>::value, void>::type,
1680*58b9f456SAndroid Build Coastguard Worker         class _Sz = typename allocator_traits<_Allocator>::size_type
1681*58b9f456SAndroid Build Coastguard Worker         >
1682*58b9f456SAndroid Build Coastguard Workerbasic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _Allocator())
1683*58b9f456SAndroid Build Coastguard Worker  -> basic_string<_CharT, _Traits, _Allocator>;
1684*58b9f456SAndroid Build Coastguard Worker#endif
1685*58b9f456SAndroid Build Coastguard Worker
1686*58b9f456SAndroid Build Coastguard Worker
1687*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
1688*58b9f456SAndroid Build Coastguard Workerinline
1689*58b9f456SAndroid Build Coastguard Workervoid
1690*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::__invalidate_all_iterators()
1691*58b9f456SAndroid Build Coastguard Worker{
1692*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1693*58b9f456SAndroid Build Coastguard Worker    __get_db()->__invalidate_all(this);
1694*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_DEBUG_LEVEL >= 2
1695*58b9f456SAndroid Build Coastguard Worker}
1696*58b9f456SAndroid Build Coastguard Worker
1697*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
1698*58b9f456SAndroid Build Coastguard Workerinline
1699*58b9f456SAndroid Build Coastguard Workervoid
1700*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type
1701*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1702*58b9f456SAndroid Build Coastguard Worker                                                                        __pos
1703*58b9f456SAndroid Build Coastguard Worker#endif
1704*58b9f456SAndroid Build Coastguard Worker                                                                      )
1705*58b9f456SAndroid Build Coastguard Worker{
1706*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1707*58b9f456SAndroid Build Coastguard Worker    __c_node* __c = __get_db()->__find_c_and_lock(this);
1708*58b9f456SAndroid Build Coastguard Worker    if (__c)
1709*58b9f456SAndroid Build Coastguard Worker    {
1710*58b9f456SAndroid Build Coastguard Worker        const_pointer __new_last = __get_pointer() + __pos;
1711*58b9f456SAndroid Build Coastguard Worker        for (__i_node** __p = __c->end_; __p != __c->beg_; )
1712*58b9f456SAndroid Build Coastguard Worker        {
1713*58b9f456SAndroid Build Coastguard Worker            --__p;
1714*58b9f456SAndroid Build Coastguard Worker            const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_);
1715*58b9f456SAndroid Build Coastguard Worker            if (__i->base() > __new_last)
1716*58b9f456SAndroid Build Coastguard Worker            {
1717*58b9f456SAndroid Build Coastguard Worker                (*__p)->__c_ = nullptr;
1718*58b9f456SAndroid Build Coastguard Worker                if (--__c->end_ != __p)
1719*58b9f456SAndroid Build Coastguard Worker                    memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
1720*58b9f456SAndroid Build Coastguard Worker            }
1721*58b9f456SAndroid Build Coastguard Worker        }
1722*58b9f456SAndroid Build Coastguard Worker        __get_db()->unlock();
1723*58b9f456SAndroid Build Coastguard Worker    }
1724*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_DEBUG_LEVEL >= 2
1725*58b9f456SAndroid Build Coastguard Worker}
1726*58b9f456SAndroid Build Coastguard Worker
1727*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
1728*58b9f456SAndroid Build Coastguard Workerinline
1729*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::basic_string()
1730*58b9f456SAndroid Build Coastguard Worker    _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
1731*58b9f456SAndroid Build Coastguard Worker{
1732*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1733*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1734*58b9f456SAndroid Build Coastguard Worker#endif
1735*58b9f456SAndroid Build Coastguard Worker    __zero();
1736*58b9f456SAndroid Build Coastguard Worker}
1737*58b9f456SAndroid Build Coastguard Worker
1738*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
1739*58b9f456SAndroid Build Coastguard Workerinline
1740*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a)
1741*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER <= 14
1742*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
1743*58b9f456SAndroid Build Coastguard Worker#else
1744*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT
1745*58b9f456SAndroid Build Coastguard Worker#endif
1746*58b9f456SAndroid Build Coastguard Worker: __r_(__second_tag(), __a)
1747*58b9f456SAndroid Build Coastguard Worker{
1748*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1749*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1750*58b9f456SAndroid Build Coastguard Worker#endif
1751*58b9f456SAndroid Build Coastguard Worker    __zero();
1752*58b9f456SAndroid Build Coastguard Worker}
1753*58b9f456SAndroid Build Coastguard Worker
1754*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
1755*58b9f456SAndroid Build Coastguard Workervoid basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s,
1756*58b9f456SAndroid Build Coastguard Worker                                                       size_type __sz,
1757*58b9f456SAndroid Build Coastguard Worker                                                       size_type __reserve)
1758*58b9f456SAndroid Build Coastguard Worker{
1759*58b9f456SAndroid Build Coastguard Worker    if (__reserve > max_size())
1760*58b9f456SAndroid Build Coastguard Worker        this->__throw_length_error();
1761*58b9f456SAndroid Build Coastguard Worker    pointer __p;
1762*58b9f456SAndroid Build Coastguard Worker    if (__reserve < __min_cap)
1763*58b9f456SAndroid Build Coastguard Worker    {
1764*58b9f456SAndroid Build Coastguard Worker        __set_short_size(__sz);
1765*58b9f456SAndroid Build Coastguard Worker        __p = __get_short_pointer();
1766*58b9f456SAndroid Build Coastguard Worker    }
1767*58b9f456SAndroid Build Coastguard Worker    else
1768*58b9f456SAndroid Build Coastguard Worker    {
1769*58b9f456SAndroid Build Coastguard Worker        size_type __cap = __recommend(__reserve);
1770*58b9f456SAndroid Build Coastguard Worker        __p = __alloc_traits::allocate(__alloc(), __cap+1);
1771*58b9f456SAndroid Build Coastguard Worker        __set_long_pointer(__p);
1772*58b9f456SAndroid Build Coastguard Worker        __set_long_cap(__cap+1);
1773*58b9f456SAndroid Build Coastguard Worker        __set_long_size(__sz);
1774*58b9f456SAndroid Build Coastguard Worker    }
1775*58b9f456SAndroid Build Coastguard Worker    traits_type::copy(_VSTD::__to_raw_pointer(__p), __s, __sz);
1776*58b9f456SAndroid Build Coastguard Worker    traits_type::assign(__p[__sz], value_type());
1777*58b9f456SAndroid Build Coastguard Worker}
1778*58b9f456SAndroid Build Coastguard Worker
1779*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
1780*58b9f456SAndroid Build Coastguard Workervoid
1781*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz)
1782*58b9f456SAndroid Build Coastguard Worker{
1783*58b9f456SAndroid Build Coastguard Worker    if (__sz > max_size())
1784*58b9f456SAndroid Build Coastguard Worker        this->__throw_length_error();
1785*58b9f456SAndroid Build Coastguard Worker    pointer __p;
1786*58b9f456SAndroid Build Coastguard Worker    if (__sz < __min_cap)
1787*58b9f456SAndroid Build Coastguard Worker    {
1788*58b9f456SAndroid Build Coastguard Worker        __set_short_size(__sz);
1789*58b9f456SAndroid Build Coastguard Worker        __p = __get_short_pointer();
1790*58b9f456SAndroid Build Coastguard Worker    }
1791*58b9f456SAndroid Build Coastguard Worker    else
1792*58b9f456SAndroid Build Coastguard Worker    {
1793*58b9f456SAndroid Build Coastguard Worker        size_type __cap = __recommend(__sz);
1794*58b9f456SAndroid Build Coastguard Worker        __p = __alloc_traits::allocate(__alloc(), __cap+1);
1795*58b9f456SAndroid Build Coastguard Worker        __set_long_pointer(__p);
1796*58b9f456SAndroid Build Coastguard Worker        __set_long_cap(__cap+1);
1797*58b9f456SAndroid Build Coastguard Worker        __set_long_size(__sz);
1798*58b9f456SAndroid Build Coastguard Worker    }
1799*58b9f456SAndroid Build Coastguard Worker    traits_type::copy(_VSTD::__to_raw_pointer(__p), __s, __sz);
1800*58b9f456SAndroid Build Coastguard Worker    traits_type::assign(__p[__sz], value_type());
1801*58b9f456SAndroid Build Coastguard Worker}
1802*58b9f456SAndroid Build Coastguard Worker
1803*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
1804*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
1805*58b9f456SAndroid Build Coastguard Workertemplate <class>
1806*58b9f456SAndroid Build Coastguard Worker#endif
1807*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a)
1808*58b9f456SAndroid Build Coastguard Worker    : __r_(__second_tag(), __a)
1809*58b9f456SAndroid Build Coastguard Worker{
1810*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr");
1811*58b9f456SAndroid Build Coastguard Worker    __init(__s, traits_type::length(__s));
1812*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1813*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1814*58b9f456SAndroid Build Coastguard Worker#endif
1815*58b9f456SAndroid Build Coastguard Worker}
1816*58b9f456SAndroid Build Coastguard Worker
1817*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
1818*58b9f456SAndroid Build Coastguard Workerinline
1819*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n)
1820*58b9f456SAndroid Build Coastguard Worker{
1821*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr");
1822*58b9f456SAndroid Build Coastguard Worker    __init(__s, __n);
1823*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1824*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1825*58b9f456SAndroid Build Coastguard Worker#endif
1826*58b9f456SAndroid Build Coastguard Worker}
1827*58b9f456SAndroid Build Coastguard Worker
1828*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
1829*58b9f456SAndroid Build Coastguard Workerinline
1830*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n, const _Allocator& __a)
1831*58b9f456SAndroid Build Coastguard Worker    : __r_(__second_tag(), __a)
1832*58b9f456SAndroid Build Coastguard Worker{
1833*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr");
1834*58b9f456SAndroid Build Coastguard Worker    __init(__s, __n);
1835*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1836*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1837*58b9f456SAndroid Build Coastguard Worker#endif
1838*58b9f456SAndroid Build Coastguard Worker}
1839*58b9f456SAndroid Build Coastguard Worker
1840*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
1841*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str)
1842*58b9f456SAndroid Build Coastguard Worker    : __r_(__second_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc()))
1843*58b9f456SAndroid Build Coastguard Worker{
1844*58b9f456SAndroid Build Coastguard Worker    if (!__str.__is_long())
1845*58b9f456SAndroid Build Coastguard Worker        __r_.first().__r = __str.__r_.first().__r;
1846*58b9f456SAndroid Build Coastguard Worker    else
1847*58b9f456SAndroid Build Coastguard Worker        __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size());
1848*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1849*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1850*58b9f456SAndroid Build Coastguard Worker#endif
1851*58b9f456SAndroid Build Coastguard Worker}
1852*58b9f456SAndroid Build Coastguard Worker
1853*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
1854*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::basic_string(
1855*58b9f456SAndroid Build Coastguard Worker    const basic_string& __str, const allocator_type& __a)
1856*58b9f456SAndroid Build Coastguard Worker    : __r_(__second_tag(), __a)
1857*58b9f456SAndroid Build Coastguard Worker{
1858*58b9f456SAndroid Build Coastguard Worker    if (!__str.__is_long())
1859*58b9f456SAndroid Build Coastguard Worker        __r_.first().__r = __str.__r_.first().__r;
1860*58b9f456SAndroid Build Coastguard Worker    else
1861*58b9f456SAndroid Build Coastguard Worker        __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size());
1862*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1863*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1864*58b9f456SAndroid Build Coastguard Worker#endif
1865*58b9f456SAndroid Build Coastguard Worker}
1866*58b9f456SAndroid Build Coastguard Worker
1867*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
1868*58b9f456SAndroid Build Coastguard Worker
1869*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
1870*58b9f456SAndroid Build Coastguard Workerinline
1871*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str)
1872*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER <= 14
1873*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
1874*58b9f456SAndroid Build Coastguard Worker#else
1875*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT
1876*58b9f456SAndroid Build Coastguard Worker#endif
1877*58b9f456SAndroid Build Coastguard Worker    : __r_(_VSTD::move(__str.__r_))
1878*58b9f456SAndroid Build Coastguard Worker{
1879*58b9f456SAndroid Build Coastguard Worker    __str.__zero();
1880*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1881*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1882*58b9f456SAndroid Build Coastguard Worker    if (__is_long())
1883*58b9f456SAndroid Build Coastguard Worker        __get_db()->swap(this, &__str);
1884*58b9f456SAndroid Build Coastguard Worker#endif
1885*58b9f456SAndroid Build Coastguard Worker}
1886*58b9f456SAndroid Build Coastguard Worker
1887*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
1888*58b9f456SAndroid Build Coastguard Workerinline
1889*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a)
1890*58b9f456SAndroid Build Coastguard Worker    : __r_(__second_tag(), __a)
1891*58b9f456SAndroid Build Coastguard Worker{
1892*58b9f456SAndroid Build Coastguard Worker    if (__str.__is_long() && __a != __str.__alloc()) // copy, not move
1893*58b9f456SAndroid Build Coastguard Worker        __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size());
1894*58b9f456SAndroid Build Coastguard Worker    else
1895*58b9f456SAndroid Build Coastguard Worker    {
1896*58b9f456SAndroid Build Coastguard Worker        __r_.first().__r = __str.__r_.first().__r;
1897*58b9f456SAndroid Build Coastguard Worker        __str.__zero();
1898*58b9f456SAndroid Build Coastguard Worker    }
1899*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1900*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1901*58b9f456SAndroid Build Coastguard Worker    if (__is_long())
1902*58b9f456SAndroid Build Coastguard Worker        __get_db()->swap(this, &__str);
1903*58b9f456SAndroid Build Coastguard Worker#endif
1904*58b9f456SAndroid Build Coastguard Worker}
1905*58b9f456SAndroid Build Coastguard Worker
1906*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
1907*58b9f456SAndroid Build Coastguard Worker
1908*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
1909*58b9f456SAndroid Build Coastguard Workervoid
1910*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c)
1911*58b9f456SAndroid Build Coastguard Worker{
1912*58b9f456SAndroid Build Coastguard Worker    if (__n > max_size())
1913*58b9f456SAndroid Build Coastguard Worker        this->__throw_length_error();
1914*58b9f456SAndroid Build Coastguard Worker    pointer __p;
1915*58b9f456SAndroid Build Coastguard Worker    if (__n < __min_cap)
1916*58b9f456SAndroid Build Coastguard Worker    {
1917*58b9f456SAndroid Build Coastguard Worker        __set_short_size(__n);
1918*58b9f456SAndroid Build Coastguard Worker        __p = __get_short_pointer();
1919*58b9f456SAndroid Build Coastguard Worker    }
1920*58b9f456SAndroid Build Coastguard Worker    else
1921*58b9f456SAndroid Build Coastguard Worker    {
1922*58b9f456SAndroid Build Coastguard Worker        size_type __cap = __recommend(__n);
1923*58b9f456SAndroid Build Coastguard Worker        __p = __alloc_traits::allocate(__alloc(), __cap+1);
1924*58b9f456SAndroid Build Coastguard Worker        __set_long_pointer(__p);
1925*58b9f456SAndroid Build Coastguard Worker        __set_long_cap(__cap+1);
1926*58b9f456SAndroid Build Coastguard Worker        __set_long_size(__n);
1927*58b9f456SAndroid Build Coastguard Worker    }
1928*58b9f456SAndroid Build Coastguard Worker    traits_type::assign(_VSTD::__to_raw_pointer(__p), __n, __c);
1929*58b9f456SAndroid Build Coastguard Worker    traits_type::assign(__p[__n], value_type());
1930*58b9f456SAndroid Build Coastguard Worker}
1931*58b9f456SAndroid Build Coastguard Worker
1932*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
1933*58b9f456SAndroid Build Coastguard Workerinline
1934*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c)
1935*58b9f456SAndroid Build Coastguard Worker{
1936*58b9f456SAndroid Build Coastguard Worker    __init(__n, __c);
1937*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1938*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1939*58b9f456SAndroid Build Coastguard Worker#endif
1940*58b9f456SAndroid Build Coastguard Worker}
1941*58b9f456SAndroid Build Coastguard Worker
1942*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
1943*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
1944*58b9f456SAndroid Build Coastguard Workertemplate <class>
1945*58b9f456SAndroid Build Coastguard Worker#endif
1946*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c, const _Allocator& __a)
1947*58b9f456SAndroid Build Coastguard Worker    : __r_(__second_tag(), __a)
1948*58b9f456SAndroid Build Coastguard Worker{
1949*58b9f456SAndroid Build Coastguard Worker    __init(__n, __c);
1950*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1951*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1952*58b9f456SAndroid Build Coastguard Worker#endif
1953*58b9f456SAndroid Build Coastguard Worker}
1954*58b9f456SAndroid Build Coastguard Worker
1955*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
1956*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str,
1957*58b9f456SAndroid Build Coastguard Worker                                                        size_type __pos, size_type __n,
1958*58b9f456SAndroid Build Coastguard Worker                                                        const _Allocator& __a)
1959*58b9f456SAndroid Build Coastguard Worker    : __r_(__second_tag(), __a)
1960*58b9f456SAndroid Build Coastguard Worker{
1961*58b9f456SAndroid Build Coastguard Worker    size_type __str_sz = __str.size();
1962*58b9f456SAndroid Build Coastguard Worker    if (__pos > __str_sz)
1963*58b9f456SAndroid Build Coastguard Worker        this->__throw_out_of_range();
1964*58b9f456SAndroid Build Coastguard Worker    __init(__str.data() + __pos, _VSTD::min(__n, __str_sz - __pos));
1965*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1966*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1967*58b9f456SAndroid Build Coastguard Worker#endif
1968*58b9f456SAndroid Build Coastguard Worker}
1969*58b9f456SAndroid Build Coastguard Worker
1970*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
1971*58b9f456SAndroid Build Coastguard Workerinline
1972*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos,
1973*58b9f456SAndroid Build Coastguard Worker                                                        const _Allocator& __a)
1974*58b9f456SAndroid Build Coastguard Worker    : __r_(__second_tag(), __a)
1975*58b9f456SAndroid Build Coastguard Worker{
1976*58b9f456SAndroid Build Coastguard Worker    size_type __str_sz = __str.size();
1977*58b9f456SAndroid Build Coastguard Worker    if (__pos > __str_sz)
1978*58b9f456SAndroid Build Coastguard Worker        this->__throw_out_of_range();
1979*58b9f456SAndroid Build Coastguard Worker    __init(__str.data() + __pos, __str_sz - __pos);
1980*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1981*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1982*58b9f456SAndroid Build Coastguard Worker#endif
1983*58b9f456SAndroid Build Coastguard Worker}
1984*58b9f456SAndroid Build Coastguard Worker
1985*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
1986*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class>
1987*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::basic_string(
1988*58b9f456SAndroid Build Coastguard Worker             const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a)
1989*58b9f456SAndroid Build Coastguard Worker    : __r_(__second_tag(), __a)
1990*58b9f456SAndroid Build Coastguard Worker{
1991*58b9f456SAndroid Build Coastguard Worker    __self_view __sv0 = __t;
1992*58b9f456SAndroid Build Coastguard Worker    __self_view __sv = __sv0.substr(__pos, __n);
1993*58b9f456SAndroid Build Coastguard Worker    __init(__sv.data(), __sv.size());
1994*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
1995*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
1996*58b9f456SAndroid Build Coastguard Worker#endif
1997*58b9f456SAndroid Build Coastguard Worker}
1998*58b9f456SAndroid Build Coastguard Worker
1999*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2000*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class>
2001*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t)
2002*58b9f456SAndroid Build Coastguard Worker{
2003*58b9f456SAndroid Build Coastguard Worker    __self_view __sv = __t;
2004*58b9f456SAndroid Build Coastguard Worker    __init(__sv.data(), __sv.size());
2005*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2006*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
2007*58b9f456SAndroid Build Coastguard Worker#endif
2008*58b9f456SAndroid Build Coastguard Worker}
2009*58b9f456SAndroid Build Coastguard Worker
2010*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2011*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class>
2012*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _Allocator& __a)
2013*58b9f456SAndroid Build Coastguard Worker    : __r_(__second_tag(), __a)
2014*58b9f456SAndroid Build Coastguard Worker{
2015*58b9f456SAndroid Build Coastguard Worker    __self_view __sv = __t;
2016*58b9f456SAndroid Build Coastguard Worker    __init(__sv.data(), __sv.size());
2017*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2018*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
2019*58b9f456SAndroid Build Coastguard Worker#endif
2020*58b9f456SAndroid Build Coastguard Worker}
2021*58b9f456SAndroid Build Coastguard Worker
2022*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2023*58b9f456SAndroid Build Coastguard Workertemplate <class _InputIterator>
2024*58b9f456SAndroid Build Coastguard Workertypename enable_if
2025*58b9f456SAndroid Build Coastguard Worker<
2026*58b9f456SAndroid Build Coastguard Worker    __is_exactly_input_iterator<_InputIterator>::value,
2027*58b9f456SAndroid Build Coastguard Worker    void
2028*58b9f456SAndroid Build Coastguard Worker>::type
2029*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _InputIterator __last)
2030*58b9f456SAndroid Build Coastguard Worker{
2031*58b9f456SAndroid Build Coastguard Worker    __zero();
2032*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
2033*58b9f456SAndroid Build Coastguard Worker    try
2034*58b9f456SAndroid Build Coastguard Worker    {
2035*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
2036*58b9f456SAndroid Build Coastguard Worker    for (; __first != __last; ++__first)
2037*58b9f456SAndroid Build Coastguard Worker        push_back(*__first);
2038*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_EXCEPTIONS
2039*58b9f456SAndroid Build Coastguard Worker    }
2040*58b9f456SAndroid Build Coastguard Worker    catch (...)
2041*58b9f456SAndroid Build Coastguard Worker    {
2042*58b9f456SAndroid Build Coastguard Worker        if (__is_long())
2043*58b9f456SAndroid Build Coastguard Worker            __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap());
2044*58b9f456SAndroid Build Coastguard Worker        throw;
2045*58b9f456SAndroid Build Coastguard Worker    }
2046*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_NO_EXCEPTIONS
2047*58b9f456SAndroid Build Coastguard Worker}
2048*58b9f456SAndroid Build Coastguard Worker
2049*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2050*58b9f456SAndroid Build Coastguard Workertemplate <class _ForwardIterator>
2051*58b9f456SAndroid Build Coastguard Workertypename enable_if
2052*58b9f456SAndroid Build Coastguard Worker<
2053*58b9f456SAndroid Build Coastguard Worker    __is_forward_iterator<_ForwardIterator>::value,
2054*58b9f456SAndroid Build Coastguard Worker    void
2055*58b9f456SAndroid Build Coastguard Worker>::type
2056*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _ForwardIterator __last)
2057*58b9f456SAndroid Build Coastguard Worker{
2058*58b9f456SAndroid Build Coastguard Worker    size_type __sz = static_cast<size_type>(_VSTD::distance(__first, __last));
2059*58b9f456SAndroid Build Coastguard Worker    if (__sz > max_size())
2060*58b9f456SAndroid Build Coastguard Worker        this->__throw_length_error();
2061*58b9f456SAndroid Build Coastguard Worker    pointer __p;
2062*58b9f456SAndroid Build Coastguard Worker    if (__sz < __min_cap)
2063*58b9f456SAndroid Build Coastguard Worker    {
2064*58b9f456SAndroid Build Coastguard Worker        __set_short_size(__sz);
2065*58b9f456SAndroid Build Coastguard Worker        __p = __get_short_pointer();
2066*58b9f456SAndroid Build Coastguard Worker    }
2067*58b9f456SAndroid Build Coastguard Worker    else
2068*58b9f456SAndroid Build Coastguard Worker    {
2069*58b9f456SAndroid Build Coastguard Worker        size_type __cap = __recommend(__sz);
2070*58b9f456SAndroid Build Coastguard Worker        __p = __alloc_traits::allocate(__alloc(), __cap+1);
2071*58b9f456SAndroid Build Coastguard Worker        __set_long_pointer(__p);
2072*58b9f456SAndroid Build Coastguard Worker        __set_long_cap(__cap+1);
2073*58b9f456SAndroid Build Coastguard Worker        __set_long_size(__sz);
2074*58b9f456SAndroid Build Coastguard Worker    }
2075*58b9f456SAndroid Build Coastguard Worker    for (; __first != __last; ++__first, (void) ++__p)
2076*58b9f456SAndroid Build Coastguard Worker        traits_type::assign(*__p, *__first);
2077*58b9f456SAndroid Build Coastguard Worker    traits_type::assign(*__p, value_type());
2078*58b9f456SAndroid Build Coastguard Worker}
2079*58b9f456SAndroid Build Coastguard Worker
2080*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2081*58b9f456SAndroid Build Coastguard Workertemplate<class _InputIterator>
2082*58b9f456SAndroid Build Coastguard Workerinline
2083*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last)
2084*58b9f456SAndroid Build Coastguard Worker{
2085*58b9f456SAndroid Build Coastguard Worker    __init(__first, __last);
2086*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2087*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
2088*58b9f456SAndroid Build Coastguard Worker#endif
2089*58b9f456SAndroid Build Coastguard Worker}
2090*58b9f456SAndroid Build Coastguard Worker
2091*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2092*58b9f456SAndroid Build Coastguard Workertemplate<class _InputIterator>
2093*58b9f456SAndroid Build Coastguard Workerinline
2094*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last,
2095*58b9f456SAndroid Build Coastguard Worker                                                        const allocator_type& __a)
2096*58b9f456SAndroid Build Coastguard Worker    : __r_(__second_tag(), __a)
2097*58b9f456SAndroid Build Coastguard Worker{
2098*58b9f456SAndroid Build Coastguard Worker    __init(__first, __last);
2099*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2100*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
2101*58b9f456SAndroid Build Coastguard Worker#endif
2102*58b9f456SAndroid Build Coastguard Worker}
2103*58b9f456SAndroid Build Coastguard Worker
2104*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
2105*58b9f456SAndroid Build Coastguard Worker
2106*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2107*58b9f456SAndroid Build Coastguard Workerinline
2108*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::basic_string(
2109*58b9f456SAndroid Build Coastguard Worker    initializer_list<_CharT> __il)
2110*58b9f456SAndroid Build Coastguard Worker{
2111*58b9f456SAndroid Build Coastguard Worker    __init(__il.begin(), __il.end());
2112*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2113*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
2114*58b9f456SAndroid Build Coastguard Worker#endif
2115*58b9f456SAndroid Build Coastguard Worker}
2116*58b9f456SAndroid Build Coastguard Worker
2117*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2118*58b9f456SAndroid Build Coastguard Workerinline
2119*58b9f456SAndroid Build Coastguard Worker
2120*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::basic_string(
2121*58b9f456SAndroid Build Coastguard Worker    initializer_list<_CharT> __il, const _Allocator& __a)
2122*58b9f456SAndroid Build Coastguard Worker    : __r_(__second_tag(), __a)
2123*58b9f456SAndroid Build Coastguard Worker{
2124*58b9f456SAndroid Build Coastguard Worker    __init(__il.begin(), __il.end());
2125*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2126*58b9f456SAndroid Build Coastguard Worker    __get_db()->__insert_c(this);
2127*58b9f456SAndroid Build Coastguard Worker#endif
2128*58b9f456SAndroid Build Coastguard Worker}
2129*58b9f456SAndroid Build Coastguard Worker
2130*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
2131*58b9f456SAndroid Build Coastguard Worker
2132*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2133*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::~basic_string()
2134*58b9f456SAndroid Build Coastguard Worker{
2135*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2136*58b9f456SAndroid Build Coastguard Worker    __get_db()->__erase_c(this);
2137*58b9f456SAndroid Build Coastguard Worker#endif
2138*58b9f456SAndroid Build Coastguard Worker    if (__is_long())
2139*58b9f456SAndroid Build Coastguard Worker        __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap());
2140*58b9f456SAndroid Build Coastguard Worker}
2141*58b9f456SAndroid Build Coastguard Worker
2142*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2143*58b9f456SAndroid Build Coastguard Workervoid
2144*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace
2145*58b9f456SAndroid Build Coastguard Worker    (size_type __old_cap, size_type __delta_cap, size_type __old_sz,
2146*58b9f456SAndroid Build Coastguard Worker     size_type __n_copy,  size_type __n_del,     size_type __n_add, const value_type* __p_new_stuff)
2147*58b9f456SAndroid Build Coastguard Worker{
2148*58b9f456SAndroid Build Coastguard Worker    size_type __ms = max_size();
2149*58b9f456SAndroid Build Coastguard Worker    if (__delta_cap > __ms - __old_cap - 1)
2150*58b9f456SAndroid Build Coastguard Worker        this->__throw_length_error();
2151*58b9f456SAndroid Build Coastguard Worker    pointer __old_p = __get_pointer();
2152*58b9f456SAndroid Build Coastguard Worker    size_type __cap = __old_cap < __ms / 2 - __alignment ?
2153*58b9f456SAndroid Build Coastguard Worker                          __recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) :
2154*58b9f456SAndroid Build Coastguard Worker                          __ms - 1;
2155*58b9f456SAndroid Build Coastguard Worker    pointer __p = __alloc_traits::allocate(__alloc(), __cap+1);
2156*58b9f456SAndroid Build Coastguard Worker    __invalidate_all_iterators();
2157*58b9f456SAndroid Build Coastguard Worker    if (__n_copy != 0)
2158*58b9f456SAndroid Build Coastguard Worker        traits_type::copy(_VSTD::__to_raw_pointer(__p),
2159*58b9f456SAndroid Build Coastguard Worker                          _VSTD::__to_raw_pointer(__old_p), __n_copy);
2160*58b9f456SAndroid Build Coastguard Worker    if (__n_add != 0)
2161*58b9f456SAndroid Build Coastguard Worker        traits_type::copy(_VSTD::__to_raw_pointer(__p) + __n_copy, __p_new_stuff, __n_add);
2162*58b9f456SAndroid Build Coastguard Worker    size_type __sec_cp_sz = __old_sz - __n_del - __n_copy;
2163*58b9f456SAndroid Build Coastguard Worker    if (__sec_cp_sz != 0)
2164*58b9f456SAndroid Build Coastguard Worker        traits_type::copy(_VSTD::__to_raw_pointer(__p) + __n_copy + __n_add,
2165*58b9f456SAndroid Build Coastguard Worker                          _VSTD::__to_raw_pointer(__old_p) + __n_copy + __n_del, __sec_cp_sz);
2166*58b9f456SAndroid Build Coastguard Worker    if (__old_cap+1 != __min_cap)
2167*58b9f456SAndroid Build Coastguard Worker        __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1);
2168*58b9f456SAndroid Build Coastguard Worker    __set_long_pointer(__p);
2169*58b9f456SAndroid Build Coastguard Worker    __set_long_cap(__cap+1);
2170*58b9f456SAndroid Build Coastguard Worker    __old_sz = __n_copy + __n_add + __sec_cp_sz;
2171*58b9f456SAndroid Build Coastguard Worker    __set_long_size(__old_sz);
2172*58b9f456SAndroid Build Coastguard Worker    traits_type::assign(__p[__old_sz], value_type());
2173*58b9f456SAndroid Build Coastguard Worker}
2174*58b9f456SAndroid Build Coastguard Worker
2175*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2176*58b9f456SAndroid Build Coastguard Workervoid
2177*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz,
2178*58b9f456SAndroid Build Coastguard Worker                                                     size_type __n_copy,  size_type __n_del,     size_type __n_add)
2179*58b9f456SAndroid Build Coastguard Worker{
2180*58b9f456SAndroid Build Coastguard Worker    size_type __ms = max_size();
2181*58b9f456SAndroid Build Coastguard Worker    if (__delta_cap > __ms - __old_cap)
2182*58b9f456SAndroid Build Coastguard Worker        this->__throw_length_error();
2183*58b9f456SAndroid Build Coastguard Worker    pointer __old_p = __get_pointer();
2184*58b9f456SAndroid Build Coastguard Worker    size_type __cap = __old_cap < __ms / 2 - __alignment ?
2185*58b9f456SAndroid Build Coastguard Worker                          __recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) :
2186*58b9f456SAndroid Build Coastguard Worker                          __ms - 1;
2187*58b9f456SAndroid Build Coastguard Worker    pointer __p = __alloc_traits::allocate(__alloc(), __cap+1);
2188*58b9f456SAndroid Build Coastguard Worker    __invalidate_all_iterators();
2189*58b9f456SAndroid Build Coastguard Worker    if (__n_copy != 0)
2190*58b9f456SAndroid Build Coastguard Worker        traits_type::copy(_VSTD::__to_raw_pointer(__p),
2191*58b9f456SAndroid Build Coastguard Worker                          _VSTD::__to_raw_pointer(__old_p), __n_copy);
2192*58b9f456SAndroid Build Coastguard Worker    size_type __sec_cp_sz = __old_sz - __n_del - __n_copy;
2193*58b9f456SAndroid Build Coastguard Worker    if (__sec_cp_sz != 0)
2194*58b9f456SAndroid Build Coastguard Worker        traits_type::copy(_VSTD::__to_raw_pointer(__p) + __n_copy + __n_add,
2195*58b9f456SAndroid Build Coastguard Worker                          _VSTD::__to_raw_pointer(__old_p) + __n_copy + __n_del,
2196*58b9f456SAndroid Build Coastguard Worker                          __sec_cp_sz);
2197*58b9f456SAndroid Build Coastguard Worker    if (__old_cap+1 != __min_cap)
2198*58b9f456SAndroid Build Coastguard Worker        __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1);
2199*58b9f456SAndroid Build Coastguard Worker    __set_long_pointer(__p);
2200*58b9f456SAndroid Build Coastguard Worker    __set_long_cap(__cap+1);
2201*58b9f456SAndroid Build Coastguard Worker}
2202*58b9f456SAndroid Build Coastguard Worker
2203*58b9f456SAndroid Build Coastguard Worker// assign
2204*58b9f456SAndroid Build Coastguard Worker
2205*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2206*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2207*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n)
2208*58b9f456SAndroid Build Coastguard Worker{
2209*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::assign received nullptr");
2210*58b9f456SAndroid Build Coastguard Worker    size_type __cap = capacity();
2211*58b9f456SAndroid Build Coastguard Worker    if (__cap >= __n)
2212*58b9f456SAndroid Build Coastguard Worker    {
2213*58b9f456SAndroid Build Coastguard Worker        value_type* __p = _VSTD::__to_raw_pointer(__get_pointer());
2214*58b9f456SAndroid Build Coastguard Worker        traits_type::move(__p, __s, __n);
2215*58b9f456SAndroid Build Coastguard Worker        traits_type::assign(__p[__n], value_type());
2216*58b9f456SAndroid Build Coastguard Worker        __set_size(__n);
2217*58b9f456SAndroid Build Coastguard Worker        __invalidate_iterators_past(__n);
2218*58b9f456SAndroid Build Coastguard Worker    }
2219*58b9f456SAndroid Build Coastguard Worker    else
2220*58b9f456SAndroid Build Coastguard Worker    {
2221*58b9f456SAndroid Build Coastguard Worker        size_type __sz = size();
2222*58b9f456SAndroid Build Coastguard Worker        __grow_by_and_replace(__cap, __n - __cap, __sz, 0, __sz, __n, __s);
2223*58b9f456SAndroid Build Coastguard Worker    }
2224*58b9f456SAndroid Build Coastguard Worker    return *this;
2225*58b9f456SAndroid Build Coastguard Worker}
2226*58b9f456SAndroid Build Coastguard Worker
2227*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2228*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2229*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c)
2230*58b9f456SAndroid Build Coastguard Worker{
2231*58b9f456SAndroid Build Coastguard Worker    size_type __cap = capacity();
2232*58b9f456SAndroid Build Coastguard Worker    if (__cap < __n)
2233*58b9f456SAndroid Build Coastguard Worker    {
2234*58b9f456SAndroid Build Coastguard Worker        size_type __sz = size();
2235*58b9f456SAndroid Build Coastguard Worker        __grow_by(__cap, __n - __cap, __sz, 0, __sz);
2236*58b9f456SAndroid Build Coastguard Worker    }
2237*58b9f456SAndroid Build Coastguard Worker    else
2238*58b9f456SAndroid Build Coastguard Worker        __invalidate_iterators_past(__n);
2239*58b9f456SAndroid Build Coastguard Worker    value_type* __p = _VSTD::__to_raw_pointer(__get_pointer());
2240*58b9f456SAndroid Build Coastguard Worker    traits_type::assign(__p, __n, __c);
2241*58b9f456SAndroid Build Coastguard Worker    traits_type::assign(__p[__n], value_type());
2242*58b9f456SAndroid Build Coastguard Worker    __set_size(__n);
2243*58b9f456SAndroid Build Coastguard Worker    return *this;
2244*58b9f456SAndroid Build Coastguard Worker}
2245*58b9f456SAndroid Build Coastguard Worker
2246*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2247*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2248*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c)
2249*58b9f456SAndroid Build Coastguard Worker{
2250*58b9f456SAndroid Build Coastguard Worker    pointer __p;
2251*58b9f456SAndroid Build Coastguard Worker    if (__is_long())
2252*58b9f456SAndroid Build Coastguard Worker    {
2253*58b9f456SAndroid Build Coastguard Worker        __p = __get_long_pointer();
2254*58b9f456SAndroid Build Coastguard Worker        __set_long_size(1);
2255*58b9f456SAndroid Build Coastguard Worker    }
2256*58b9f456SAndroid Build Coastguard Worker    else
2257*58b9f456SAndroid Build Coastguard Worker    {
2258*58b9f456SAndroid Build Coastguard Worker        __p = __get_short_pointer();
2259*58b9f456SAndroid Build Coastguard Worker        __set_short_size(1);
2260*58b9f456SAndroid Build Coastguard Worker    }
2261*58b9f456SAndroid Build Coastguard Worker    traits_type::assign(*__p, __c);
2262*58b9f456SAndroid Build Coastguard Worker    traits_type::assign(*++__p, value_type());
2263*58b9f456SAndroid Build Coastguard Worker    __invalidate_iterators_past(1);
2264*58b9f456SAndroid Build Coastguard Worker    return *this;
2265*58b9f456SAndroid Build Coastguard Worker}
2266*58b9f456SAndroid Build Coastguard Worker
2267*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2268*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2269*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)
2270*58b9f456SAndroid Build Coastguard Worker{
2271*58b9f456SAndroid Build Coastguard Worker    if (this != &__str)
2272*58b9f456SAndroid Build Coastguard Worker    {
2273*58b9f456SAndroid Build Coastguard Worker        __copy_assign_alloc(__str);
2274*58b9f456SAndroid Build Coastguard Worker        assign(__str.data(), __str.size());
2275*58b9f456SAndroid Build Coastguard Worker    }
2276*58b9f456SAndroid Build Coastguard Worker    return *this;
2277*58b9f456SAndroid Build Coastguard Worker}
2278*58b9f456SAndroid Build Coastguard Worker
2279*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
2280*58b9f456SAndroid Build Coastguard Worker
2281*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2282*58b9f456SAndroid Build Coastguard Workerinline
2283*58b9f456SAndroid Build Coastguard Workervoid
2284*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type)
2285*58b9f456SAndroid Build Coastguard Worker    _NOEXCEPT_(__alloc_traits::is_always_equal::value)
2286*58b9f456SAndroid Build Coastguard Worker{
2287*58b9f456SAndroid Build Coastguard Worker    if (__alloc() != __str.__alloc())
2288*58b9f456SAndroid Build Coastguard Worker        assign(__str);
2289*58b9f456SAndroid Build Coastguard Worker    else
2290*58b9f456SAndroid Build Coastguard Worker        __move_assign(__str, true_type());
2291*58b9f456SAndroid Build Coastguard Worker}
2292*58b9f456SAndroid Build Coastguard Worker
2293*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2294*58b9f456SAndroid Build Coastguard Workerinline
2295*58b9f456SAndroid Build Coastguard Workervoid
2296*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type)
2297*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14
2298*58b9f456SAndroid Build Coastguard Worker    _NOEXCEPT
2299*58b9f456SAndroid Build Coastguard Worker#else
2300*58b9f456SAndroid Build Coastguard Worker    _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
2301*58b9f456SAndroid Build Coastguard Worker#endif
2302*58b9f456SAndroid Build Coastguard Worker{
2303*58b9f456SAndroid Build Coastguard Worker    __clear_and_shrink();
2304*58b9f456SAndroid Build Coastguard Worker    __r_.first() = __str.__r_.first();
2305*58b9f456SAndroid Build Coastguard Worker    __move_assign_alloc(__str);
2306*58b9f456SAndroid Build Coastguard Worker    __str.__zero();
2307*58b9f456SAndroid Build Coastguard Worker}
2308*58b9f456SAndroid Build Coastguard Worker
2309*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2310*58b9f456SAndroid Build Coastguard Workerinline
2311*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2312*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str)
2313*58b9f456SAndroid Build Coastguard Worker    _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
2314*58b9f456SAndroid Build Coastguard Worker{
2315*58b9f456SAndroid Build Coastguard Worker    __move_assign(__str, integral_constant<bool,
2316*58b9f456SAndroid Build Coastguard Worker          __alloc_traits::propagate_on_container_move_assignment::value>());
2317*58b9f456SAndroid Build Coastguard Worker    return *this;
2318*58b9f456SAndroid Build Coastguard Worker}
2319*58b9f456SAndroid Build Coastguard Worker
2320*58b9f456SAndroid Build Coastguard Worker#endif
2321*58b9f456SAndroid Build Coastguard Worker
2322*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2323*58b9f456SAndroid Build Coastguard Workertemplate<class _InputIterator>
2324*58b9f456SAndroid Build Coastguard Workertypename enable_if
2325*58b9f456SAndroid Build Coastguard Worker<
2326*58b9f456SAndroid Build Coastguard Worker     __is_exactly_input_iterator <_InputIterator>::value
2327*58b9f456SAndroid Build Coastguard Worker          || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
2328*58b9f456SAndroid Build Coastguard Worker    basic_string<_CharT, _Traits, _Allocator>&
2329*58b9f456SAndroid Build Coastguard Worker>::type
2330*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
2331*58b9f456SAndroid Build Coastguard Worker{
2332*58b9f456SAndroid Build Coastguard Worker    const basic_string __temp(__first, __last, __alloc());
2333*58b9f456SAndroid Build Coastguard Worker    assign(__temp.data(), __temp.size());
2334*58b9f456SAndroid Build Coastguard Worker    return *this;
2335*58b9f456SAndroid Build Coastguard Worker}
2336*58b9f456SAndroid Build Coastguard Worker
2337*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2338*58b9f456SAndroid Build Coastguard Workertemplate<class _ForwardIterator>
2339*58b9f456SAndroid Build Coastguard Workertypename enable_if
2340*58b9f456SAndroid Build Coastguard Worker<
2341*58b9f456SAndroid Build Coastguard Worker    __is_forward_iterator<_ForwardIterator>::value
2342*58b9f456SAndroid Build Coastguard Worker         && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,
2343*58b9f456SAndroid Build Coastguard Worker    basic_string<_CharT, _Traits, _Allocator>&
2344*58b9f456SAndroid Build Coastguard Worker>::type
2345*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)
2346*58b9f456SAndroid Build Coastguard Worker{
2347*58b9f456SAndroid Build Coastguard Worker    size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
2348*58b9f456SAndroid Build Coastguard Worker    size_type __cap = capacity();
2349*58b9f456SAndroid Build Coastguard Worker    if (__cap < __n)
2350*58b9f456SAndroid Build Coastguard Worker    {
2351*58b9f456SAndroid Build Coastguard Worker        size_type __sz = size();
2352*58b9f456SAndroid Build Coastguard Worker        __grow_by(__cap, __n - __cap, __sz, 0, __sz);
2353*58b9f456SAndroid Build Coastguard Worker    }
2354*58b9f456SAndroid Build Coastguard Worker    else
2355*58b9f456SAndroid Build Coastguard Worker        __invalidate_iterators_past(__n);
2356*58b9f456SAndroid Build Coastguard Worker    pointer __p = __get_pointer();
2357*58b9f456SAndroid Build Coastguard Worker    for (; __first != __last; ++__first, ++__p)
2358*58b9f456SAndroid Build Coastguard Worker        traits_type::assign(*__p, *__first);
2359*58b9f456SAndroid Build Coastguard Worker    traits_type::assign(*__p, value_type());
2360*58b9f456SAndroid Build Coastguard Worker    __set_size(__n);
2361*58b9f456SAndroid Build Coastguard Worker    return *this;
2362*58b9f456SAndroid Build Coastguard Worker}
2363*58b9f456SAndroid Build Coastguard Worker
2364*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2365*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2366*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, size_type __pos, size_type __n)
2367*58b9f456SAndroid Build Coastguard Worker{
2368*58b9f456SAndroid Build Coastguard Worker    size_type __sz = __str.size();
2369*58b9f456SAndroid Build Coastguard Worker    if (__pos > __sz)
2370*58b9f456SAndroid Build Coastguard Worker        this->__throw_out_of_range();
2371*58b9f456SAndroid Build Coastguard Worker    return assign(__str.data() + __pos, _VSTD::min(__n, __sz - __pos));
2372*58b9f456SAndroid Build Coastguard Worker}
2373*58b9f456SAndroid Build Coastguard Worker
2374*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2375*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
2376*58b9f456SAndroid Build Coastguard Workertypename enable_if
2377*58b9f456SAndroid Build Coastguard Worker<
2378*58b9f456SAndroid Build Coastguard Worker    __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
2379*58b9f456SAndroid Build Coastguard Worker    basic_string<_CharT, _Traits, _Allocator>&
2380*58b9f456SAndroid Build Coastguard Worker>::type
2381*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::assign(const _Tp & __t, size_type __pos, size_type __n)
2382*58b9f456SAndroid Build Coastguard Worker{
2383*58b9f456SAndroid Build Coastguard Worker    __self_view __sv = __t;
2384*58b9f456SAndroid Build Coastguard Worker    size_type __sz = __sv.size();
2385*58b9f456SAndroid Build Coastguard Worker    if (__pos > __sz)
2386*58b9f456SAndroid Build Coastguard Worker        this->__throw_out_of_range();
2387*58b9f456SAndroid Build Coastguard Worker    return assign(__sv.data() + __pos, _VSTD::min(__n, __sz - __pos));
2388*58b9f456SAndroid Build Coastguard Worker}
2389*58b9f456SAndroid Build Coastguard Worker
2390*58b9f456SAndroid Build Coastguard Worker
2391*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2392*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2393*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s)
2394*58b9f456SAndroid Build Coastguard Worker{
2395*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__s != nullptr, "string::assign received nullptr");
2396*58b9f456SAndroid Build Coastguard Worker    return assign(__s, traits_type::length(__s));
2397*58b9f456SAndroid Build Coastguard Worker}
2398*58b9f456SAndroid Build Coastguard Worker
2399*58b9f456SAndroid Build Coastguard Worker// append
2400*58b9f456SAndroid Build Coastguard Worker
2401*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2402*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2403*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n)
2404*58b9f456SAndroid Build Coastguard Worker{
2405*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::append received nullptr");
2406*58b9f456SAndroid Build Coastguard Worker    size_type __cap = capacity();
2407*58b9f456SAndroid Build Coastguard Worker    size_type __sz = size();
2408*58b9f456SAndroid Build Coastguard Worker    if (__cap - __sz >= __n)
2409*58b9f456SAndroid Build Coastguard Worker    {
2410*58b9f456SAndroid Build Coastguard Worker        if (__n)
2411*58b9f456SAndroid Build Coastguard Worker        {
2412*58b9f456SAndroid Build Coastguard Worker            value_type* __p = _VSTD::__to_raw_pointer(__get_pointer());
2413*58b9f456SAndroid Build Coastguard Worker            traits_type::copy(__p + __sz, __s, __n);
2414*58b9f456SAndroid Build Coastguard Worker            __sz += __n;
2415*58b9f456SAndroid Build Coastguard Worker            __set_size(__sz);
2416*58b9f456SAndroid Build Coastguard Worker            traits_type::assign(__p[__sz], value_type());
2417*58b9f456SAndroid Build Coastguard Worker        }
2418*58b9f456SAndroid Build Coastguard Worker    }
2419*58b9f456SAndroid Build Coastguard Worker    else
2420*58b9f456SAndroid Build Coastguard Worker        __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __sz, 0, __n, __s);
2421*58b9f456SAndroid Build Coastguard Worker    return *this;
2422*58b9f456SAndroid Build Coastguard Worker}
2423*58b9f456SAndroid Build Coastguard Worker
2424*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2425*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2426*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c)
2427*58b9f456SAndroid Build Coastguard Worker{
2428*58b9f456SAndroid Build Coastguard Worker    if (__n)
2429*58b9f456SAndroid Build Coastguard Worker    {
2430*58b9f456SAndroid Build Coastguard Worker        size_type __cap = capacity();
2431*58b9f456SAndroid Build Coastguard Worker        size_type __sz = size();
2432*58b9f456SAndroid Build Coastguard Worker        if (__cap - __sz < __n)
2433*58b9f456SAndroid Build Coastguard Worker            __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0);
2434*58b9f456SAndroid Build Coastguard Worker        pointer __p = __get_pointer();
2435*58b9f456SAndroid Build Coastguard Worker        traits_type::assign(_VSTD::__to_raw_pointer(__p) + __sz, __n, __c);
2436*58b9f456SAndroid Build Coastguard Worker        __sz += __n;
2437*58b9f456SAndroid Build Coastguard Worker        __set_size(__sz);
2438*58b9f456SAndroid Build Coastguard Worker        traits_type::assign(__p[__sz], value_type());
2439*58b9f456SAndroid Build Coastguard Worker    }
2440*58b9f456SAndroid Build Coastguard Worker    return *this;
2441*58b9f456SAndroid Build Coastguard Worker}
2442*58b9f456SAndroid Build Coastguard Worker
2443*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2444*58b9f456SAndroid Build Coastguard Workerinline void
2445*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n)
2446*58b9f456SAndroid Build Coastguard Worker{
2447*58b9f456SAndroid Build Coastguard Worker    if (__n)
2448*58b9f456SAndroid Build Coastguard Worker    {
2449*58b9f456SAndroid Build Coastguard Worker        size_type __cap = capacity();
2450*58b9f456SAndroid Build Coastguard Worker        size_type __sz = size();
2451*58b9f456SAndroid Build Coastguard Worker        if (__cap - __sz < __n)
2452*58b9f456SAndroid Build Coastguard Worker            __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0);
2453*58b9f456SAndroid Build Coastguard Worker        pointer __p = __get_pointer();
2454*58b9f456SAndroid Build Coastguard Worker        __sz += __n;
2455*58b9f456SAndroid Build Coastguard Worker        __set_size(__sz);
2456*58b9f456SAndroid Build Coastguard Worker        traits_type::assign(__p[__sz], value_type());
2457*58b9f456SAndroid Build Coastguard Worker    }
2458*58b9f456SAndroid Build Coastguard Worker}
2459*58b9f456SAndroid Build Coastguard Worker
2460*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2461*58b9f456SAndroid Build Coastguard Workervoid
2462*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c)
2463*58b9f456SAndroid Build Coastguard Worker{
2464*58b9f456SAndroid Build Coastguard Worker    bool __is_short = !__is_long();
2465*58b9f456SAndroid Build Coastguard Worker    size_type __cap;
2466*58b9f456SAndroid Build Coastguard Worker    size_type __sz;
2467*58b9f456SAndroid Build Coastguard Worker    if (__is_short)
2468*58b9f456SAndroid Build Coastguard Worker    {
2469*58b9f456SAndroid Build Coastguard Worker        __cap = __min_cap - 1;
2470*58b9f456SAndroid Build Coastguard Worker        __sz = __get_short_size();
2471*58b9f456SAndroid Build Coastguard Worker    }
2472*58b9f456SAndroid Build Coastguard Worker    else
2473*58b9f456SAndroid Build Coastguard Worker    {
2474*58b9f456SAndroid Build Coastguard Worker        __cap = __get_long_cap() - 1;
2475*58b9f456SAndroid Build Coastguard Worker        __sz = __get_long_size();
2476*58b9f456SAndroid Build Coastguard Worker    }
2477*58b9f456SAndroid Build Coastguard Worker    if (__sz == __cap)
2478*58b9f456SAndroid Build Coastguard Worker    {
2479*58b9f456SAndroid Build Coastguard Worker        __grow_by(__cap, 1, __sz, __sz, 0);
2480*58b9f456SAndroid Build Coastguard Worker        __is_short = !__is_long();
2481*58b9f456SAndroid Build Coastguard Worker    }
2482*58b9f456SAndroid Build Coastguard Worker    pointer __p;
2483*58b9f456SAndroid Build Coastguard Worker    if (__is_short)
2484*58b9f456SAndroid Build Coastguard Worker    {
2485*58b9f456SAndroid Build Coastguard Worker        __p = __get_short_pointer() + __sz;
2486*58b9f456SAndroid Build Coastguard Worker        __set_short_size(__sz+1);
2487*58b9f456SAndroid Build Coastguard Worker    }
2488*58b9f456SAndroid Build Coastguard Worker    else
2489*58b9f456SAndroid Build Coastguard Worker    {
2490*58b9f456SAndroid Build Coastguard Worker        __p = __get_long_pointer() + __sz;
2491*58b9f456SAndroid Build Coastguard Worker        __set_long_size(__sz+1);
2492*58b9f456SAndroid Build Coastguard Worker    }
2493*58b9f456SAndroid Build Coastguard Worker    traits_type::assign(*__p, __c);
2494*58b9f456SAndroid Build Coastguard Worker    traits_type::assign(*++__p, value_type());
2495*58b9f456SAndroid Build Coastguard Worker}
2496*58b9f456SAndroid Build Coastguard Worker
2497*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
2498*58b9f456SAndroid Build Coastguard Workerbool __ptr_in_range (const _Tp* __p, const _Tp* __first, const _Tp* __last)
2499*58b9f456SAndroid Build Coastguard Worker{
2500*58b9f456SAndroid Build Coastguard Worker    return __first <= __p && __p < __last;
2501*58b9f456SAndroid Build Coastguard Worker}
2502*58b9f456SAndroid Build Coastguard Worker
2503*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp1, class _Tp2>
2504*58b9f456SAndroid Build Coastguard Workerbool __ptr_in_range (const _Tp1*, const _Tp2*, const _Tp2*)
2505*58b9f456SAndroid Build Coastguard Worker{
2506*58b9f456SAndroid Build Coastguard Worker    return false;
2507*58b9f456SAndroid Build Coastguard Worker}
2508*58b9f456SAndroid Build Coastguard Worker
2509*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2510*58b9f456SAndroid Build Coastguard Workertemplate<class _ForwardIterator>
2511*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2512*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::__append_forward_unsafe(
2513*58b9f456SAndroid Build Coastguard Worker    _ForwardIterator __first, _ForwardIterator __last)
2514*58b9f456SAndroid Build Coastguard Worker{
2515*58b9f456SAndroid Build Coastguard Worker    static_assert(__is_forward_iterator<_ForwardIterator>::value,
2516*58b9f456SAndroid Build Coastguard Worker                  "function requires a ForwardIterator");
2517*58b9f456SAndroid Build Coastguard Worker    size_type __sz = size();
2518*58b9f456SAndroid Build Coastguard Worker    size_type __cap = capacity();
2519*58b9f456SAndroid Build Coastguard Worker    size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
2520*58b9f456SAndroid Build Coastguard Worker    if (__n)
2521*58b9f456SAndroid Build Coastguard Worker    {
2522*58b9f456SAndroid Build Coastguard Worker        typedef typename iterator_traits<_ForwardIterator>::reference _CharRef;
2523*58b9f456SAndroid Build Coastguard Worker        _CharRef __tmp_ref = *__first;
2524*58b9f456SAndroid Build Coastguard Worker        if (__ptr_in_range(_VSTD::addressof(__tmp_ref), data(), data() + size()))
2525*58b9f456SAndroid Build Coastguard Worker        {
2526*58b9f456SAndroid Build Coastguard Worker            const basic_string __temp (__first, __last, __alloc());
2527*58b9f456SAndroid Build Coastguard Worker            append(__temp.data(), __temp.size());
2528*58b9f456SAndroid Build Coastguard Worker        }
2529*58b9f456SAndroid Build Coastguard Worker        else
2530*58b9f456SAndroid Build Coastguard Worker        {
2531*58b9f456SAndroid Build Coastguard Worker            if (__cap - __sz < __n)
2532*58b9f456SAndroid Build Coastguard Worker                __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0);
2533*58b9f456SAndroid Build Coastguard Worker            pointer __p = __get_pointer() + __sz;
2534*58b9f456SAndroid Build Coastguard Worker            for (; __first != __last; ++__p, ++__first)
2535*58b9f456SAndroid Build Coastguard Worker                traits_type::assign(*__p, *__first);
2536*58b9f456SAndroid Build Coastguard Worker            traits_type::assign(*__p, value_type());
2537*58b9f456SAndroid Build Coastguard Worker            __set_size(__sz + __n);
2538*58b9f456SAndroid Build Coastguard Worker        }
2539*58b9f456SAndroid Build Coastguard Worker    }
2540*58b9f456SAndroid Build Coastguard Worker    return *this;
2541*58b9f456SAndroid Build Coastguard Worker}
2542*58b9f456SAndroid Build Coastguard Worker
2543*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2544*58b9f456SAndroid Build Coastguard Workerinline
2545*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2546*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str)
2547*58b9f456SAndroid Build Coastguard Worker{
2548*58b9f456SAndroid Build Coastguard Worker    return append(__str.data(), __str.size());
2549*58b9f456SAndroid Build Coastguard Worker}
2550*58b9f456SAndroid Build Coastguard Worker
2551*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2552*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2553*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, size_type __pos, size_type __n)
2554*58b9f456SAndroid Build Coastguard Worker{
2555*58b9f456SAndroid Build Coastguard Worker    size_type __sz = __str.size();
2556*58b9f456SAndroid Build Coastguard Worker    if (__pos > __sz)
2557*58b9f456SAndroid Build Coastguard Worker        this->__throw_out_of_range();
2558*58b9f456SAndroid Build Coastguard Worker    return append(__str.data() + __pos, _VSTD::min(__n, __sz - __pos));
2559*58b9f456SAndroid Build Coastguard Worker}
2560*58b9f456SAndroid Build Coastguard Worker
2561*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2562*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
2563*58b9f456SAndroid Build Coastguard Worker    typename enable_if
2564*58b9f456SAndroid Build Coastguard Worker    <
2565*58b9f456SAndroid Build Coastguard Worker        __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
2566*58b9f456SAndroid Build Coastguard Worker        basic_string<_CharT, _Traits, _Allocator>&
2567*58b9f456SAndroid Build Coastguard Worker    >::type
2568*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::append(const _Tp & __t, size_type __pos, size_type __n)
2569*58b9f456SAndroid Build Coastguard Worker{
2570*58b9f456SAndroid Build Coastguard Worker    __self_view __sv = __t;
2571*58b9f456SAndroid Build Coastguard Worker    size_type __sz = __sv.size();
2572*58b9f456SAndroid Build Coastguard Worker    if (__pos > __sz)
2573*58b9f456SAndroid Build Coastguard Worker        this->__throw_out_of_range();
2574*58b9f456SAndroid Build Coastguard Worker    return append(__sv.data() + __pos, _VSTD::min(__n, __sz - __pos));
2575*58b9f456SAndroid Build Coastguard Worker}
2576*58b9f456SAndroid Build Coastguard Worker
2577*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2578*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2579*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s)
2580*58b9f456SAndroid Build Coastguard Worker{
2581*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__s != nullptr, "string::append received nullptr");
2582*58b9f456SAndroid Build Coastguard Worker    return append(__s, traits_type::length(__s));
2583*58b9f456SAndroid Build Coastguard Worker}
2584*58b9f456SAndroid Build Coastguard Worker
2585*58b9f456SAndroid Build Coastguard Worker// insert
2586*58b9f456SAndroid Build Coastguard Worker
2587*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2588*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2589*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n)
2590*58b9f456SAndroid Build Coastguard Worker{
2591*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::insert received nullptr");
2592*58b9f456SAndroid Build Coastguard Worker    size_type __sz = size();
2593*58b9f456SAndroid Build Coastguard Worker    if (__pos > __sz)
2594*58b9f456SAndroid Build Coastguard Worker        this->__throw_out_of_range();
2595*58b9f456SAndroid Build Coastguard Worker    size_type __cap = capacity();
2596*58b9f456SAndroid Build Coastguard Worker    if (__cap - __sz >= __n)
2597*58b9f456SAndroid Build Coastguard Worker    {
2598*58b9f456SAndroid Build Coastguard Worker        if (__n)
2599*58b9f456SAndroid Build Coastguard Worker        {
2600*58b9f456SAndroid Build Coastguard Worker            value_type* __p = _VSTD::__to_raw_pointer(__get_pointer());
2601*58b9f456SAndroid Build Coastguard Worker            size_type __n_move = __sz - __pos;
2602*58b9f456SAndroid Build Coastguard Worker            if (__n_move != 0)
2603*58b9f456SAndroid Build Coastguard Worker            {
2604*58b9f456SAndroid Build Coastguard Worker                if (__p + __pos <= __s && __s < __p + __sz)
2605*58b9f456SAndroid Build Coastguard Worker                    __s += __n;
2606*58b9f456SAndroid Build Coastguard Worker                traits_type::move(__p + __pos + __n, __p + __pos, __n_move);
2607*58b9f456SAndroid Build Coastguard Worker            }
2608*58b9f456SAndroid Build Coastguard Worker            traits_type::move(__p + __pos, __s, __n);
2609*58b9f456SAndroid Build Coastguard Worker            __sz += __n;
2610*58b9f456SAndroid Build Coastguard Worker            __set_size(__sz);
2611*58b9f456SAndroid Build Coastguard Worker            traits_type::assign(__p[__sz], value_type());
2612*58b9f456SAndroid Build Coastguard Worker        }
2613*58b9f456SAndroid Build Coastguard Worker    }
2614*58b9f456SAndroid Build Coastguard Worker    else
2615*58b9f456SAndroid Build Coastguard Worker        __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __pos, 0, __n, __s);
2616*58b9f456SAndroid Build Coastguard Worker    return *this;
2617*58b9f456SAndroid Build Coastguard Worker}
2618*58b9f456SAndroid Build Coastguard Worker
2619*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2620*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2621*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n, value_type __c)
2622*58b9f456SAndroid Build Coastguard Worker{
2623*58b9f456SAndroid Build Coastguard Worker    size_type __sz = size();
2624*58b9f456SAndroid Build Coastguard Worker    if (__pos > __sz)
2625*58b9f456SAndroid Build Coastguard Worker        this->__throw_out_of_range();
2626*58b9f456SAndroid Build Coastguard Worker    if (__n)
2627*58b9f456SAndroid Build Coastguard Worker    {
2628*58b9f456SAndroid Build Coastguard Worker        size_type __cap = capacity();
2629*58b9f456SAndroid Build Coastguard Worker        value_type* __p;
2630*58b9f456SAndroid Build Coastguard Worker        if (__cap - __sz >= __n)
2631*58b9f456SAndroid Build Coastguard Worker        {
2632*58b9f456SAndroid Build Coastguard Worker            __p = _VSTD::__to_raw_pointer(__get_pointer());
2633*58b9f456SAndroid Build Coastguard Worker            size_type __n_move = __sz - __pos;
2634*58b9f456SAndroid Build Coastguard Worker            if (__n_move != 0)
2635*58b9f456SAndroid Build Coastguard Worker                traits_type::move(__p + __pos + __n, __p + __pos, __n_move);
2636*58b9f456SAndroid Build Coastguard Worker        }
2637*58b9f456SAndroid Build Coastguard Worker        else
2638*58b9f456SAndroid Build Coastguard Worker        {
2639*58b9f456SAndroid Build Coastguard Worker            __grow_by(__cap, __sz + __n - __cap, __sz, __pos, 0, __n);
2640*58b9f456SAndroid Build Coastguard Worker            __p = _VSTD::__to_raw_pointer(__get_long_pointer());
2641*58b9f456SAndroid Build Coastguard Worker        }
2642*58b9f456SAndroid Build Coastguard Worker        traits_type::assign(__p + __pos, __n, __c);
2643*58b9f456SAndroid Build Coastguard Worker        __sz += __n;
2644*58b9f456SAndroid Build Coastguard Worker        __set_size(__sz);
2645*58b9f456SAndroid Build Coastguard Worker        traits_type::assign(__p[__sz], value_type());
2646*58b9f456SAndroid Build Coastguard Worker    }
2647*58b9f456SAndroid Build Coastguard Worker    return *this;
2648*58b9f456SAndroid Build Coastguard Worker}
2649*58b9f456SAndroid Build Coastguard Worker
2650*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2651*58b9f456SAndroid Build Coastguard Workertemplate<class _InputIterator>
2652*58b9f456SAndroid Build Coastguard Workertypename enable_if
2653*58b9f456SAndroid Build Coastguard Worker<
2654*58b9f456SAndroid Build Coastguard Worker   __is_exactly_input_iterator<_InputIterator>::value
2655*58b9f456SAndroid Build Coastguard Worker        || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
2656*58b9f456SAndroid Build Coastguard Worker   typename basic_string<_CharT, _Traits, _Allocator>::iterator
2657*58b9f456SAndroid Build Coastguard Worker>::type
2658*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last)
2659*58b9f456SAndroid Build Coastguard Worker{
2660*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2661*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
2662*58b9f456SAndroid Build Coastguard Worker        "string::insert(iterator, range) called with an iterator not"
2663*58b9f456SAndroid Build Coastguard Worker        " referring to this string");
2664*58b9f456SAndroid Build Coastguard Worker#endif
2665*58b9f456SAndroid Build Coastguard Worker    const basic_string __temp(__first, __last, __alloc());
2666*58b9f456SAndroid Build Coastguard Worker    return insert(__pos, __temp.data(), __temp.data() + __temp.size());
2667*58b9f456SAndroid Build Coastguard Worker}
2668*58b9f456SAndroid Build Coastguard Worker
2669*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2670*58b9f456SAndroid Build Coastguard Workertemplate<class _ForwardIterator>
2671*58b9f456SAndroid Build Coastguard Workertypename enable_if
2672*58b9f456SAndroid Build Coastguard Worker<
2673*58b9f456SAndroid Build Coastguard Worker    __is_forward_iterator<_ForwardIterator>::value
2674*58b9f456SAndroid Build Coastguard Worker        && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,
2675*58b9f456SAndroid Build Coastguard Worker    typename basic_string<_CharT, _Traits, _Allocator>::iterator
2676*58b9f456SAndroid Build Coastguard Worker>::type
2677*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last)
2678*58b9f456SAndroid Build Coastguard Worker{
2679*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2680*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
2681*58b9f456SAndroid Build Coastguard Worker        "string::insert(iterator, range) called with an iterator not"
2682*58b9f456SAndroid Build Coastguard Worker        " referring to this string");
2683*58b9f456SAndroid Build Coastguard Worker#endif
2684*58b9f456SAndroid Build Coastguard Worker    size_type __ip = static_cast<size_type>(__pos - begin());
2685*58b9f456SAndroid Build Coastguard Worker    size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
2686*58b9f456SAndroid Build Coastguard Worker    if (__n)
2687*58b9f456SAndroid Build Coastguard Worker    {
2688*58b9f456SAndroid Build Coastguard Worker        typedef typename iterator_traits<_ForwardIterator>::reference _CharRef;
2689*58b9f456SAndroid Build Coastguard Worker        _CharRef __tmp_char = *__first;
2690*58b9f456SAndroid Build Coastguard Worker        if (__ptr_in_range(_VSTD::addressof(__tmp_char), data(), data() + size()))
2691*58b9f456SAndroid Build Coastguard Worker        {
2692*58b9f456SAndroid Build Coastguard Worker            const basic_string __temp(__first, __last, __alloc());
2693*58b9f456SAndroid Build Coastguard Worker            return insert(__pos, __temp.data(), __temp.data() + __temp.size());
2694*58b9f456SAndroid Build Coastguard Worker        }
2695*58b9f456SAndroid Build Coastguard Worker
2696*58b9f456SAndroid Build Coastguard Worker        size_type __sz = size();
2697*58b9f456SAndroid Build Coastguard Worker        size_type __cap = capacity();
2698*58b9f456SAndroid Build Coastguard Worker        value_type* __p;
2699*58b9f456SAndroid Build Coastguard Worker        if (__cap - __sz >= __n)
2700*58b9f456SAndroid Build Coastguard Worker        {
2701*58b9f456SAndroid Build Coastguard Worker            __p = _VSTD::__to_raw_pointer(__get_pointer());
2702*58b9f456SAndroid Build Coastguard Worker            size_type __n_move = __sz - __ip;
2703*58b9f456SAndroid Build Coastguard Worker            if (__n_move != 0)
2704*58b9f456SAndroid Build Coastguard Worker                traits_type::move(__p + __ip + __n, __p + __ip, __n_move);
2705*58b9f456SAndroid Build Coastguard Worker        }
2706*58b9f456SAndroid Build Coastguard Worker        else
2707*58b9f456SAndroid Build Coastguard Worker        {
2708*58b9f456SAndroid Build Coastguard Worker            __grow_by(__cap, __sz + __n - __cap, __sz, __ip, 0, __n);
2709*58b9f456SAndroid Build Coastguard Worker            __p = _VSTD::__to_raw_pointer(__get_long_pointer());
2710*58b9f456SAndroid Build Coastguard Worker        }
2711*58b9f456SAndroid Build Coastguard Worker        __sz += __n;
2712*58b9f456SAndroid Build Coastguard Worker        __set_size(__sz);
2713*58b9f456SAndroid Build Coastguard Worker        traits_type::assign(__p[__sz], value_type());
2714*58b9f456SAndroid Build Coastguard Worker        for (__p += __ip; __first != __last; ++__p, ++__first)
2715*58b9f456SAndroid Build Coastguard Worker            traits_type::assign(*__p, *__first);
2716*58b9f456SAndroid Build Coastguard Worker    }
2717*58b9f456SAndroid Build Coastguard Worker    return begin() + __ip;
2718*58b9f456SAndroid Build Coastguard Worker}
2719*58b9f456SAndroid Build Coastguard Worker
2720*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2721*58b9f456SAndroid Build Coastguard Workerinline
2722*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2723*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str)
2724*58b9f456SAndroid Build Coastguard Worker{
2725*58b9f456SAndroid Build Coastguard Worker    return insert(__pos1, __str.data(), __str.size());
2726*58b9f456SAndroid Build Coastguard Worker}
2727*58b9f456SAndroid Build Coastguard Worker
2728*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2729*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2730*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str,
2731*58b9f456SAndroid Build Coastguard Worker                                                  size_type __pos2, size_type __n)
2732*58b9f456SAndroid Build Coastguard Worker{
2733*58b9f456SAndroid Build Coastguard Worker    size_type __str_sz = __str.size();
2734*58b9f456SAndroid Build Coastguard Worker    if (__pos2 > __str_sz)
2735*58b9f456SAndroid Build Coastguard Worker        this->__throw_out_of_range();
2736*58b9f456SAndroid Build Coastguard Worker    return insert(__pos1, __str.data() + __pos2, _VSTD::min(__n, __str_sz - __pos2));
2737*58b9f456SAndroid Build Coastguard Worker}
2738*58b9f456SAndroid Build Coastguard Worker
2739*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2740*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
2741*58b9f456SAndroid Build Coastguard Workertypename enable_if
2742*58b9f456SAndroid Build Coastguard Worker<
2743*58b9f456SAndroid Build Coastguard Worker    __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
2744*58b9f456SAndroid Build Coastguard Worker    basic_string<_CharT, _Traits, _Allocator>&
2745*58b9f456SAndroid Build Coastguard Worker>::type
2746*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const _Tp& __t,
2747*58b9f456SAndroid Build Coastguard Worker                                                  size_type __pos2, size_type __n)
2748*58b9f456SAndroid Build Coastguard Worker{
2749*58b9f456SAndroid Build Coastguard Worker    __self_view __sv = __t;
2750*58b9f456SAndroid Build Coastguard Worker    size_type __str_sz = __sv.size();
2751*58b9f456SAndroid Build Coastguard Worker    if (__pos2 > __str_sz)
2752*58b9f456SAndroid Build Coastguard Worker        this->__throw_out_of_range();
2753*58b9f456SAndroid Build Coastguard Worker    return insert(__pos1, __sv.data() + __pos2, _VSTD::min(__n, __str_sz - __pos2));
2754*58b9f456SAndroid Build Coastguard Worker}
2755*58b9f456SAndroid Build Coastguard Worker
2756*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2757*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2758*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s)
2759*58b9f456SAndroid Build Coastguard Worker{
2760*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__s != nullptr, "string::insert received nullptr");
2761*58b9f456SAndroid Build Coastguard Worker    return insert(__pos, __s, traits_type::length(__s));
2762*58b9f456SAndroid Build Coastguard Worker}
2763*58b9f456SAndroid Build Coastguard Worker
2764*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2765*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::iterator
2766*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_type __c)
2767*58b9f456SAndroid Build Coastguard Worker{
2768*58b9f456SAndroid Build Coastguard Worker    size_type __ip = static_cast<size_type>(__pos - begin());
2769*58b9f456SAndroid Build Coastguard Worker    size_type __sz = size();
2770*58b9f456SAndroid Build Coastguard Worker    size_type __cap = capacity();
2771*58b9f456SAndroid Build Coastguard Worker    value_type* __p;
2772*58b9f456SAndroid Build Coastguard Worker    if (__cap == __sz)
2773*58b9f456SAndroid Build Coastguard Worker    {
2774*58b9f456SAndroid Build Coastguard Worker        __grow_by(__cap, 1, __sz, __ip, 0, 1);
2775*58b9f456SAndroid Build Coastguard Worker        __p = _VSTD::__to_raw_pointer(__get_long_pointer());
2776*58b9f456SAndroid Build Coastguard Worker    }
2777*58b9f456SAndroid Build Coastguard Worker    else
2778*58b9f456SAndroid Build Coastguard Worker    {
2779*58b9f456SAndroid Build Coastguard Worker        __p = _VSTD::__to_raw_pointer(__get_pointer());
2780*58b9f456SAndroid Build Coastguard Worker        size_type __n_move = __sz - __ip;
2781*58b9f456SAndroid Build Coastguard Worker        if (__n_move != 0)
2782*58b9f456SAndroid Build Coastguard Worker            traits_type::move(__p + __ip + 1, __p + __ip, __n_move);
2783*58b9f456SAndroid Build Coastguard Worker    }
2784*58b9f456SAndroid Build Coastguard Worker    traits_type::assign(__p[__ip], __c);
2785*58b9f456SAndroid Build Coastguard Worker    traits_type::assign(__p[++__sz], value_type());
2786*58b9f456SAndroid Build Coastguard Worker    __set_size(__sz);
2787*58b9f456SAndroid Build Coastguard Worker    return begin() + static_cast<difference_type>(__ip);
2788*58b9f456SAndroid Build Coastguard Worker}
2789*58b9f456SAndroid Build Coastguard Worker
2790*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2791*58b9f456SAndroid Build Coastguard Workerinline
2792*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::iterator
2793*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_type __n, value_type __c)
2794*58b9f456SAndroid Build Coastguard Worker{
2795*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
2796*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
2797*58b9f456SAndroid Build Coastguard Worker        "string::insert(iterator, n, value) called with an iterator not"
2798*58b9f456SAndroid Build Coastguard Worker        " referring to this string");
2799*58b9f456SAndroid Build Coastguard Worker#endif
2800*58b9f456SAndroid Build Coastguard Worker    difference_type __p = __pos - begin();
2801*58b9f456SAndroid Build Coastguard Worker    insert(static_cast<size_type>(__p), __n, __c);
2802*58b9f456SAndroid Build Coastguard Worker    return begin() + __p;
2803*58b9f456SAndroid Build Coastguard Worker}
2804*58b9f456SAndroid Build Coastguard Worker
2805*58b9f456SAndroid Build Coastguard Worker// replace
2806*58b9f456SAndroid Build Coastguard Worker
2807*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2808*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2809*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2)
2810*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
2811*58b9f456SAndroid Build Coastguard Worker{
2812*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::replace received nullptr");
2813*58b9f456SAndroid Build Coastguard Worker    size_type __sz = size();
2814*58b9f456SAndroid Build Coastguard Worker    if (__pos > __sz)
2815*58b9f456SAndroid Build Coastguard Worker        this->__throw_out_of_range();
2816*58b9f456SAndroid Build Coastguard Worker    __n1 = _VSTD::min(__n1, __sz - __pos);
2817*58b9f456SAndroid Build Coastguard Worker    size_type __cap = capacity();
2818*58b9f456SAndroid Build Coastguard Worker    if (__cap - __sz + __n1 >= __n2)
2819*58b9f456SAndroid Build Coastguard Worker    {
2820*58b9f456SAndroid Build Coastguard Worker        value_type* __p = _VSTD::__to_raw_pointer(__get_pointer());
2821*58b9f456SAndroid Build Coastguard Worker        if (__n1 != __n2)
2822*58b9f456SAndroid Build Coastguard Worker        {
2823*58b9f456SAndroid Build Coastguard Worker            size_type __n_move = __sz - __pos - __n1;
2824*58b9f456SAndroid Build Coastguard Worker            if (__n_move != 0)
2825*58b9f456SAndroid Build Coastguard Worker            {
2826*58b9f456SAndroid Build Coastguard Worker                if (__n1 > __n2)
2827*58b9f456SAndroid Build Coastguard Worker                {
2828*58b9f456SAndroid Build Coastguard Worker                    traits_type::move(__p + __pos, __s, __n2);
2829*58b9f456SAndroid Build Coastguard Worker                    traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move);
2830*58b9f456SAndroid Build Coastguard Worker                    goto __finish;
2831*58b9f456SAndroid Build Coastguard Worker                }
2832*58b9f456SAndroid Build Coastguard Worker                if (__p + __pos < __s && __s < __p + __sz)
2833*58b9f456SAndroid Build Coastguard Worker                {
2834*58b9f456SAndroid Build Coastguard Worker                    if (__p + __pos + __n1 <= __s)
2835*58b9f456SAndroid Build Coastguard Worker                        __s += __n2 - __n1;
2836*58b9f456SAndroid Build Coastguard Worker                    else // __p + __pos < __s < __p + __pos + __n1
2837*58b9f456SAndroid Build Coastguard Worker                    {
2838*58b9f456SAndroid Build Coastguard Worker                        traits_type::move(__p + __pos, __s, __n1);
2839*58b9f456SAndroid Build Coastguard Worker                        __pos += __n1;
2840*58b9f456SAndroid Build Coastguard Worker                        __s += __n2;
2841*58b9f456SAndroid Build Coastguard Worker                        __n2 -= __n1;
2842*58b9f456SAndroid Build Coastguard Worker                        __n1 = 0;
2843*58b9f456SAndroid Build Coastguard Worker                    }
2844*58b9f456SAndroid Build Coastguard Worker                }
2845*58b9f456SAndroid Build Coastguard Worker                traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move);
2846*58b9f456SAndroid Build Coastguard Worker            }
2847*58b9f456SAndroid Build Coastguard Worker        }
2848*58b9f456SAndroid Build Coastguard Worker        traits_type::move(__p + __pos, __s, __n2);
2849*58b9f456SAndroid Build Coastguard Worker__finish:
2850*58b9f456SAndroid Build Coastguard Worker// __sz += __n2 - __n1; in this and the below function below can cause unsigned integer overflow,
2851*58b9f456SAndroid Build Coastguard Worker// but this is a safe operation, so we disable the check.
2852*58b9f456SAndroid Build Coastguard Worker        __sz += __n2 - __n1;
2853*58b9f456SAndroid Build Coastguard Worker        __set_size(__sz);
2854*58b9f456SAndroid Build Coastguard Worker        __invalidate_iterators_past(__sz);
2855*58b9f456SAndroid Build Coastguard Worker        traits_type::assign(__p[__sz], value_type());
2856*58b9f456SAndroid Build Coastguard Worker    }
2857*58b9f456SAndroid Build Coastguard Worker    else
2858*58b9f456SAndroid Build Coastguard Worker        __grow_by_and_replace(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2, __s);
2859*58b9f456SAndroid Build Coastguard Worker    return *this;
2860*58b9f456SAndroid Build Coastguard Worker}
2861*58b9f456SAndroid Build Coastguard Worker
2862*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2863*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2864*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, size_type __n2, value_type __c)
2865*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
2866*58b9f456SAndroid Build Coastguard Worker{
2867*58b9f456SAndroid Build Coastguard Worker    size_type __sz = size();
2868*58b9f456SAndroid Build Coastguard Worker    if (__pos > __sz)
2869*58b9f456SAndroid Build Coastguard Worker        this->__throw_out_of_range();
2870*58b9f456SAndroid Build Coastguard Worker    __n1 = _VSTD::min(__n1, __sz - __pos);
2871*58b9f456SAndroid Build Coastguard Worker    size_type __cap = capacity();
2872*58b9f456SAndroid Build Coastguard Worker    value_type* __p;
2873*58b9f456SAndroid Build Coastguard Worker    if (__cap - __sz + __n1 >= __n2)
2874*58b9f456SAndroid Build Coastguard Worker    {
2875*58b9f456SAndroid Build Coastguard Worker        __p = _VSTD::__to_raw_pointer(__get_pointer());
2876*58b9f456SAndroid Build Coastguard Worker        if (__n1 != __n2)
2877*58b9f456SAndroid Build Coastguard Worker        {
2878*58b9f456SAndroid Build Coastguard Worker            size_type __n_move = __sz - __pos - __n1;
2879*58b9f456SAndroid Build Coastguard Worker            if (__n_move != 0)
2880*58b9f456SAndroid Build Coastguard Worker                traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move);
2881*58b9f456SAndroid Build Coastguard Worker        }
2882*58b9f456SAndroid Build Coastguard Worker    }
2883*58b9f456SAndroid Build Coastguard Worker    else
2884*58b9f456SAndroid Build Coastguard Worker    {
2885*58b9f456SAndroid Build Coastguard Worker        __grow_by(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2);
2886*58b9f456SAndroid Build Coastguard Worker        __p = _VSTD::__to_raw_pointer(__get_long_pointer());
2887*58b9f456SAndroid Build Coastguard Worker    }
2888*58b9f456SAndroid Build Coastguard Worker    traits_type::assign(__p + __pos, __n2, __c);
2889*58b9f456SAndroid Build Coastguard Worker    __sz += __n2 - __n1;
2890*58b9f456SAndroid Build Coastguard Worker    __set_size(__sz);
2891*58b9f456SAndroid Build Coastguard Worker    __invalidate_iterators_past(__sz);
2892*58b9f456SAndroid Build Coastguard Worker    traits_type::assign(__p[__sz], value_type());
2893*58b9f456SAndroid Build Coastguard Worker    return *this;
2894*58b9f456SAndroid Build Coastguard Worker}
2895*58b9f456SAndroid Build Coastguard Worker
2896*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2897*58b9f456SAndroid Build Coastguard Workertemplate<class _InputIterator>
2898*58b9f456SAndroid Build Coastguard Workertypename enable_if
2899*58b9f456SAndroid Build Coastguard Worker<
2900*58b9f456SAndroid Build Coastguard Worker    __is_input_iterator<_InputIterator>::value,
2901*58b9f456SAndroid Build Coastguard Worker    basic_string<_CharT, _Traits, _Allocator>&
2902*58b9f456SAndroid Build Coastguard Worker>::type
2903*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2,
2904*58b9f456SAndroid Build Coastguard Worker                                                   _InputIterator __j1, _InputIterator __j2)
2905*58b9f456SAndroid Build Coastguard Worker{
2906*58b9f456SAndroid Build Coastguard Worker    const basic_string __temp(__j1, __j2, __alloc());
2907*58b9f456SAndroid Build Coastguard Worker    return this->replace(__i1, __i2, __temp);
2908*58b9f456SAndroid Build Coastguard Worker}
2909*58b9f456SAndroid Build Coastguard Worker
2910*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2911*58b9f456SAndroid Build Coastguard Workerinline
2912*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2913*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str)
2914*58b9f456SAndroid Build Coastguard Worker{
2915*58b9f456SAndroid Build Coastguard Worker    return replace(__pos1, __n1, __str.data(), __str.size());
2916*58b9f456SAndroid Build Coastguard Worker}
2917*58b9f456SAndroid Build Coastguard Worker
2918*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2919*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2920*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str,
2921*58b9f456SAndroid Build Coastguard Worker                                                   size_type __pos2, size_type __n2)
2922*58b9f456SAndroid Build Coastguard Worker{
2923*58b9f456SAndroid Build Coastguard Worker    size_type __str_sz = __str.size();
2924*58b9f456SAndroid Build Coastguard Worker    if (__pos2 > __str_sz)
2925*58b9f456SAndroid Build Coastguard Worker        this->__throw_out_of_range();
2926*58b9f456SAndroid Build Coastguard Worker    return replace(__pos1, __n1, __str.data() + __pos2, _VSTD::min(__n2, __str_sz - __pos2));
2927*58b9f456SAndroid Build Coastguard Worker}
2928*58b9f456SAndroid Build Coastguard Worker
2929*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2930*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
2931*58b9f456SAndroid Build Coastguard Workertypename enable_if
2932*58b9f456SAndroid Build Coastguard Worker<
2933*58b9f456SAndroid Build Coastguard Worker    __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
2934*58b9f456SAndroid Build Coastguard Worker    basic_string<_CharT, _Traits, _Allocator>&
2935*58b9f456SAndroid Build Coastguard Worker>::type
2936*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const _Tp& __t,
2937*58b9f456SAndroid Build Coastguard Worker                                                   size_type __pos2, size_type __n2)
2938*58b9f456SAndroid Build Coastguard Worker{
2939*58b9f456SAndroid Build Coastguard Worker    __self_view __sv = __t;
2940*58b9f456SAndroid Build Coastguard Worker    size_type __str_sz = __sv.size();
2941*58b9f456SAndroid Build Coastguard Worker    if (__pos2 > __str_sz)
2942*58b9f456SAndroid Build Coastguard Worker        this->__throw_out_of_range();
2943*58b9f456SAndroid Build Coastguard Worker    return replace(__pos1, __n1, __sv.data() + __pos2, _VSTD::min(__n2, __str_sz - __pos2));
2944*58b9f456SAndroid Build Coastguard Worker}
2945*58b9f456SAndroid Build Coastguard Worker
2946*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2947*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2948*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s)
2949*58b9f456SAndroid Build Coastguard Worker{
2950*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__s != nullptr, "string::replace received nullptr");
2951*58b9f456SAndroid Build Coastguard Worker    return replace(__pos, __n1, __s, traits_type::length(__s));
2952*58b9f456SAndroid Build Coastguard Worker}
2953*58b9f456SAndroid Build Coastguard Worker
2954*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2955*58b9f456SAndroid Build Coastguard Workerinline
2956*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2957*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const basic_string& __str)
2958*58b9f456SAndroid Build Coastguard Worker{
2959*58b9f456SAndroid Build Coastguard Worker    return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1),
2960*58b9f456SAndroid Build Coastguard Worker                   __str.data(), __str.size());
2961*58b9f456SAndroid Build Coastguard Worker}
2962*58b9f456SAndroid Build Coastguard Worker
2963*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2964*58b9f456SAndroid Build Coastguard Workerinline
2965*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2966*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n)
2967*58b9f456SAndroid Build Coastguard Worker{
2968*58b9f456SAndroid Build Coastguard Worker    return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __s, __n);
2969*58b9f456SAndroid Build Coastguard Worker}
2970*58b9f456SAndroid Build Coastguard Worker
2971*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2972*58b9f456SAndroid Build Coastguard Workerinline
2973*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2974*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s)
2975*58b9f456SAndroid Build Coastguard Worker{
2976*58b9f456SAndroid Build Coastguard Worker    return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __s);
2977*58b9f456SAndroid Build Coastguard Worker}
2978*58b9f456SAndroid Build Coastguard Worker
2979*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2980*58b9f456SAndroid Build Coastguard Workerinline
2981*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2982*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c)
2983*58b9f456SAndroid Build Coastguard Worker{
2984*58b9f456SAndroid Build Coastguard Worker    return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __n, __c);
2985*58b9f456SAndroid Build Coastguard Worker}
2986*58b9f456SAndroid Build Coastguard Worker
2987*58b9f456SAndroid Build Coastguard Worker// erase
2988*58b9f456SAndroid Build Coastguard Worker
2989*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
2990*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>&
2991*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, size_type __n)
2992*58b9f456SAndroid Build Coastguard Worker{
2993*58b9f456SAndroid Build Coastguard Worker    size_type __sz = size();
2994*58b9f456SAndroid Build Coastguard Worker    if (__pos > __sz)
2995*58b9f456SAndroid Build Coastguard Worker        this->__throw_out_of_range();
2996*58b9f456SAndroid Build Coastguard Worker    if (__n)
2997*58b9f456SAndroid Build Coastguard Worker    {
2998*58b9f456SAndroid Build Coastguard Worker        value_type* __p = _VSTD::__to_raw_pointer(__get_pointer());
2999*58b9f456SAndroid Build Coastguard Worker        __n = _VSTD::min(__n, __sz - __pos);
3000*58b9f456SAndroid Build Coastguard Worker        size_type __n_move = __sz - __pos - __n;
3001*58b9f456SAndroid Build Coastguard Worker        if (__n_move != 0)
3002*58b9f456SAndroid Build Coastguard Worker            traits_type::move(__p + __pos, __p + __pos + __n, __n_move);
3003*58b9f456SAndroid Build Coastguard Worker        __sz -= __n;
3004*58b9f456SAndroid Build Coastguard Worker        __set_size(__sz);
3005*58b9f456SAndroid Build Coastguard Worker        __invalidate_iterators_past(__sz);
3006*58b9f456SAndroid Build Coastguard Worker        traits_type::assign(__p[__sz], value_type());
3007*58b9f456SAndroid Build Coastguard Worker    }
3008*58b9f456SAndroid Build Coastguard Worker    return *this;
3009*58b9f456SAndroid Build Coastguard Worker}
3010*58b9f456SAndroid Build Coastguard Worker
3011*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3012*58b9f456SAndroid Build Coastguard Workerinline
3013*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::iterator
3014*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos)
3015*58b9f456SAndroid Build Coastguard Worker{
3016*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
3017*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
3018*58b9f456SAndroid Build Coastguard Worker        "string::erase(iterator) called with an iterator not"
3019*58b9f456SAndroid Build Coastguard Worker        " referring to this string");
3020*58b9f456SAndroid Build Coastguard Worker#endif
3021*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__pos != end(),
3022*58b9f456SAndroid Build Coastguard Worker        "string::erase(iterator) called with a non-dereferenceable iterator");
3023*58b9f456SAndroid Build Coastguard Worker    iterator __b = begin();
3024*58b9f456SAndroid Build Coastguard Worker    size_type __r = static_cast<size_type>(__pos - __b);
3025*58b9f456SAndroid Build Coastguard Worker    erase(__r, 1);
3026*58b9f456SAndroid Build Coastguard Worker    return __b + static_cast<difference_type>(__r);
3027*58b9f456SAndroid Build Coastguard Worker}
3028*58b9f456SAndroid Build Coastguard Worker
3029*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3030*58b9f456SAndroid Build Coastguard Workerinline
3031*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::iterator
3032*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last)
3033*58b9f456SAndroid Build Coastguard Worker{
3034*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
3035*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this,
3036*58b9f456SAndroid Build Coastguard Worker        "string::erase(iterator,  iterator) called with an iterator not"
3037*58b9f456SAndroid Build Coastguard Worker        " referring to this string");
3038*58b9f456SAndroid Build Coastguard Worker#endif
3039*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__first <= __last, "string::erase(first, last) called with invalid range");
3040*58b9f456SAndroid Build Coastguard Worker    iterator __b = begin();
3041*58b9f456SAndroid Build Coastguard Worker    size_type __r = static_cast<size_type>(__first - __b);
3042*58b9f456SAndroid Build Coastguard Worker    erase(__r, static_cast<size_type>(__last - __first));
3043*58b9f456SAndroid Build Coastguard Worker    return __b + static_cast<difference_type>(__r);
3044*58b9f456SAndroid Build Coastguard Worker}
3045*58b9f456SAndroid Build Coastguard Worker
3046*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3047*58b9f456SAndroid Build Coastguard Workerinline
3048*58b9f456SAndroid Build Coastguard Workervoid
3049*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::pop_back()
3050*58b9f456SAndroid Build Coastguard Worker{
3051*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(!empty(), "string::pop_back(): string is already empty");
3052*58b9f456SAndroid Build Coastguard Worker    size_type __sz;
3053*58b9f456SAndroid Build Coastguard Worker    if (__is_long())
3054*58b9f456SAndroid Build Coastguard Worker    {
3055*58b9f456SAndroid Build Coastguard Worker        __sz = __get_long_size() - 1;
3056*58b9f456SAndroid Build Coastguard Worker        __set_long_size(__sz);
3057*58b9f456SAndroid Build Coastguard Worker        traits_type::assign(*(__get_long_pointer() + __sz), value_type());
3058*58b9f456SAndroid Build Coastguard Worker    }
3059*58b9f456SAndroid Build Coastguard Worker    else
3060*58b9f456SAndroid Build Coastguard Worker    {
3061*58b9f456SAndroid Build Coastguard Worker        __sz = __get_short_size() - 1;
3062*58b9f456SAndroid Build Coastguard Worker        __set_short_size(__sz);
3063*58b9f456SAndroid Build Coastguard Worker        traits_type::assign(*(__get_short_pointer() + __sz), value_type());
3064*58b9f456SAndroid Build Coastguard Worker    }
3065*58b9f456SAndroid Build Coastguard Worker    __invalidate_iterators_past(__sz);
3066*58b9f456SAndroid Build Coastguard Worker}
3067*58b9f456SAndroid Build Coastguard Worker
3068*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3069*58b9f456SAndroid Build Coastguard Workerinline
3070*58b9f456SAndroid Build Coastguard Workervoid
3071*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT
3072*58b9f456SAndroid Build Coastguard Worker{
3073*58b9f456SAndroid Build Coastguard Worker    __invalidate_all_iterators();
3074*58b9f456SAndroid Build Coastguard Worker    if (__is_long())
3075*58b9f456SAndroid Build Coastguard Worker    {
3076*58b9f456SAndroid Build Coastguard Worker        traits_type::assign(*__get_long_pointer(), value_type());
3077*58b9f456SAndroid Build Coastguard Worker        __set_long_size(0);
3078*58b9f456SAndroid Build Coastguard Worker    }
3079*58b9f456SAndroid Build Coastguard Worker    else
3080*58b9f456SAndroid Build Coastguard Worker    {
3081*58b9f456SAndroid Build Coastguard Worker        traits_type::assign(*__get_short_pointer(), value_type());
3082*58b9f456SAndroid Build Coastguard Worker        __set_short_size(0);
3083*58b9f456SAndroid Build Coastguard Worker    }
3084*58b9f456SAndroid Build Coastguard Worker}
3085*58b9f456SAndroid Build Coastguard Worker
3086*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3087*58b9f456SAndroid Build Coastguard Workerinline
3088*58b9f456SAndroid Build Coastguard Workervoid
3089*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::__erase_to_end(size_type __pos)
3090*58b9f456SAndroid Build Coastguard Worker{
3091*58b9f456SAndroid Build Coastguard Worker    if (__is_long())
3092*58b9f456SAndroid Build Coastguard Worker    {
3093*58b9f456SAndroid Build Coastguard Worker        traits_type::assign(*(__get_long_pointer() + __pos), value_type());
3094*58b9f456SAndroid Build Coastguard Worker        __set_long_size(__pos);
3095*58b9f456SAndroid Build Coastguard Worker    }
3096*58b9f456SAndroid Build Coastguard Worker    else
3097*58b9f456SAndroid Build Coastguard Worker    {
3098*58b9f456SAndroid Build Coastguard Worker        traits_type::assign(*(__get_short_pointer() + __pos), value_type());
3099*58b9f456SAndroid Build Coastguard Worker        __set_short_size(__pos);
3100*58b9f456SAndroid Build Coastguard Worker    }
3101*58b9f456SAndroid Build Coastguard Worker    __invalidate_iterators_past(__pos);
3102*58b9f456SAndroid Build Coastguard Worker}
3103*58b9f456SAndroid Build Coastguard Worker
3104*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3105*58b9f456SAndroid Build Coastguard Workervoid
3106*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c)
3107*58b9f456SAndroid Build Coastguard Worker{
3108*58b9f456SAndroid Build Coastguard Worker    size_type __sz = size();
3109*58b9f456SAndroid Build Coastguard Worker    if (__n > __sz)
3110*58b9f456SAndroid Build Coastguard Worker        append(__n - __sz, __c);
3111*58b9f456SAndroid Build Coastguard Worker    else
3112*58b9f456SAndroid Build Coastguard Worker        __erase_to_end(__n);
3113*58b9f456SAndroid Build Coastguard Worker}
3114*58b9f456SAndroid Build Coastguard Worker
3115*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3116*58b9f456SAndroid Build Coastguard Workerinline void
3117*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n)
3118*58b9f456SAndroid Build Coastguard Worker{
3119*58b9f456SAndroid Build Coastguard Worker    size_type __sz = size();
3120*58b9f456SAndroid Build Coastguard Worker    if (__n > __sz) {
3121*58b9f456SAndroid Build Coastguard Worker       __append_default_init(__n - __sz);
3122*58b9f456SAndroid Build Coastguard Worker    } else
3123*58b9f456SAndroid Build Coastguard Worker        __erase_to_end(__n);
3124*58b9f456SAndroid Build Coastguard Worker}
3125*58b9f456SAndroid Build Coastguard Worker
3126*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3127*58b9f456SAndroid Build Coastguard Workerinline
3128*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3129*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::max_size() const _NOEXCEPT
3130*58b9f456SAndroid Build Coastguard Worker{
3131*58b9f456SAndroid Build Coastguard Worker    size_type __m = __alloc_traits::max_size(__alloc());
3132*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_BIG_ENDIAN
3133*58b9f456SAndroid Build Coastguard Worker    return (__m <= ~__long_mask ? __m : __m/2) - __alignment;
3134*58b9f456SAndroid Build Coastguard Worker#else
3135*58b9f456SAndroid Build Coastguard Worker    return __m - __alignment;
3136*58b9f456SAndroid Build Coastguard Worker#endif
3137*58b9f456SAndroid Build Coastguard Worker}
3138*58b9f456SAndroid Build Coastguard Worker
3139*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3140*58b9f456SAndroid Build Coastguard Workervoid
3141*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::reserve(size_type __res_arg)
3142*58b9f456SAndroid Build Coastguard Worker{
3143*58b9f456SAndroid Build Coastguard Worker    if (__res_arg > max_size())
3144*58b9f456SAndroid Build Coastguard Worker        this->__throw_length_error();
3145*58b9f456SAndroid Build Coastguard Worker    size_type __cap = capacity();
3146*58b9f456SAndroid Build Coastguard Worker    size_type __sz = size();
3147*58b9f456SAndroid Build Coastguard Worker    __res_arg = _VSTD::max(__res_arg, __sz);
3148*58b9f456SAndroid Build Coastguard Worker    __res_arg = __recommend(__res_arg);
3149*58b9f456SAndroid Build Coastguard Worker    if (__res_arg != __cap)
3150*58b9f456SAndroid Build Coastguard Worker    {
3151*58b9f456SAndroid Build Coastguard Worker        pointer __new_data, __p;
3152*58b9f456SAndroid Build Coastguard Worker        bool __was_long, __now_long;
3153*58b9f456SAndroid Build Coastguard Worker        if (__res_arg == __min_cap - 1)
3154*58b9f456SAndroid Build Coastguard Worker        {
3155*58b9f456SAndroid Build Coastguard Worker            __was_long = true;
3156*58b9f456SAndroid Build Coastguard Worker            __now_long = false;
3157*58b9f456SAndroid Build Coastguard Worker            __new_data = __get_short_pointer();
3158*58b9f456SAndroid Build Coastguard Worker            __p = __get_long_pointer();
3159*58b9f456SAndroid Build Coastguard Worker        }
3160*58b9f456SAndroid Build Coastguard Worker        else
3161*58b9f456SAndroid Build Coastguard Worker        {
3162*58b9f456SAndroid Build Coastguard Worker            if (__res_arg > __cap)
3163*58b9f456SAndroid Build Coastguard Worker                __new_data = __alloc_traits::allocate(__alloc(), __res_arg+1);
3164*58b9f456SAndroid Build Coastguard Worker            else
3165*58b9f456SAndroid Build Coastguard Worker            {
3166*58b9f456SAndroid Build Coastguard Worker            #ifndef _LIBCPP_NO_EXCEPTIONS
3167*58b9f456SAndroid Build Coastguard Worker                try
3168*58b9f456SAndroid Build Coastguard Worker                {
3169*58b9f456SAndroid Build Coastguard Worker            #endif  // _LIBCPP_NO_EXCEPTIONS
3170*58b9f456SAndroid Build Coastguard Worker                    __new_data = __alloc_traits::allocate(__alloc(), __res_arg+1);
3171*58b9f456SAndroid Build Coastguard Worker            #ifndef _LIBCPP_NO_EXCEPTIONS
3172*58b9f456SAndroid Build Coastguard Worker                }
3173*58b9f456SAndroid Build Coastguard Worker                catch (...)
3174*58b9f456SAndroid Build Coastguard Worker                {
3175*58b9f456SAndroid Build Coastguard Worker                    return;
3176*58b9f456SAndroid Build Coastguard Worker                }
3177*58b9f456SAndroid Build Coastguard Worker            #else  // _LIBCPP_NO_EXCEPTIONS
3178*58b9f456SAndroid Build Coastguard Worker                if (__new_data == nullptr)
3179*58b9f456SAndroid Build Coastguard Worker                    return;
3180*58b9f456SAndroid Build Coastguard Worker            #endif  // _LIBCPP_NO_EXCEPTIONS
3181*58b9f456SAndroid Build Coastguard Worker            }
3182*58b9f456SAndroid Build Coastguard Worker            __now_long = true;
3183*58b9f456SAndroid Build Coastguard Worker            __was_long = __is_long();
3184*58b9f456SAndroid Build Coastguard Worker            __p = __get_pointer();
3185*58b9f456SAndroid Build Coastguard Worker        }
3186*58b9f456SAndroid Build Coastguard Worker        traits_type::copy(_VSTD::__to_raw_pointer(__new_data),
3187*58b9f456SAndroid Build Coastguard Worker                          _VSTD::__to_raw_pointer(__p), size()+1);
3188*58b9f456SAndroid Build Coastguard Worker        if (__was_long)
3189*58b9f456SAndroid Build Coastguard Worker            __alloc_traits::deallocate(__alloc(), __p, __cap+1);
3190*58b9f456SAndroid Build Coastguard Worker        if (__now_long)
3191*58b9f456SAndroid Build Coastguard Worker        {
3192*58b9f456SAndroid Build Coastguard Worker            __set_long_cap(__res_arg+1);
3193*58b9f456SAndroid Build Coastguard Worker            __set_long_size(__sz);
3194*58b9f456SAndroid Build Coastguard Worker            __set_long_pointer(__new_data);
3195*58b9f456SAndroid Build Coastguard Worker        }
3196*58b9f456SAndroid Build Coastguard Worker        else
3197*58b9f456SAndroid Build Coastguard Worker            __set_short_size(__sz);
3198*58b9f456SAndroid Build Coastguard Worker        __invalidate_all_iterators();
3199*58b9f456SAndroid Build Coastguard Worker    }
3200*58b9f456SAndroid Build Coastguard Worker}
3201*58b9f456SAndroid Build Coastguard Worker
3202*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3203*58b9f456SAndroid Build Coastguard Workerinline
3204*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::const_reference
3205*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) const _NOEXCEPT
3206*58b9f456SAndroid Build Coastguard Worker{
3207*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds");
3208*58b9f456SAndroid Build Coastguard Worker    return *(data() + __pos);
3209*58b9f456SAndroid Build Coastguard Worker}
3210*58b9f456SAndroid Build Coastguard Worker
3211*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3212*58b9f456SAndroid Build Coastguard Workerinline
3213*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::reference
3214*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) _NOEXCEPT
3215*58b9f456SAndroid Build Coastguard Worker{
3216*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds");
3217*58b9f456SAndroid Build Coastguard Worker    return *(__get_pointer() + __pos);
3218*58b9f456SAndroid Build Coastguard Worker}
3219*58b9f456SAndroid Build Coastguard Worker
3220*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3221*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::const_reference
3222*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const
3223*58b9f456SAndroid Build Coastguard Worker{
3224*58b9f456SAndroid Build Coastguard Worker    if (__n >= size())
3225*58b9f456SAndroid Build Coastguard Worker        this->__throw_out_of_range();
3226*58b9f456SAndroid Build Coastguard Worker    return (*this)[__n];
3227*58b9f456SAndroid Build Coastguard Worker}
3228*58b9f456SAndroid Build Coastguard Worker
3229*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3230*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::reference
3231*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::at(size_type __n)
3232*58b9f456SAndroid Build Coastguard Worker{
3233*58b9f456SAndroid Build Coastguard Worker    if (__n >= size())
3234*58b9f456SAndroid Build Coastguard Worker        this->__throw_out_of_range();
3235*58b9f456SAndroid Build Coastguard Worker    return (*this)[__n];
3236*58b9f456SAndroid Build Coastguard Worker}
3237*58b9f456SAndroid Build Coastguard Worker
3238*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3239*58b9f456SAndroid Build Coastguard Workerinline
3240*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::reference
3241*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::front()
3242*58b9f456SAndroid Build Coastguard Worker{
3243*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(!empty(), "string::front(): string is empty");
3244*58b9f456SAndroid Build Coastguard Worker    return *__get_pointer();
3245*58b9f456SAndroid Build Coastguard Worker}
3246*58b9f456SAndroid Build Coastguard Worker
3247*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3248*58b9f456SAndroid Build Coastguard Workerinline
3249*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::const_reference
3250*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::front() const
3251*58b9f456SAndroid Build Coastguard Worker{
3252*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(!empty(), "string::front(): string is empty");
3253*58b9f456SAndroid Build Coastguard Worker    return *data();
3254*58b9f456SAndroid Build Coastguard Worker}
3255*58b9f456SAndroid Build Coastguard Worker
3256*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3257*58b9f456SAndroid Build Coastguard Workerinline
3258*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::reference
3259*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::back()
3260*58b9f456SAndroid Build Coastguard Worker{
3261*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(!empty(), "string::back(): string is empty");
3262*58b9f456SAndroid Build Coastguard Worker    return *(__get_pointer() + size() - 1);
3263*58b9f456SAndroid Build Coastguard Worker}
3264*58b9f456SAndroid Build Coastguard Worker
3265*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3266*58b9f456SAndroid Build Coastguard Workerinline
3267*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::const_reference
3268*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::back() const
3269*58b9f456SAndroid Build Coastguard Worker{
3270*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(!empty(), "string::back(): string is empty");
3271*58b9f456SAndroid Build Coastguard Worker    return *(data() + size() - 1);
3272*58b9f456SAndroid Build Coastguard Worker}
3273*58b9f456SAndroid Build Coastguard Worker
3274*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3275*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3276*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, size_type __pos) const
3277*58b9f456SAndroid Build Coastguard Worker{
3278*58b9f456SAndroid Build Coastguard Worker    size_type __sz = size();
3279*58b9f456SAndroid Build Coastguard Worker    if (__pos > __sz)
3280*58b9f456SAndroid Build Coastguard Worker        this->__throw_out_of_range();
3281*58b9f456SAndroid Build Coastguard Worker    size_type __rlen = _VSTD::min(__n, __sz - __pos);
3282*58b9f456SAndroid Build Coastguard Worker    traits_type::copy(__s, data() + __pos, __rlen);
3283*58b9f456SAndroid Build Coastguard Worker    return __rlen;
3284*58b9f456SAndroid Build Coastguard Worker}
3285*58b9f456SAndroid Build Coastguard Worker
3286*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3287*58b9f456SAndroid Build Coastguard Workerinline
3288*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>
3289*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::substr(size_type __pos, size_type __n) const
3290*58b9f456SAndroid Build Coastguard Worker{
3291*58b9f456SAndroid Build Coastguard Worker    return basic_string(*this, __pos, __n, __alloc());
3292*58b9f456SAndroid Build Coastguard Worker}
3293*58b9f456SAndroid Build Coastguard Worker
3294*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3295*58b9f456SAndroid Build Coastguard Workerinline
3296*58b9f456SAndroid Build Coastguard Workervoid
3297*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)
3298*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER >= 14
3299*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_DEBUG
3300*58b9f456SAndroid Build Coastguard Worker#else
3301*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value ||
3302*58b9f456SAndroid Build Coastguard Worker                    __is_nothrow_swappable<allocator_type>::value)
3303*58b9f456SAndroid Build Coastguard Worker#endif
3304*58b9f456SAndroid Build Coastguard Worker{
3305*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
3306*58b9f456SAndroid Build Coastguard Worker    if (!__is_long())
3307*58b9f456SAndroid Build Coastguard Worker        __get_db()->__invalidate_all(this);
3308*58b9f456SAndroid Build Coastguard Worker    if (!__str.__is_long())
3309*58b9f456SAndroid Build Coastguard Worker        __get_db()->__invalidate_all(&__str);
3310*58b9f456SAndroid Build Coastguard Worker    __get_db()->swap(this, &__str);
3311*58b9f456SAndroid Build Coastguard Worker#endif
3312*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(
3313*58b9f456SAndroid Build Coastguard Worker        __alloc_traits::propagate_on_container_swap::value ||
3314*58b9f456SAndroid Build Coastguard Worker        __alloc_traits::is_always_equal::value ||
3315*58b9f456SAndroid Build Coastguard Worker        __alloc() == __str.__alloc(), "swapping non-equal allocators");
3316*58b9f456SAndroid Build Coastguard Worker    _VSTD::swap(__r_.first(), __str.__r_.first());
3317*58b9f456SAndroid Build Coastguard Worker    __swap_allocator(__alloc(), __str.__alloc());
3318*58b9f456SAndroid Build Coastguard Worker}
3319*58b9f456SAndroid Build Coastguard Worker
3320*58b9f456SAndroid Build Coastguard Worker// find
3321*58b9f456SAndroid Build Coastguard Worker
3322*58b9f456SAndroid Build Coastguard Workertemplate <class _Traits>
3323*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_HIDDEN __traits_eq
3324*58b9f456SAndroid Build Coastguard Worker{
3325*58b9f456SAndroid Build Coastguard Worker    typedef typename _Traits::char_type char_type;
3326*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
3327*58b9f456SAndroid Build Coastguard Worker    bool operator()(const char_type& __x, const char_type& __y) _NOEXCEPT
3328*58b9f456SAndroid Build Coastguard Worker        {return _Traits::eq(__x, __y);}
3329*58b9f456SAndroid Build Coastguard Worker};
3330*58b9f456SAndroid Build Coastguard Worker
3331*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3332*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3333*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,
3334*58b9f456SAndroid Build Coastguard Worker                                                size_type __pos,
3335*58b9f456SAndroid Build Coastguard Worker                                                size_type __n) const _NOEXCEPT
3336*58b9f456SAndroid Build Coastguard Worker{
3337*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find(): received nullptr");
3338*58b9f456SAndroid Build Coastguard Worker    return __str_find<value_type, size_type, traits_type, npos>
3339*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __s, __pos, __n);
3340*58b9f456SAndroid Build Coastguard Worker}
3341*58b9f456SAndroid Build Coastguard Worker
3342*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3343*58b9f456SAndroid Build Coastguard Workerinline
3344*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3345*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str,
3346*58b9f456SAndroid Build Coastguard Worker                                                size_type __pos) const _NOEXCEPT
3347*58b9f456SAndroid Build Coastguard Worker{
3348*58b9f456SAndroid Build Coastguard Worker    return __str_find<value_type, size_type, traits_type, npos>
3349*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __str.data(), __pos, __str.size());
3350*58b9f456SAndroid Build Coastguard Worker}
3351*58b9f456SAndroid Build Coastguard Worker
3352*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3353*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
3354*58b9f456SAndroid Build Coastguard Workertypename enable_if
3355*58b9f456SAndroid Build Coastguard Worker<
3356*58b9f456SAndroid Build Coastguard Worker    __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
3357*58b9f456SAndroid Build Coastguard Worker    typename basic_string<_CharT, _Traits, _Allocator>::size_type
3358*58b9f456SAndroid Build Coastguard Worker>::type
3359*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::find(const _Tp &__t,
3360*58b9f456SAndroid Build Coastguard Worker                                                size_type __pos) const
3361*58b9f456SAndroid Build Coastguard Worker{
3362*58b9f456SAndroid Build Coastguard Worker    __self_view __sv = __t;
3363*58b9f456SAndroid Build Coastguard Worker    return __str_find<value_type, size_type, traits_type, npos>
3364*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __sv.data(), __pos, __sv.size());
3365*58b9f456SAndroid Build Coastguard Worker}
3366*58b9f456SAndroid Build Coastguard Worker
3367*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3368*58b9f456SAndroid Build Coastguard Workerinline
3369*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3370*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,
3371*58b9f456SAndroid Build Coastguard Worker                                                size_type __pos) const _NOEXCEPT
3372*58b9f456SAndroid Build Coastguard Worker{
3373*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__s != nullptr, "string::find(): received nullptr");
3374*58b9f456SAndroid Build Coastguard Worker    return __str_find<value_type, size_type, traits_type, npos>
3375*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __s, __pos, traits_type::length(__s));
3376*58b9f456SAndroid Build Coastguard Worker}
3377*58b9f456SAndroid Build Coastguard Worker
3378*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3379*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3380*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::find(value_type __c,
3381*58b9f456SAndroid Build Coastguard Worker                                                size_type __pos) const _NOEXCEPT
3382*58b9f456SAndroid Build Coastguard Worker{
3383*58b9f456SAndroid Build Coastguard Worker    return __str_find<value_type, size_type, traits_type, npos>
3384*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __c, __pos);
3385*58b9f456SAndroid Build Coastguard Worker}
3386*58b9f456SAndroid Build Coastguard Worker
3387*58b9f456SAndroid Build Coastguard Worker// rfind
3388*58b9f456SAndroid Build Coastguard Worker
3389*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3390*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3391*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,
3392*58b9f456SAndroid Build Coastguard Worker                                                 size_type __pos,
3393*58b9f456SAndroid Build Coastguard Worker                                                 size_type __n) const _NOEXCEPT
3394*58b9f456SAndroid Build Coastguard Worker{
3395*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::rfind(): received nullptr");
3396*58b9f456SAndroid Build Coastguard Worker    return __str_rfind<value_type, size_type, traits_type, npos>
3397*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __s, __pos, __n);
3398*58b9f456SAndroid Build Coastguard Worker}
3399*58b9f456SAndroid Build Coastguard Worker
3400*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3401*58b9f456SAndroid Build Coastguard Workerinline
3402*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3403*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str,
3404*58b9f456SAndroid Build Coastguard Worker                                                 size_type __pos) const _NOEXCEPT
3405*58b9f456SAndroid Build Coastguard Worker{
3406*58b9f456SAndroid Build Coastguard Worker    return __str_rfind<value_type, size_type, traits_type, npos>
3407*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __str.data(), __pos, __str.size());
3408*58b9f456SAndroid Build Coastguard Worker}
3409*58b9f456SAndroid Build Coastguard Worker
3410*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3411*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
3412*58b9f456SAndroid Build Coastguard Workertypename enable_if
3413*58b9f456SAndroid Build Coastguard Worker<
3414*58b9f456SAndroid Build Coastguard Worker    __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
3415*58b9f456SAndroid Build Coastguard Worker    typename basic_string<_CharT, _Traits, _Allocator>::size_type
3416*58b9f456SAndroid Build Coastguard Worker>::type
3417*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::rfind(const _Tp& __t,
3418*58b9f456SAndroid Build Coastguard Worker                                                size_type __pos) const
3419*58b9f456SAndroid Build Coastguard Worker{
3420*58b9f456SAndroid Build Coastguard Worker    __self_view __sv = __t;
3421*58b9f456SAndroid Build Coastguard Worker    return __str_rfind<value_type, size_type, traits_type, npos>
3422*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __sv.data(), __pos, __sv.size());
3423*58b9f456SAndroid Build Coastguard Worker}
3424*58b9f456SAndroid Build Coastguard Worker
3425*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3426*58b9f456SAndroid Build Coastguard Workerinline
3427*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3428*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,
3429*58b9f456SAndroid Build Coastguard Worker                                                 size_type __pos) const _NOEXCEPT
3430*58b9f456SAndroid Build Coastguard Worker{
3431*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__s != nullptr, "string::rfind(): received nullptr");
3432*58b9f456SAndroid Build Coastguard Worker    return __str_rfind<value_type, size_type, traits_type, npos>
3433*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __s, __pos, traits_type::length(__s));
3434*58b9f456SAndroid Build Coastguard Worker}
3435*58b9f456SAndroid Build Coastguard Worker
3436*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3437*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3438*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c,
3439*58b9f456SAndroid Build Coastguard Worker                                                 size_type __pos) const _NOEXCEPT
3440*58b9f456SAndroid Build Coastguard Worker{
3441*58b9f456SAndroid Build Coastguard Worker    return __str_rfind<value_type, size_type, traits_type, npos>
3442*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __c, __pos);
3443*58b9f456SAndroid Build Coastguard Worker}
3444*58b9f456SAndroid Build Coastguard Worker
3445*58b9f456SAndroid Build Coastguard Worker// find_first_of
3446*58b9f456SAndroid Build Coastguard Worker
3447*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3448*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3449*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,
3450*58b9f456SAndroid Build Coastguard Worker                                                         size_type __pos,
3451*58b9f456SAndroid Build Coastguard Worker                                                         size_type __n) const _NOEXCEPT
3452*58b9f456SAndroid Build Coastguard Worker{
3453*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_of(): received nullptr");
3454*58b9f456SAndroid Build Coastguard Worker    return __str_find_first_of<value_type, size_type, traits_type, npos>
3455*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __s, __pos, __n);
3456*58b9f456SAndroid Build Coastguard Worker}
3457*58b9f456SAndroid Build Coastguard Worker
3458*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3459*58b9f456SAndroid Build Coastguard Workerinline
3460*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3461*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str,
3462*58b9f456SAndroid Build Coastguard Worker                                                         size_type __pos) const _NOEXCEPT
3463*58b9f456SAndroid Build Coastguard Worker{
3464*58b9f456SAndroid Build Coastguard Worker    return __str_find_first_of<value_type, size_type, traits_type, npos>
3465*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __str.data(), __pos, __str.size());
3466*58b9f456SAndroid Build Coastguard Worker}
3467*58b9f456SAndroid Build Coastguard Worker
3468*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3469*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
3470*58b9f456SAndroid Build Coastguard Workertypename enable_if
3471*58b9f456SAndroid Build Coastguard Worker<
3472*58b9f456SAndroid Build Coastguard Worker    __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
3473*58b9f456SAndroid Build Coastguard Worker    typename basic_string<_CharT, _Traits, _Allocator>::size_type
3474*58b9f456SAndroid Build Coastguard Worker>::type
3475*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::find_first_of(const _Tp& __t,
3476*58b9f456SAndroid Build Coastguard Worker                                                size_type __pos) const
3477*58b9f456SAndroid Build Coastguard Worker{
3478*58b9f456SAndroid Build Coastguard Worker    __self_view __sv = __t;
3479*58b9f456SAndroid Build Coastguard Worker    return __str_find_first_of<value_type, size_type, traits_type, npos>
3480*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __sv.data(), __pos, __sv.size());
3481*58b9f456SAndroid Build Coastguard Worker}
3482*58b9f456SAndroid Build Coastguard Worker
3483*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3484*58b9f456SAndroid Build Coastguard Workerinline
3485*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3486*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,
3487*58b9f456SAndroid Build Coastguard Worker                                                         size_type __pos) const _NOEXCEPT
3488*58b9f456SAndroid Build Coastguard Worker{
3489*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__s != nullptr, "string::find_first_of(): received nullptr");
3490*58b9f456SAndroid Build Coastguard Worker    return __str_find_first_of<value_type, size_type, traits_type, npos>
3491*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __s, __pos, traits_type::length(__s));
3492*58b9f456SAndroid Build Coastguard Worker}
3493*58b9f456SAndroid Build Coastguard Worker
3494*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3495*58b9f456SAndroid Build Coastguard Workerinline
3496*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3497*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c,
3498*58b9f456SAndroid Build Coastguard Worker                                                         size_type __pos) const _NOEXCEPT
3499*58b9f456SAndroid Build Coastguard Worker{
3500*58b9f456SAndroid Build Coastguard Worker    return find(__c, __pos);
3501*58b9f456SAndroid Build Coastguard Worker}
3502*58b9f456SAndroid Build Coastguard Worker
3503*58b9f456SAndroid Build Coastguard Worker// find_last_of
3504*58b9f456SAndroid Build Coastguard Worker
3505*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3506*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3507*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,
3508*58b9f456SAndroid Build Coastguard Worker                                                        size_type __pos,
3509*58b9f456SAndroid Build Coastguard Worker                                                        size_type __n) const _NOEXCEPT
3510*58b9f456SAndroid Build Coastguard Worker{
3511*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_of(): received nullptr");
3512*58b9f456SAndroid Build Coastguard Worker    return __str_find_last_of<value_type, size_type, traits_type, npos>
3513*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __s, __pos, __n);
3514*58b9f456SAndroid Build Coastguard Worker}
3515*58b9f456SAndroid Build Coastguard Worker
3516*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3517*58b9f456SAndroid Build Coastguard Workerinline
3518*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3519*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str,
3520*58b9f456SAndroid Build Coastguard Worker                                                        size_type __pos) const _NOEXCEPT
3521*58b9f456SAndroid Build Coastguard Worker{
3522*58b9f456SAndroid Build Coastguard Worker    return __str_find_last_of<value_type, size_type, traits_type, npos>
3523*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __str.data(), __pos, __str.size());
3524*58b9f456SAndroid Build Coastguard Worker}
3525*58b9f456SAndroid Build Coastguard Worker
3526*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3527*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
3528*58b9f456SAndroid Build Coastguard Workertypename enable_if
3529*58b9f456SAndroid Build Coastguard Worker<
3530*58b9f456SAndroid Build Coastguard Worker    __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
3531*58b9f456SAndroid Build Coastguard Worker    typename basic_string<_CharT, _Traits, _Allocator>::size_type
3532*58b9f456SAndroid Build Coastguard Worker>::type
3533*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::find_last_of(const _Tp& __t,
3534*58b9f456SAndroid Build Coastguard Worker                                                size_type __pos) const
3535*58b9f456SAndroid Build Coastguard Worker{
3536*58b9f456SAndroid Build Coastguard Worker    __self_view __sv = __t;
3537*58b9f456SAndroid Build Coastguard Worker    return __str_find_last_of<value_type, size_type, traits_type, npos>
3538*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __sv.data(), __pos, __sv.size());
3539*58b9f456SAndroid Build Coastguard Worker}
3540*58b9f456SAndroid Build Coastguard Worker
3541*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3542*58b9f456SAndroid Build Coastguard Workerinline
3543*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3544*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,
3545*58b9f456SAndroid Build Coastguard Worker                                                        size_type __pos) const _NOEXCEPT
3546*58b9f456SAndroid Build Coastguard Worker{
3547*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__s != nullptr, "string::find_last_of(): received nullptr");
3548*58b9f456SAndroid Build Coastguard Worker    return __str_find_last_of<value_type, size_type, traits_type, npos>
3549*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __s, __pos, traits_type::length(__s));
3550*58b9f456SAndroid Build Coastguard Worker}
3551*58b9f456SAndroid Build Coastguard Worker
3552*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3553*58b9f456SAndroid Build Coastguard Workerinline
3554*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3555*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c,
3556*58b9f456SAndroid Build Coastguard Worker                                                        size_type __pos) const _NOEXCEPT
3557*58b9f456SAndroid Build Coastguard Worker{
3558*58b9f456SAndroid Build Coastguard Worker    return rfind(__c, __pos);
3559*58b9f456SAndroid Build Coastguard Worker}
3560*58b9f456SAndroid Build Coastguard Worker
3561*58b9f456SAndroid Build Coastguard Worker// find_first_not_of
3562*58b9f456SAndroid Build Coastguard Worker
3563*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3564*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3565*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s,
3566*58b9f456SAndroid Build Coastguard Worker                                                             size_type __pos,
3567*58b9f456SAndroid Build Coastguard Worker                                                             size_type __n) const _NOEXCEPT
3568*58b9f456SAndroid Build Coastguard Worker{
3569*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_not_of(): received nullptr");
3570*58b9f456SAndroid Build Coastguard Worker    return __str_find_first_not_of<value_type, size_type, traits_type, npos>
3571*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __s, __pos, __n);
3572*58b9f456SAndroid Build Coastguard Worker}
3573*58b9f456SAndroid Build Coastguard Worker
3574*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3575*58b9f456SAndroid Build Coastguard Workerinline
3576*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3577*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& __str,
3578*58b9f456SAndroid Build Coastguard Worker                                                             size_type __pos) const _NOEXCEPT
3579*58b9f456SAndroid Build Coastguard Worker{
3580*58b9f456SAndroid Build Coastguard Worker    return __str_find_first_not_of<value_type, size_type, traits_type, npos>
3581*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __str.data(), __pos, __str.size());
3582*58b9f456SAndroid Build Coastguard Worker}
3583*58b9f456SAndroid Build Coastguard Worker
3584*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3585*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
3586*58b9f456SAndroid Build Coastguard Workertypename enable_if
3587*58b9f456SAndroid Build Coastguard Worker<
3588*58b9f456SAndroid Build Coastguard Worker    __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
3589*58b9f456SAndroid Build Coastguard Worker    typename basic_string<_CharT, _Traits, _Allocator>::size_type
3590*58b9f456SAndroid Build Coastguard Worker>::type
3591*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const _Tp& __t,
3592*58b9f456SAndroid Build Coastguard Worker                                                size_type __pos) const
3593*58b9f456SAndroid Build Coastguard Worker{
3594*58b9f456SAndroid Build Coastguard Worker    __self_view __sv = __t;
3595*58b9f456SAndroid Build Coastguard Worker    return __str_find_first_not_of<value_type, size_type, traits_type, npos>
3596*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __sv.data(), __pos, __sv.size());
3597*58b9f456SAndroid Build Coastguard Worker}
3598*58b9f456SAndroid Build Coastguard Worker
3599*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3600*58b9f456SAndroid Build Coastguard Workerinline
3601*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3602*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s,
3603*58b9f456SAndroid Build Coastguard Worker                                                             size_type __pos) const _NOEXCEPT
3604*58b9f456SAndroid Build Coastguard Worker{
3605*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__s != nullptr, "string::find_first_not_of(): received nullptr");
3606*58b9f456SAndroid Build Coastguard Worker    return __str_find_first_not_of<value_type, size_type, traits_type, npos>
3607*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __s, __pos, traits_type::length(__s));
3608*58b9f456SAndroid Build Coastguard Worker}
3609*58b9f456SAndroid Build Coastguard Worker
3610*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3611*58b9f456SAndroid Build Coastguard Workerinline
3612*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3613*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c,
3614*58b9f456SAndroid Build Coastguard Worker                                                             size_type __pos) const _NOEXCEPT
3615*58b9f456SAndroid Build Coastguard Worker{
3616*58b9f456SAndroid Build Coastguard Worker    return __str_find_first_not_of<value_type, size_type, traits_type, npos>
3617*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __c, __pos);
3618*58b9f456SAndroid Build Coastguard Worker}
3619*58b9f456SAndroid Build Coastguard Worker
3620*58b9f456SAndroid Build Coastguard Worker// find_last_not_of
3621*58b9f456SAndroid Build Coastguard Worker
3622*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3623*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3624*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s,
3625*58b9f456SAndroid Build Coastguard Worker                                                            size_type __pos,
3626*58b9f456SAndroid Build Coastguard Worker                                                            size_type __n) const _NOEXCEPT
3627*58b9f456SAndroid Build Coastguard Worker{
3628*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_not_of(): received nullptr");
3629*58b9f456SAndroid Build Coastguard Worker    return __str_find_last_not_of<value_type, size_type, traits_type, npos>
3630*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __s, __pos, __n);
3631*58b9f456SAndroid Build Coastguard Worker}
3632*58b9f456SAndroid Build Coastguard Worker
3633*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3634*58b9f456SAndroid Build Coastguard Workerinline
3635*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3636*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& __str,
3637*58b9f456SAndroid Build Coastguard Worker                                                            size_type __pos) const _NOEXCEPT
3638*58b9f456SAndroid Build Coastguard Worker{
3639*58b9f456SAndroid Build Coastguard Worker    return __str_find_last_not_of<value_type, size_type, traits_type, npos>
3640*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __str.data(), __pos, __str.size());
3641*58b9f456SAndroid Build Coastguard Worker}
3642*58b9f456SAndroid Build Coastguard Worker
3643*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3644*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
3645*58b9f456SAndroid Build Coastguard Workertypename enable_if
3646*58b9f456SAndroid Build Coastguard Worker<
3647*58b9f456SAndroid Build Coastguard Worker    __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
3648*58b9f456SAndroid Build Coastguard Worker    typename basic_string<_CharT, _Traits, _Allocator>::size_type
3649*58b9f456SAndroid Build Coastguard Worker>::type
3650*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const _Tp& __t,
3651*58b9f456SAndroid Build Coastguard Worker                                                size_type __pos) const
3652*58b9f456SAndroid Build Coastguard Worker{
3653*58b9f456SAndroid Build Coastguard Worker    __self_view __sv = __t;
3654*58b9f456SAndroid Build Coastguard Worker    return __str_find_last_not_of<value_type, size_type, traits_type, npos>
3655*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __sv.data(), __pos, __sv.size());
3656*58b9f456SAndroid Build Coastguard Worker}
3657*58b9f456SAndroid Build Coastguard Worker
3658*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3659*58b9f456SAndroid Build Coastguard Workerinline
3660*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3661*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s,
3662*58b9f456SAndroid Build Coastguard Worker                                                            size_type __pos) const _NOEXCEPT
3663*58b9f456SAndroid Build Coastguard Worker{
3664*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__s != nullptr, "string::find_last_not_of(): received nullptr");
3665*58b9f456SAndroid Build Coastguard Worker    return __str_find_last_not_of<value_type, size_type, traits_type, npos>
3666*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __s, __pos, traits_type::length(__s));
3667*58b9f456SAndroid Build Coastguard Worker}
3668*58b9f456SAndroid Build Coastguard Worker
3669*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3670*58b9f456SAndroid Build Coastguard Workerinline
3671*58b9f456SAndroid Build Coastguard Workertypename basic_string<_CharT, _Traits, _Allocator>::size_type
3672*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c,
3673*58b9f456SAndroid Build Coastguard Worker                                                            size_type __pos) const _NOEXCEPT
3674*58b9f456SAndroid Build Coastguard Worker{
3675*58b9f456SAndroid Build Coastguard Worker    return __str_find_last_not_of<value_type, size_type, traits_type, npos>
3676*58b9f456SAndroid Build Coastguard Worker        (data(), size(), __c, __pos);
3677*58b9f456SAndroid Build Coastguard Worker}
3678*58b9f456SAndroid Build Coastguard Worker
3679*58b9f456SAndroid Build Coastguard Worker// compare
3680*58b9f456SAndroid Build Coastguard Worker
3681*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3682*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
3683*58b9f456SAndroid Build Coastguard Workertypename enable_if
3684*58b9f456SAndroid Build Coastguard Worker<
3685*58b9f456SAndroid Build Coastguard Worker    __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
3686*58b9f456SAndroid Build Coastguard Worker    int
3687*58b9f456SAndroid Build Coastguard Worker>::type
3688*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const
3689*58b9f456SAndroid Build Coastguard Worker{
3690*58b9f456SAndroid Build Coastguard Worker    __self_view __sv = __t;
3691*58b9f456SAndroid Build Coastguard Worker    size_t __lhs_sz = size();
3692*58b9f456SAndroid Build Coastguard Worker    size_t __rhs_sz = __sv.size();
3693*58b9f456SAndroid Build Coastguard Worker    int __result = traits_type::compare(data(), __sv.data(),
3694*58b9f456SAndroid Build Coastguard Worker                                        _VSTD::min(__lhs_sz, __rhs_sz));
3695*58b9f456SAndroid Build Coastguard Worker    if (__result != 0)
3696*58b9f456SAndroid Build Coastguard Worker        return __result;
3697*58b9f456SAndroid Build Coastguard Worker    if (__lhs_sz < __rhs_sz)
3698*58b9f456SAndroid Build Coastguard Worker        return -1;
3699*58b9f456SAndroid Build Coastguard Worker    if (__lhs_sz > __rhs_sz)
3700*58b9f456SAndroid Build Coastguard Worker        return 1;
3701*58b9f456SAndroid Build Coastguard Worker    return 0;
3702*58b9f456SAndroid Build Coastguard Worker}
3703*58b9f456SAndroid Build Coastguard Worker
3704*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3705*58b9f456SAndroid Build Coastguard Workerinline
3706*58b9f456SAndroid Build Coastguard Workerint
3707*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT
3708*58b9f456SAndroid Build Coastguard Worker{
3709*58b9f456SAndroid Build Coastguard Worker    return compare(__self_view(__str));
3710*58b9f456SAndroid Build Coastguard Worker}
3711*58b9f456SAndroid Build Coastguard Worker
3712*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3713*58b9f456SAndroid Build Coastguard Workerint
3714*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
3715*58b9f456SAndroid Build Coastguard Worker                                                   size_type __n1,
3716*58b9f456SAndroid Build Coastguard Worker                                                   const value_type* __s,
3717*58b9f456SAndroid Build Coastguard Worker                                                   size_type __n2) const
3718*58b9f456SAndroid Build Coastguard Worker{
3719*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::compare(): received nullptr");
3720*58b9f456SAndroid Build Coastguard Worker    size_type __sz = size();
3721*58b9f456SAndroid Build Coastguard Worker    if (__pos1 > __sz || __n2 == npos)
3722*58b9f456SAndroid Build Coastguard Worker        this->__throw_out_of_range();
3723*58b9f456SAndroid Build Coastguard Worker    size_type __rlen = _VSTD::min(__n1, __sz - __pos1);
3724*58b9f456SAndroid Build Coastguard Worker    int __r = traits_type::compare(data() + __pos1, __s, _VSTD::min(__rlen, __n2));
3725*58b9f456SAndroid Build Coastguard Worker    if (__r == 0)
3726*58b9f456SAndroid Build Coastguard Worker    {
3727*58b9f456SAndroid Build Coastguard Worker        if (__rlen < __n2)
3728*58b9f456SAndroid Build Coastguard Worker            __r = -1;
3729*58b9f456SAndroid Build Coastguard Worker        else if (__rlen > __n2)
3730*58b9f456SAndroid Build Coastguard Worker            __r = 1;
3731*58b9f456SAndroid Build Coastguard Worker    }
3732*58b9f456SAndroid Build Coastguard Worker    return __r;
3733*58b9f456SAndroid Build Coastguard Worker}
3734*58b9f456SAndroid Build Coastguard Worker
3735*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3736*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
3737*58b9f456SAndroid Build Coastguard Workertypename enable_if
3738*58b9f456SAndroid Build Coastguard Worker<
3739*58b9f456SAndroid Build Coastguard Worker    __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
3740*58b9f456SAndroid Build Coastguard Worker    int
3741*58b9f456SAndroid Build Coastguard Worker>::type
3742*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
3743*58b9f456SAndroid Build Coastguard Worker                                                   size_type __n1,
3744*58b9f456SAndroid Build Coastguard Worker                                                   const _Tp& __t) const
3745*58b9f456SAndroid Build Coastguard Worker{
3746*58b9f456SAndroid Build Coastguard Worker    __self_view __sv = __t;
3747*58b9f456SAndroid Build Coastguard Worker    return compare(__pos1, __n1, __sv.data(), __sv.size());
3748*58b9f456SAndroid Build Coastguard Worker}
3749*58b9f456SAndroid Build Coastguard Worker
3750*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3751*58b9f456SAndroid Build Coastguard Workerinline
3752*58b9f456SAndroid Build Coastguard Workerint
3753*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
3754*58b9f456SAndroid Build Coastguard Worker                                                   size_type __n1,
3755*58b9f456SAndroid Build Coastguard Worker                                                   const basic_string& __str) const
3756*58b9f456SAndroid Build Coastguard Worker{
3757*58b9f456SAndroid Build Coastguard Worker    return compare(__pos1, __n1, __str.data(), __str.size());
3758*58b9f456SAndroid Build Coastguard Worker}
3759*58b9f456SAndroid Build Coastguard Worker
3760*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3761*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
3762*58b9f456SAndroid Build Coastguard Workertypename enable_if
3763*58b9f456SAndroid Build Coastguard Worker<
3764*58b9f456SAndroid Build Coastguard Worker    __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
3765*58b9f456SAndroid Build Coastguard Worker    int
3766*58b9f456SAndroid Build Coastguard Worker>::type
3767*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
3768*58b9f456SAndroid Build Coastguard Worker                                                   size_type __n1,
3769*58b9f456SAndroid Build Coastguard Worker                                                   const _Tp& __t,
3770*58b9f456SAndroid Build Coastguard Worker                                                   size_type __pos2,
3771*58b9f456SAndroid Build Coastguard Worker                                                   size_type __n2) const
3772*58b9f456SAndroid Build Coastguard Worker{
3773*58b9f456SAndroid Build Coastguard Worker    __self_view __sv = __t;
3774*58b9f456SAndroid Build Coastguard Worker    return __self_view(*this).substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
3775*58b9f456SAndroid Build Coastguard Worker}
3776*58b9f456SAndroid Build Coastguard Worker
3777*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3778*58b9f456SAndroid Build Coastguard Workerint
3779*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
3780*58b9f456SAndroid Build Coastguard Worker                                                   size_type __n1,
3781*58b9f456SAndroid Build Coastguard Worker                                                   const basic_string& __str,
3782*58b9f456SAndroid Build Coastguard Worker                                                   size_type __pos2,
3783*58b9f456SAndroid Build Coastguard Worker                                                   size_type __n2) const
3784*58b9f456SAndroid Build Coastguard Worker{
3785*58b9f456SAndroid Build Coastguard Worker        return compare(__pos1, __n1, __self_view(__str), __pos2, __n2);
3786*58b9f456SAndroid Build Coastguard Worker}
3787*58b9f456SAndroid Build Coastguard Worker
3788*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3789*58b9f456SAndroid Build Coastguard Workerint
3790*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT
3791*58b9f456SAndroid Build Coastguard Worker{
3792*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr");
3793*58b9f456SAndroid Build Coastguard Worker    return compare(0, npos, __s, traits_type::length(__s));
3794*58b9f456SAndroid Build Coastguard Worker}
3795*58b9f456SAndroid Build Coastguard Worker
3796*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
3797*58b9f456SAndroid Build Coastguard Workerint
3798*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
3799*58b9f456SAndroid Build Coastguard Worker                                                   size_type __n1,
3800*58b9f456SAndroid Build Coastguard Worker                                                   const value_type* __s) const
3801*58b9f456SAndroid Build Coastguard Worker{
3802*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr");
3803*58b9f456SAndroid Build Coastguard Worker    return compare(__pos1, __n1, __s, traits_type::length(__s));
3804*58b9f456SAndroid Build Coastguard Worker}
3805*58b9f456SAndroid Build Coastguard Worker
3806*58b9f456SAndroid Build Coastguard Worker// __invariants
3807*58b9f456SAndroid Build Coastguard Worker
3808*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3809*58b9f456SAndroid Build Coastguard Workerinline
3810*58b9f456SAndroid Build Coastguard Workerbool
3811*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::__invariants() const
3812*58b9f456SAndroid Build Coastguard Worker{
3813*58b9f456SAndroid Build Coastguard Worker    if (size() > capacity())
3814*58b9f456SAndroid Build Coastguard Worker        return false;
3815*58b9f456SAndroid Build Coastguard Worker    if (capacity() < __min_cap - 1)
3816*58b9f456SAndroid Build Coastguard Worker        return false;
3817*58b9f456SAndroid Build Coastguard Worker    if (data() == 0)
3818*58b9f456SAndroid Build Coastguard Worker        return false;
3819*58b9f456SAndroid Build Coastguard Worker    if (data()[size()] != value_type(0))
3820*58b9f456SAndroid Build Coastguard Worker        return false;
3821*58b9f456SAndroid Build Coastguard Worker    return true;
3822*58b9f456SAndroid Build Coastguard Worker}
3823*58b9f456SAndroid Build Coastguard Worker
3824*58b9f456SAndroid Build Coastguard Worker// __clear_and_shrink
3825*58b9f456SAndroid Build Coastguard Worker
3826*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3827*58b9f456SAndroid Build Coastguard Workerinline
3828*58b9f456SAndroid Build Coastguard Workervoid
3829*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT
3830*58b9f456SAndroid Build Coastguard Worker{
3831*58b9f456SAndroid Build Coastguard Worker    clear();
3832*58b9f456SAndroid Build Coastguard Worker    if(__is_long())
3833*58b9f456SAndroid Build Coastguard Worker    {
3834*58b9f456SAndroid Build Coastguard Worker        __alloc_traits::deallocate(__alloc(), __get_long_pointer(), capacity() + 1);
3835*58b9f456SAndroid Build Coastguard Worker        __set_long_cap(0);
3836*58b9f456SAndroid Build Coastguard Worker        __set_short_size(0);
3837*58b9f456SAndroid Build Coastguard Worker    }
3838*58b9f456SAndroid Build Coastguard Worker}
3839*58b9f456SAndroid Build Coastguard Worker
3840*58b9f456SAndroid Build Coastguard Worker// operator==
3841*58b9f456SAndroid Build Coastguard Worker
3842*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3843*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
3844*58b9f456SAndroid Build Coastguard Workerbool
3845*58b9f456SAndroid Build Coastguard Workeroperator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
3846*58b9f456SAndroid Build Coastguard Worker           const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
3847*58b9f456SAndroid Build Coastguard Worker{
3848*58b9f456SAndroid Build Coastguard Worker    size_t __lhs_sz = __lhs.size();
3849*58b9f456SAndroid Build Coastguard Worker    return __lhs_sz == __rhs.size() && _Traits::compare(__lhs.data(),
3850*58b9f456SAndroid Build Coastguard Worker                                                        __rhs.data(),
3851*58b9f456SAndroid Build Coastguard Worker                                                        __lhs_sz) == 0;
3852*58b9f456SAndroid Build Coastguard Worker}
3853*58b9f456SAndroid Build Coastguard Worker
3854*58b9f456SAndroid Build Coastguard Workertemplate<class _Allocator>
3855*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
3856*58b9f456SAndroid Build Coastguard Workerbool
3857*58b9f456SAndroid Build Coastguard Workeroperator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs,
3858*58b9f456SAndroid Build Coastguard Worker           const basic_string<char, char_traits<char>, _Allocator>& __rhs) _NOEXCEPT
3859*58b9f456SAndroid Build Coastguard Worker{
3860*58b9f456SAndroid Build Coastguard Worker    size_t __lhs_sz = __lhs.size();
3861*58b9f456SAndroid Build Coastguard Worker    if (__lhs_sz != __rhs.size())
3862*58b9f456SAndroid Build Coastguard Worker        return false;
3863*58b9f456SAndroid Build Coastguard Worker    const char* __lp = __lhs.data();
3864*58b9f456SAndroid Build Coastguard Worker    const char* __rp = __rhs.data();
3865*58b9f456SAndroid Build Coastguard Worker    if (__lhs.__is_long())
3866*58b9f456SAndroid Build Coastguard Worker        return char_traits<char>::compare(__lp, __rp, __lhs_sz) == 0;
3867*58b9f456SAndroid Build Coastguard Worker    for (; __lhs_sz != 0; --__lhs_sz, ++__lp, ++__rp)
3868*58b9f456SAndroid Build Coastguard Worker        if (*__lp != *__rp)
3869*58b9f456SAndroid Build Coastguard Worker            return false;
3870*58b9f456SAndroid Build Coastguard Worker    return true;
3871*58b9f456SAndroid Build Coastguard Worker}
3872*58b9f456SAndroid Build Coastguard Worker
3873*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3874*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
3875*58b9f456SAndroid Build Coastguard Workerbool
3876*58b9f456SAndroid Build Coastguard Workeroperator==(const _CharT* __lhs,
3877*58b9f456SAndroid Build Coastguard Worker           const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
3878*58b9f456SAndroid Build Coastguard Worker{
3879*58b9f456SAndroid Build Coastguard Worker    typedef basic_string<_CharT, _Traits, _Allocator> _String;
3880*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__lhs != nullptr, "operator==(char*, basic_string): received nullptr");
3881*58b9f456SAndroid Build Coastguard Worker    size_t __lhs_len = _Traits::length(__lhs);
3882*58b9f456SAndroid Build Coastguard Worker    if (__lhs_len != __rhs.size()) return false;
3883*58b9f456SAndroid Build Coastguard Worker    return __rhs.compare(0, _String::npos, __lhs, __lhs_len) == 0;
3884*58b9f456SAndroid Build Coastguard Worker}
3885*58b9f456SAndroid Build Coastguard Worker
3886*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3887*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
3888*58b9f456SAndroid Build Coastguard Workerbool
3889*58b9f456SAndroid Build Coastguard Workeroperator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
3890*58b9f456SAndroid Build Coastguard Worker           const _CharT* __rhs) _NOEXCEPT
3891*58b9f456SAndroid Build Coastguard Worker{
3892*58b9f456SAndroid Build Coastguard Worker    typedef basic_string<_CharT, _Traits, _Allocator> _String;
3893*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_ASSERT(__rhs != nullptr, "operator==(basic_string, char*): received nullptr");
3894*58b9f456SAndroid Build Coastguard Worker    size_t __rhs_len = _Traits::length(__rhs);
3895*58b9f456SAndroid Build Coastguard Worker    if (__rhs_len != __lhs.size()) return false;
3896*58b9f456SAndroid Build Coastguard Worker    return __lhs.compare(0, _String::npos, __rhs, __rhs_len) == 0;
3897*58b9f456SAndroid Build Coastguard Worker}
3898*58b9f456SAndroid Build Coastguard Worker
3899*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3900*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
3901*58b9f456SAndroid Build Coastguard Workerbool
3902*58b9f456SAndroid Build Coastguard Workeroperator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
3903*58b9f456SAndroid Build Coastguard Worker           const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
3904*58b9f456SAndroid Build Coastguard Worker{
3905*58b9f456SAndroid Build Coastguard Worker    return !(__lhs == __rhs);
3906*58b9f456SAndroid Build Coastguard Worker}
3907*58b9f456SAndroid Build Coastguard Worker
3908*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3909*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
3910*58b9f456SAndroid Build Coastguard Workerbool
3911*58b9f456SAndroid Build Coastguard Workeroperator!=(const _CharT* __lhs,
3912*58b9f456SAndroid Build Coastguard Worker           const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
3913*58b9f456SAndroid Build Coastguard Worker{
3914*58b9f456SAndroid Build Coastguard Worker    return !(__lhs == __rhs);
3915*58b9f456SAndroid Build Coastguard Worker}
3916*58b9f456SAndroid Build Coastguard Worker
3917*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3918*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
3919*58b9f456SAndroid Build Coastguard Workerbool
3920*58b9f456SAndroid Build Coastguard Workeroperator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
3921*58b9f456SAndroid Build Coastguard Worker           const _CharT* __rhs) _NOEXCEPT
3922*58b9f456SAndroid Build Coastguard Worker{
3923*58b9f456SAndroid Build Coastguard Worker    return !(__lhs == __rhs);
3924*58b9f456SAndroid Build Coastguard Worker}
3925*58b9f456SAndroid Build Coastguard Worker
3926*58b9f456SAndroid Build Coastguard Worker// operator<
3927*58b9f456SAndroid Build Coastguard Worker
3928*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3929*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
3930*58b9f456SAndroid Build Coastguard Workerbool
3931*58b9f456SAndroid Build Coastguard Workeroperator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
3932*58b9f456SAndroid Build Coastguard Worker           const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
3933*58b9f456SAndroid Build Coastguard Worker{
3934*58b9f456SAndroid Build Coastguard Worker    return __lhs.compare(__rhs) < 0;
3935*58b9f456SAndroid Build Coastguard Worker}
3936*58b9f456SAndroid Build Coastguard Worker
3937*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3938*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
3939*58b9f456SAndroid Build Coastguard Workerbool
3940*58b9f456SAndroid Build Coastguard Workeroperator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
3941*58b9f456SAndroid Build Coastguard Worker           const _CharT* __rhs) _NOEXCEPT
3942*58b9f456SAndroid Build Coastguard Worker{
3943*58b9f456SAndroid Build Coastguard Worker    return __lhs.compare(__rhs) < 0;
3944*58b9f456SAndroid Build Coastguard Worker}
3945*58b9f456SAndroid Build Coastguard Worker
3946*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3947*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
3948*58b9f456SAndroid Build Coastguard Workerbool
3949*58b9f456SAndroid Build Coastguard Workeroperator< (const _CharT* __lhs,
3950*58b9f456SAndroid Build Coastguard Worker           const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
3951*58b9f456SAndroid Build Coastguard Worker{
3952*58b9f456SAndroid Build Coastguard Worker    return __rhs.compare(__lhs) > 0;
3953*58b9f456SAndroid Build Coastguard Worker}
3954*58b9f456SAndroid Build Coastguard Worker
3955*58b9f456SAndroid Build Coastguard Worker// operator>
3956*58b9f456SAndroid Build Coastguard Worker
3957*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3958*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
3959*58b9f456SAndroid Build Coastguard Workerbool
3960*58b9f456SAndroid Build Coastguard Workeroperator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
3961*58b9f456SAndroid Build Coastguard Worker           const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
3962*58b9f456SAndroid Build Coastguard Worker{
3963*58b9f456SAndroid Build Coastguard Worker    return __rhs < __lhs;
3964*58b9f456SAndroid Build Coastguard Worker}
3965*58b9f456SAndroid Build Coastguard Worker
3966*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3967*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
3968*58b9f456SAndroid Build Coastguard Workerbool
3969*58b9f456SAndroid Build Coastguard Workeroperator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
3970*58b9f456SAndroid Build Coastguard Worker           const _CharT* __rhs) _NOEXCEPT
3971*58b9f456SAndroid Build Coastguard Worker{
3972*58b9f456SAndroid Build Coastguard Worker    return __rhs < __lhs;
3973*58b9f456SAndroid Build Coastguard Worker}
3974*58b9f456SAndroid Build Coastguard Worker
3975*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3976*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
3977*58b9f456SAndroid Build Coastguard Workerbool
3978*58b9f456SAndroid Build Coastguard Workeroperator> (const _CharT* __lhs,
3979*58b9f456SAndroid Build Coastguard Worker           const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
3980*58b9f456SAndroid Build Coastguard Worker{
3981*58b9f456SAndroid Build Coastguard Worker    return __rhs < __lhs;
3982*58b9f456SAndroid Build Coastguard Worker}
3983*58b9f456SAndroid Build Coastguard Worker
3984*58b9f456SAndroid Build Coastguard Worker// operator<=
3985*58b9f456SAndroid Build Coastguard Worker
3986*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3987*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
3988*58b9f456SAndroid Build Coastguard Workerbool
3989*58b9f456SAndroid Build Coastguard Workeroperator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
3990*58b9f456SAndroid Build Coastguard Worker           const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
3991*58b9f456SAndroid Build Coastguard Worker{
3992*58b9f456SAndroid Build Coastguard Worker    return !(__rhs < __lhs);
3993*58b9f456SAndroid Build Coastguard Worker}
3994*58b9f456SAndroid Build Coastguard Worker
3995*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
3996*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
3997*58b9f456SAndroid Build Coastguard Workerbool
3998*58b9f456SAndroid Build Coastguard Workeroperator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
3999*58b9f456SAndroid Build Coastguard Worker           const _CharT* __rhs) _NOEXCEPT
4000*58b9f456SAndroid Build Coastguard Worker{
4001*58b9f456SAndroid Build Coastguard Worker    return !(__rhs < __lhs);
4002*58b9f456SAndroid Build Coastguard Worker}
4003*58b9f456SAndroid Build Coastguard Worker
4004*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4005*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
4006*58b9f456SAndroid Build Coastguard Workerbool
4007*58b9f456SAndroid Build Coastguard Workeroperator<=(const _CharT* __lhs,
4008*58b9f456SAndroid Build Coastguard Worker           const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
4009*58b9f456SAndroid Build Coastguard Worker{
4010*58b9f456SAndroid Build Coastguard Worker    return !(__rhs < __lhs);
4011*58b9f456SAndroid Build Coastguard Worker}
4012*58b9f456SAndroid Build Coastguard Worker
4013*58b9f456SAndroid Build Coastguard Worker// operator>=
4014*58b9f456SAndroid Build Coastguard Worker
4015*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4016*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
4017*58b9f456SAndroid Build Coastguard Workerbool
4018*58b9f456SAndroid Build Coastguard Workeroperator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4019*58b9f456SAndroid Build Coastguard Worker           const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
4020*58b9f456SAndroid Build Coastguard Worker{
4021*58b9f456SAndroid Build Coastguard Worker    return !(__lhs < __rhs);
4022*58b9f456SAndroid Build Coastguard Worker}
4023*58b9f456SAndroid Build Coastguard Worker
4024*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4025*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
4026*58b9f456SAndroid Build Coastguard Workerbool
4027*58b9f456SAndroid Build Coastguard Workeroperator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4028*58b9f456SAndroid Build Coastguard Worker           const _CharT* __rhs) _NOEXCEPT
4029*58b9f456SAndroid Build Coastguard Worker{
4030*58b9f456SAndroid Build Coastguard Worker    return !(__lhs < __rhs);
4031*58b9f456SAndroid Build Coastguard Worker}
4032*58b9f456SAndroid Build Coastguard Worker
4033*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4034*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
4035*58b9f456SAndroid Build Coastguard Workerbool
4036*58b9f456SAndroid Build Coastguard Workeroperator>=(const _CharT* __lhs,
4037*58b9f456SAndroid Build Coastguard Worker           const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
4038*58b9f456SAndroid Build Coastguard Worker{
4039*58b9f456SAndroid Build Coastguard Worker    return !(__lhs < __rhs);
4040*58b9f456SAndroid Build Coastguard Worker}
4041*58b9f456SAndroid Build Coastguard Worker
4042*58b9f456SAndroid Build Coastguard Worker// operator +
4043*58b9f456SAndroid Build Coastguard Worker
4044*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4045*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>
4046*58b9f456SAndroid Build Coastguard Workeroperator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4047*58b9f456SAndroid Build Coastguard Worker          const basic_string<_CharT, _Traits, _Allocator>& __rhs)
4048*58b9f456SAndroid Build Coastguard Worker{
4049*58b9f456SAndroid Build Coastguard Worker    basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator());
4050*58b9f456SAndroid Build Coastguard Worker    typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size();
4051*58b9f456SAndroid Build Coastguard Worker    typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size();
4052*58b9f456SAndroid Build Coastguard Worker    __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz);
4053*58b9f456SAndroid Build Coastguard Worker    __r.append(__rhs.data(), __rhs_sz);
4054*58b9f456SAndroid Build Coastguard Worker    return __r;
4055*58b9f456SAndroid Build Coastguard Worker}
4056*58b9f456SAndroid Build Coastguard Worker
4057*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4058*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>
4059*58b9f456SAndroid Build Coastguard Workeroperator+(const _CharT* __lhs , const basic_string<_CharT,_Traits,_Allocator>& __rhs)
4060*58b9f456SAndroid Build Coastguard Worker{
4061*58b9f456SAndroid Build Coastguard Worker    basic_string<_CharT, _Traits, _Allocator> __r(__rhs.get_allocator());
4062*58b9f456SAndroid Build Coastguard Worker    typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = _Traits::length(__lhs);
4063*58b9f456SAndroid Build Coastguard Worker    typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size();
4064*58b9f456SAndroid Build Coastguard Worker    __r.__init(__lhs, __lhs_sz, __lhs_sz + __rhs_sz);
4065*58b9f456SAndroid Build Coastguard Worker    __r.append(__rhs.data(), __rhs_sz);
4066*58b9f456SAndroid Build Coastguard Worker    return __r;
4067*58b9f456SAndroid Build Coastguard Worker}
4068*58b9f456SAndroid Build Coastguard Worker
4069*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4070*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>
4071*58b9f456SAndroid Build Coastguard Workeroperator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Allocator>& __rhs)
4072*58b9f456SAndroid Build Coastguard Worker{
4073*58b9f456SAndroid Build Coastguard Worker    basic_string<_CharT, _Traits, _Allocator> __r(__rhs.get_allocator());
4074*58b9f456SAndroid Build Coastguard Worker    typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size();
4075*58b9f456SAndroid Build Coastguard Worker    __r.__init(&__lhs, 1, 1 + __rhs_sz);
4076*58b9f456SAndroid Build Coastguard Worker    __r.append(__rhs.data(), __rhs_sz);
4077*58b9f456SAndroid Build Coastguard Worker    return __r;
4078*58b9f456SAndroid Build Coastguard Worker}
4079*58b9f456SAndroid Build Coastguard Worker
4080*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4081*58b9f456SAndroid Build Coastguard Workerinline
4082*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>
4083*58b9f456SAndroid Build Coastguard Workeroperator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs)
4084*58b9f456SAndroid Build Coastguard Worker{
4085*58b9f456SAndroid Build Coastguard Worker    basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator());
4086*58b9f456SAndroid Build Coastguard Worker    typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size();
4087*58b9f456SAndroid Build Coastguard Worker    typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = _Traits::length(__rhs);
4088*58b9f456SAndroid Build Coastguard Worker    __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz);
4089*58b9f456SAndroid Build Coastguard Worker    __r.append(__rhs, __rhs_sz);
4090*58b9f456SAndroid Build Coastguard Worker    return __r;
4091*58b9f456SAndroid Build Coastguard Worker}
4092*58b9f456SAndroid Build Coastguard Worker
4093*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4094*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>
4095*58b9f456SAndroid Build Coastguard Workeroperator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs)
4096*58b9f456SAndroid Build Coastguard Worker{
4097*58b9f456SAndroid Build Coastguard Worker    basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator());
4098*58b9f456SAndroid Build Coastguard Worker    typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size();
4099*58b9f456SAndroid Build Coastguard Worker    __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + 1);
4100*58b9f456SAndroid Build Coastguard Worker    __r.push_back(__rhs);
4101*58b9f456SAndroid Build Coastguard Worker    return __r;
4102*58b9f456SAndroid Build Coastguard Worker}
4103*58b9f456SAndroid Build Coastguard Worker
4104*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
4105*58b9f456SAndroid Build Coastguard Worker
4106*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4107*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
4108*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>
4109*58b9f456SAndroid Build Coastguard Workeroperator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs)
4110*58b9f456SAndroid Build Coastguard Worker{
4111*58b9f456SAndroid Build Coastguard Worker    return _VSTD::move(__lhs.append(__rhs));
4112*58b9f456SAndroid Build Coastguard Worker}
4113*58b9f456SAndroid Build Coastguard Worker
4114*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4115*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
4116*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>
4117*58b9f456SAndroid Build Coastguard Workeroperator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs)
4118*58b9f456SAndroid Build Coastguard Worker{
4119*58b9f456SAndroid Build Coastguard Worker    return _VSTD::move(__rhs.insert(0, __lhs));
4120*58b9f456SAndroid Build Coastguard Worker}
4121*58b9f456SAndroid Build Coastguard Worker
4122*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4123*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
4124*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>
4125*58b9f456SAndroid Build Coastguard Workeroperator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs)
4126*58b9f456SAndroid Build Coastguard Worker{
4127*58b9f456SAndroid Build Coastguard Worker    return _VSTD::move(__lhs.append(__rhs));
4128*58b9f456SAndroid Build Coastguard Worker}
4129*58b9f456SAndroid Build Coastguard Worker
4130*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4131*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
4132*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>
4133*58b9f456SAndroid Build Coastguard Workeroperator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs)
4134*58b9f456SAndroid Build Coastguard Worker{
4135*58b9f456SAndroid Build Coastguard Worker    return _VSTD::move(__rhs.insert(0, __lhs));
4136*58b9f456SAndroid Build Coastguard Worker}
4137*58b9f456SAndroid Build Coastguard Worker
4138*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4139*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
4140*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>
4141*58b9f456SAndroid Build Coastguard Workeroperator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs)
4142*58b9f456SAndroid Build Coastguard Worker{
4143*58b9f456SAndroid Build Coastguard Worker    __rhs.insert(__rhs.begin(), __lhs);
4144*58b9f456SAndroid Build Coastguard Worker    return _VSTD::move(__rhs);
4145*58b9f456SAndroid Build Coastguard Worker}
4146*58b9f456SAndroid Build Coastguard Worker
4147*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4148*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
4149*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>
4150*58b9f456SAndroid Build Coastguard Workeroperator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs)
4151*58b9f456SAndroid Build Coastguard Worker{
4152*58b9f456SAndroid Build Coastguard Worker    return _VSTD::move(__lhs.append(__rhs));
4153*58b9f456SAndroid Build Coastguard Worker}
4154*58b9f456SAndroid Build Coastguard Worker
4155*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4156*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
4157*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>
4158*58b9f456SAndroid Build Coastguard Workeroperator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs)
4159*58b9f456SAndroid Build Coastguard Worker{
4160*58b9f456SAndroid Build Coastguard Worker    __lhs.push_back(__rhs);
4161*58b9f456SAndroid Build Coastguard Worker    return _VSTD::move(__lhs);
4162*58b9f456SAndroid Build Coastguard Worker}
4163*58b9f456SAndroid Build Coastguard Worker
4164*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
4165*58b9f456SAndroid Build Coastguard Worker
4166*58b9f456SAndroid Build Coastguard Worker// swap
4167*58b9f456SAndroid Build Coastguard Worker
4168*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4169*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
4170*58b9f456SAndroid Build Coastguard Workervoid
4171*58b9f456SAndroid Build Coastguard Workerswap(basic_string<_CharT, _Traits, _Allocator>& __lhs,
4172*58b9f456SAndroid Build Coastguard Worker     basic_string<_CharT, _Traits, _Allocator>& __rhs)
4173*58b9f456SAndroid Build Coastguard Worker     _NOEXCEPT_(_NOEXCEPT_(__lhs.swap(__rhs)))
4174*58b9f456SAndroid Build Coastguard Worker{
4175*58b9f456SAndroid Build Coastguard Worker    __lhs.swap(__rhs);
4176*58b9f456SAndroid Build Coastguard Worker}
4177*58b9f456SAndroid Build Coastguard Worker
4178*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_HAS_CHAR8_T
4179*58b9f456SAndroid Build Coastguard Workertypedef basic_string<char8_t> u8string;
4180*58b9f456SAndroid Build Coastguard Worker#endif
4181*58b9f456SAndroid Build Coastguard Worker
4182*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
4183*58b9f456SAndroid Build Coastguard Workertypedef basic_string<char16_t> u16string;
4184*58b9f456SAndroid Build Coastguard Workertypedef basic_string<char32_t> u32string;
4185*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
4186*58b9f456SAndroid Build Coastguard Worker
4187*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS int                stoi  (const string& __str, size_t* __idx = 0, int __base = 10);
4188*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS long               stol  (const string& __str, size_t* __idx = 0, int __base = 10);
4189*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS unsigned long      stoul (const string& __str, size_t* __idx = 0, int __base = 10);
4190*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS long long          stoll (const string& __str, size_t* __idx = 0, int __base = 10);
4191*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS unsigned long long stoull(const string& __str, size_t* __idx = 0, int __base = 10);
4192*58b9f456SAndroid Build Coastguard Worker
4193*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS float       stof (const string& __str, size_t* __idx = 0);
4194*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS double      stod (const string& __str, size_t* __idx = 0);
4195*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS long double stold(const string& __str, size_t* __idx = 0);
4196*58b9f456SAndroid Build Coastguard Worker
4197*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS string to_string(int __val);
4198*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS string to_string(unsigned __val);
4199*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS string to_string(long __val);
4200*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS string to_string(unsigned long __val);
4201*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS string to_string(long long __val);
4202*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS string to_string(unsigned long long __val);
4203*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS string to_string(float __val);
4204*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS string to_string(double __val);
4205*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS string to_string(long double __val);
4206*58b9f456SAndroid Build Coastguard Worker
4207*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS int                stoi  (const wstring& __str, size_t* __idx = 0, int __base = 10);
4208*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS long               stol  (const wstring& __str, size_t* __idx = 0, int __base = 10);
4209*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS unsigned long      stoul (const wstring& __str, size_t* __idx = 0, int __base = 10);
4210*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS long long          stoll (const wstring& __str, size_t* __idx = 0, int __base = 10);
4211*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS unsigned long long stoull(const wstring& __str, size_t* __idx = 0, int __base = 10);
4212*58b9f456SAndroid Build Coastguard Worker
4213*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS float       stof (const wstring& __str, size_t* __idx = 0);
4214*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS double      stod (const wstring& __str, size_t* __idx = 0);
4215*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS long double stold(const wstring& __str, size_t* __idx = 0);
4216*58b9f456SAndroid Build Coastguard Worker
4217*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS wstring to_wstring(int __val);
4218*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS wstring to_wstring(unsigned __val);
4219*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS wstring to_wstring(long __val);
4220*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS wstring to_wstring(unsigned long __val);
4221*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS wstring to_wstring(long long __val);
4222*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS wstring to_wstring(unsigned long long __val);
4223*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS wstring to_wstring(float __val);
4224*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS wstring to_wstring(double __val);
4225*58b9f456SAndroid Build Coastguard Worker_LIBCPP_FUNC_VIS wstring to_wstring(long double __val);
4226*58b9f456SAndroid Build Coastguard Worker
4227*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4228*58b9f456SAndroid Build Coastguard Worker    const typename basic_string<_CharT, _Traits, _Allocator>::size_type
4229*58b9f456SAndroid Build Coastguard Worker                   basic_string<_CharT, _Traits, _Allocator>::npos;
4230*58b9f456SAndroid Build Coastguard Worker
4231*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4232*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS hash<basic_string<_CharT, _Traits, _Allocator> >
4233*58b9f456SAndroid Build Coastguard Worker    : public unary_function<basic_string<_CharT, _Traits, _Allocator>, size_t>
4234*58b9f456SAndroid Build Coastguard Worker{
4235*58b9f456SAndroid Build Coastguard Worker    size_t
4236*58b9f456SAndroid Build Coastguard Worker        operator()(const basic_string<_CharT, _Traits, _Allocator>& __val) const _NOEXCEPT;
4237*58b9f456SAndroid Build Coastguard Worker};
4238*58b9f456SAndroid Build Coastguard Worker
4239*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4240*58b9f456SAndroid Build Coastguard Workersize_t
4241*58b9f456SAndroid Build Coastguard Workerhash<basic_string<_CharT, _Traits, _Allocator> >::operator()(
4242*58b9f456SAndroid Build Coastguard Worker        const basic_string<_CharT, _Traits, _Allocator>& __val) const _NOEXCEPT
4243*58b9f456SAndroid Build Coastguard Worker{
4244*58b9f456SAndroid Build Coastguard Worker    return __do_string_hash(__val.data(), __val.data() + __val.size());
4245*58b9f456SAndroid Build Coastguard Worker}
4246*58b9f456SAndroid Build Coastguard Worker
4247*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4248*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>&
4249*58b9f456SAndroid Build Coastguard Workeroperator<<(basic_ostream<_CharT, _Traits>& __os,
4250*58b9f456SAndroid Build Coastguard Worker           const basic_string<_CharT, _Traits, _Allocator>& __str);
4251*58b9f456SAndroid Build Coastguard Worker
4252*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4253*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
4254*58b9f456SAndroid Build Coastguard Workeroperator>>(basic_istream<_CharT, _Traits>& __is,
4255*58b9f456SAndroid Build Coastguard Worker           basic_string<_CharT, _Traits, _Allocator>& __str);
4256*58b9f456SAndroid Build Coastguard Worker
4257*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4258*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
4259*58b9f456SAndroid Build Coastguard Workergetline(basic_istream<_CharT, _Traits>& __is,
4260*58b9f456SAndroid Build Coastguard Worker        basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm);
4261*58b9f456SAndroid Build Coastguard Worker
4262*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4263*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
4264*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
4265*58b9f456SAndroid Build Coastguard Workergetline(basic_istream<_CharT, _Traits>& __is,
4266*58b9f456SAndroid Build Coastguard Worker        basic_string<_CharT, _Traits, _Allocator>& __str);
4267*58b9f456SAndroid Build Coastguard Worker
4268*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
4269*58b9f456SAndroid Build Coastguard Worker
4270*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4271*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
4272*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
4273*58b9f456SAndroid Build Coastguard Workergetline(basic_istream<_CharT, _Traits>&& __is,
4274*58b9f456SAndroid Build Coastguard Worker        basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm);
4275*58b9f456SAndroid Build Coastguard Worker
4276*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4277*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
4278*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>&
4279*58b9f456SAndroid Build Coastguard Workergetline(basic_istream<_CharT, _Traits>&& __is,
4280*58b9f456SAndroid Build Coastguard Worker        basic_string<_CharT, _Traits, _Allocator>& __str);
4281*58b9f456SAndroid Build Coastguard Worker
4282*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CXX03_LANG
4283*58b9f456SAndroid Build Coastguard Worker
4284*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 17
4285*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator, class _Up>
4286*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
4287*58b9f456SAndroid Build Coastguard Workervoid erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v)
4288*58b9f456SAndroid Build Coastguard Worker{ __str.erase(_VSTD::remove(__str.begin(), __str.end(), __v), __str.end()); }
4289*58b9f456SAndroid Build Coastguard Worker
4290*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator, class _Predicate>
4291*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
4292*58b9f456SAndroid Build Coastguard Workervoid erase_if(basic_string<_CharT, _Traits, _Allocator>& __str, _Predicate __pred)
4293*58b9f456SAndroid Build Coastguard Worker{ __str.erase(_VSTD::remove_if(__str.begin(), __str.end(), __pred), __str.end()); }
4294*58b9f456SAndroid Build Coastguard Worker#endif
4295*58b9f456SAndroid Build Coastguard Worker
4296*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_DEBUG_LEVEL >= 2
4297*58b9f456SAndroid Build Coastguard Worker
4298*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4299*58b9f456SAndroid Build Coastguard Workerbool
4300*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::__dereferenceable(const const_iterator* __i) const
4301*58b9f456SAndroid Build Coastguard Worker{
4302*58b9f456SAndroid Build Coastguard Worker    return this->data() <= _VSTD::__to_raw_pointer(__i->base()) &&
4303*58b9f456SAndroid Build Coastguard Worker           _VSTD::__to_raw_pointer(__i->base()) < this->data() + this->size();
4304*58b9f456SAndroid Build Coastguard Worker}
4305*58b9f456SAndroid Build Coastguard Worker
4306*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4307*58b9f456SAndroid Build Coastguard Workerbool
4308*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::__decrementable(const const_iterator* __i) const
4309*58b9f456SAndroid Build Coastguard Worker{
4310*58b9f456SAndroid Build Coastguard Worker    return this->data() < _VSTD::__to_raw_pointer(__i->base()) &&
4311*58b9f456SAndroid Build Coastguard Worker           _VSTD::__to_raw_pointer(__i->base()) <= this->data() + this->size();
4312*58b9f456SAndroid Build Coastguard Worker}
4313*58b9f456SAndroid Build Coastguard Worker
4314*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4315*58b9f456SAndroid Build Coastguard Workerbool
4316*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const
4317*58b9f456SAndroid Build Coastguard Worker{
4318*58b9f456SAndroid Build Coastguard Worker    const value_type* __p = _VSTD::__to_raw_pointer(__i->base()) + __n;
4319*58b9f456SAndroid Build Coastguard Worker    return this->data() <= __p && __p <= this->data() + this->size();
4320*58b9f456SAndroid Build Coastguard Worker}
4321*58b9f456SAndroid Build Coastguard Worker
4322*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator>
4323*58b9f456SAndroid Build Coastguard Workerbool
4324*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const
4325*58b9f456SAndroid Build Coastguard Worker{
4326*58b9f456SAndroid Build Coastguard Worker    const value_type* __p = _VSTD::__to_raw_pointer(__i->base()) + __n;
4327*58b9f456SAndroid Build Coastguard Worker    return this->data() <= __p && __p < this->data() + this->size();
4328*58b9f456SAndroid Build Coastguard Worker}
4329*58b9f456SAndroid Build Coastguard Worker
4330*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_DEBUG_LEVEL >= 2
4331*58b9f456SAndroid Build Coastguard Worker
4332*58b9f456SAndroid Build Coastguard Worker_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_string<char>)
4333*58b9f456SAndroid Build Coastguard Worker_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_string<wchar_t>)
4334*58b9f456SAndroid Build Coastguard Worker
4335*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 11
4336*58b9f456SAndroid Build Coastguard Worker// Literal suffixes for basic_string [basic.string.literals]
4337*58b9f456SAndroid Build Coastguard Workerinline namespace literals
4338*58b9f456SAndroid Build Coastguard Worker{
4339*58b9f456SAndroid Build Coastguard Worker  inline namespace string_literals
4340*58b9f456SAndroid Build Coastguard Worker  {
4341*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_INLINE_VISIBILITY
4342*58b9f456SAndroid Build Coastguard Worker    basic_string<char> operator "" s( const char *__str, size_t __len )
4343*58b9f456SAndroid Build Coastguard Worker    {
4344*58b9f456SAndroid Build Coastguard Worker        return basic_string<char> (__str, __len);
4345*58b9f456SAndroid Build Coastguard Worker    }
4346*58b9f456SAndroid Build Coastguard Worker
4347*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_INLINE_VISIBILITY
4348*58b9f456SAndroid Build Coastguard Worker    basic_string<wchar_t> operator "" s( const wchar_t *__str, size_t __len )
4349*58b9f456SAndroid Build Coastguard Worker    {
4350*58b9f456SAndroid Build Coastguard Worker        return basic_string<wchar_t> (__str, __len);
4351*58b9f456SAndroid Build Coastguard Worker    }
4352*58b9f456SAndroid Build Coastguard Worker
4353*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_HAS_CHAR8_T
4354*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_INLINE_VISIBILITY
4355*58b9f456SAndroid Build Coastguard Worker    basic_string<char8_t> operator "" s(const char8_t *__str, size_t __len) _NOEXCEPT
4356*58b9f456SAndroid Build Coastguard Worker    {
4357*58b9f456SAndroid Build Coastguard Worker        return basic_string<char8_t> (__str, __len);
4358*58b9f456SAndroid Build Coastguard Worker    }
4359*58b9f456SAndroid Build Coastguard Worker#endif
4360*58b9f456SAndroid Build Coastguard Worker
4361*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_INLINE_VISIBILITY
4362*58b9f456SAndroid Build Coastguard Worker    basic_string<char16_t> operator "" s( const char16_t *__str, size_t __len )
4363*58b9f456SAndroid Build Coastguard Worker    {
4364*58b9f456SAndroid Build Coastguard Worker        return basic_string<char16_t> (__str, __len);
4365*58b9f456SAndroid Build Coastguard Worker    }
4366*58b9f456SAndroid Build Coastguard Worker
4367*58b9f456SAndroid Build Coastguard Worker    inline _LIBCPP_INLINE_VISIBILITY
4368*58b9f456SAndroid Build Coastguard Worker    basic_string<char32_t> operator "" s( const char32_t *__str, size_t __len )
4369*58b9f456SAndroid Build Coastguard Worker    {
4370*58b9f456SAndroid Build Coastguard Worker        return basic_string<char32_t> (__str, __len);
4371*58b9f456SAndroid Build Coastguard Worker    }
4372*58b9f456SAndroid Build Coastguard Worker  }
4373*58b9f456SAndroid Build Coastguard Worker}
4374*58b9f456SAndroid Build Coastguard Worker#endif
4375*58b9f456SAndroid Build Coastguard Worker
4376*58b9f456SAndroid Build Coastguard Worker_LIBCPP_END_NAMESPACE_STD
4377*58b9f456SAndroid Build Coastguard Worker
4378*58b9f456SAndroid Build Coastguard Worker_LIBCPP_POP_MACROS
4379*58b9f456SAndroid Build Coastguard Worker
4380*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_STRING
4381