Cider Isn't Darwin Emulation, Really
Something went wrong. Try again.
152 kB · 4042 lines
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043// -*- C++ -*-//===--------------------------- string -----------------------------------===////// The LLVM Compiler Infrastructure//// This file is distributed under the University of Illinois Open Source// License. See LICENSE.TXT for details.////===----------------------------------------------------------------------===//#ifndef _LIBCPP_STRING#define _LIBCPP_STRING/* string synopsisnamespace std{template <class stateT>class fpos{private: stateT st;public: fpos(streamoff = streamoff()); operator streamoff() const; stateT state() const; void state(stateT); fpos& operator+=(streamoff); fpos operator+ (streamoff) const; fpos& operator-=(streamoff); fpos operator- (streamoff) const;};template <class stateT> streamoff operator-(const fpos<stateT>& x, const fpos<stateT>& y);template <class stateT> bool operator==(const fpos<stateT>& x, const fpos<stateT>& y);template <class stateT> bool operator!=(const fpos<stateT>& x, const fpos<stateT>& y);template <class charT>struct char_traits{ typedef charT char_type; typedef ... int_type; typedef streamoff off_type; typedef streampos pos_type; typedef mbstate_t state_type; static void assign(char_type& c1, const char_type& c2) noexcept; static constexpr bool eq(char_type c1, char_type c2) noexcept; static constexpr bool lt(char_type c1, char_type c2) noexcept; static int compare(const char_type* s1, const char_type* s2, size_t n); static size_t length(const char_type* s); static const char_type* find(const char_type* s, size_t n, const char_type& a); static char_type* move(char_type* s1, const char_type* s2, size_t n); static char_type* copy(char_type* s1, const char_type* s2, size_t n); static char_type* assign(char_type* s, size_t n, char_type a); static constexpr int_type not_eof(int_type c) noexcept; static constexpr char_type to_char_type(int_type c) noexcept; static constexpr int_type to_int_type(char_type c) noexcept; static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept; static constexpr int_type eof() noexcept;};template <> struct char_traits<char>;template <> struct char_traits<wchar_t>;template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >class basic_string{public:// types: typedef traits traits_type; typedef typename traits_type::char_type value_type; typedef Allocator allocator_type; typedef typename allocator_type::size_type size_type; typedef typename allocator_type::difference_type difference_type; typedef typename allocator_type::reference reference; typedef typename allocator_type::const_reference const_reference; typedef typename allocator_type::pointer pointer; typedef typename allocator_type::const_pointer const_pointer; typedef implementation-defined iterator; typedef implementation-defined const_iterator; typedef std::reverse_iterator<iterator> reverse_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator; static const size_type npos = -1; basic_string() noexcept(is_nothrow_default_constructible<allocator_type>::value); explicit basic_string(const allocator_type& a); basic_string(const basic_string& str); basic_string(basic_string&& str) noexcept(is_nothrow_move_constructible<allocator_type>::value); basic_string(const basic_string& str, size_type pos, const allocator_type& a = allocator_type()); basic_string(const basic_string& str, size_type pos, size_type n, const Allocator& a = Allocator()); template<class T> basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator()); // C++17 explicit basic_string(const basic_string_view<charT, traits> sv, const Allocator& a = Allocator()); basic_string(const value_type* s, const allocator_type& a = allocator_type()); basic_string(const value_type* s, size_type n, const allocator_type& a = allocator_type()); basic_string(size_type n, value_type c, const allocator_type& a = allocator_type()); template<class InputIterator> basic_string(InputIterator begin, InputIterator end, const allocator_type& a = allocator_type()); basic_string(initializer_list<value_type>, const Allocator& = Allocator()); basic_string(const basic_string&, const Allocator&); basic_string(basic_string&&, const Allocator&); ~basic_string(); operator basic_string_view<charT, traits>() const noexcept; basic_string& operator=(const basic_string& str); basic_string& operator=(basic_string_view<charT, traits> sv); basic_string& operator=(basic_string&& str) noexcept( allocator_type::propagate_on_container_move_assignment::value || allocator_type::is_always_equal::value ); // C++17 basic_string& operator=(const value_type* s); basic_string& operator=(value_type c); basic_string& operator=(initializer_list<value_type>); iterator begin() noexcept; const_iterator begin() const noexcept; iterator end() noexcept; const_iterator end() const noexcept; reverse_iterator rbegin() noexcept; const_reverse_iterator rbegin() const noexcept; reverse_iterator rend() noexcept; const_reverse_iterator rend() const noexcept; const_iterator cbegin() const noexcept; const_iterator cend() const noexcept; const_reverse_iterator crbegin() const noexcept; const_reverse_iterator crend() const noexcept; size_type size() const noexcept; size_type length() const noexcept; size_type max_size() const noexcept; size_type capacity() const noexcept; void resize(size_type n, value_type c); void resize(size_type n); void reserve(size_type res_arg = 0); void shrink_to_fit(); void clear() noexcept; bool empty() const noexcept; const_reference operator[](size_type pos) const; reference operator[](size_type pos); const_reference at(size_type n) const; reference at(size_type n); basic_string& operator+=(const basic_string& str); basic_string& operator+=(basic_string_view<charT, traits> sv); basic_string& operator+=(const value_type* s); basic_string& operator+=(value_type c); basic_string& operator+=(initializer_list<value_type>); basic_string& append(const basic_string& str); basic_string& append(basic_string_view<charT, traits> sv); basic_string& append(const basic_string& str, size_type pos, size_type n=npos); //C++14 template <class T> basic_string& append(const T& t, size_type pos, size_type n=npos); // C++17 basic_string& append(const value_type* s, size_type n); basic_string& append(const value_type* s); basic_string& append(size_type n, value_type c); template<class InputIterator> basic_string& append(InputIterator first, InputIterator last); basic_string& append(initializer_list<value_type>); void push_back(value_type c); void pop_back(); reference front(); const_reference front() const; reference back(); const_reference back() const; basic_string& assign(const basic_string& str); basic_string& assign(basic_string_view<charT, traits> sv); basic_string& assign(basic_string&& str); basic_string& assign(const basic_string& str, size_type pos, size_type n=npos); // C++14 template <class T> basic_string& assign(const T& t, size_type pos, size_type n=npos); // C++17 basic_string& assign(const value_type* s, size_type n); basic_string& assign(const value_type* s); basic_string& assign(size_type n, value_type c); template<class InputIterator> basic_string& assign(InputIterator first, InputIterator last); basic_string& assign(initializer_list<value_type>); basic_string& insert(size_type pos1, const basic_string& str); basic_string& insert(size_type pos1, basic_string_view<charT, traits> sv); basic_string& insert(size_type pos1, const basic_string& str, size_type pos2, size_type n); template <class T> basic_string& insert(size_type pos1, const T& t, size_type pos2, size_type n); // C++17 basic_string& insert(size_type pos, const value_type* s, size_type n=npos); //C++14 basic_string& insert(size_type pos, const value_type* s); basic_string& insert(size_type pos, size_type n, value_type c); iterator insert(const_iterator p, value_type c); iterator insert(const_iterator p, size_type n, value_type c); template<class InputIterator> iterator insert(const_iterator p, InputIterator first, InputIterator last); iterator insert(const_iterator p, initializer_list<value_type>); basic_string& erase(size_type pos = 0, size_type n = npos); iterator erase(const_iterator position); iterator erase(const_iterator first, const_iterator last); basic_string& replace(size_type pos1, size_type n1, const basic_string& str); basic_string& replace(size_type pos1, size_type n1, basic_string_view<charT, traits> sv); basic_string& replace(size_type pos1, size_type n1, const basic_string& str, size_type pos2, size_type n2=npos); // C++14 template <class T> basic_string& replace(size_type pos1, size_type n1, const T& t, size_type pos2, size_type n); // C++17 basic_string& replace(size_type pos, size_type n1, const value_type* s, size_type n2); basic_string& replace(size_type pos, size_type n1, const value_type* s); basic_string& replace(size_type pos, size_type n1, size_type n2, value_type c); basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str); basic_string& replace(const_iterator i1, const_iterator i2, basic_string_view<charT, traits> sv); basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s, size_type n); basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s); basic_string& replace(const_iterator i1, const_iterator i2, size_type n, value_type c); template<class InputIterator> basic_string& replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2); basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<value_type>); size_type copy(value_type* s, size_type n, size_type pos = 0) const; basic_string substr(size_type pos = 0, size_type n = npos) const; void swap(basic_string& str) noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value || allocator_traits<allocator_type>::is_always_equal::value); // C++17 const value_type* c_str() const noexcept; const value_type* data() const noexcept; value_type* data() noexcept; // C++17 allocator_type get_allocator() const noexcept; size_type find(const basic_string& str, size_type pos = 0) const noexcept; size_type find(basic_string_view<charT, traits> sv, size_type pos = 0) const noexcept; size_type find(const value_type* s, size_type pos, size_type n) const noexcept; size_type find(const value_type* s, size_type pos = 0) const noexcept; size_type find(value_type c, size_type pos = 0) const noexcept; size_type rfind(const basic_string& str, size_type pos = npos) const noexcept; size_type ffind(basic_string_view<charT, traits> sv, size_type pos = 0) const noexcept; size_type rfind(const value_type* s, size_type pos, size_type n) const noexcept; size_type rfind(const value_type* s, size_type pos = npos) const noexcept; size_type rfind(value_type c, size_type pos = npos) const noexcept; size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept; size_type find_first_of(basic_string_view<charT, traits> sv, size_type pos = 0) const noexcept; size_type find_first_of(const value_type* s, size_type pos, size_type n) const noexcept; size_type find_first_of(const value_type* s, size_type pos = 0) const noexcept; size_type find_first_of(value_type c, size_type pos = 0) const noexcept; size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept; size_type find_last_of(basic_string_view<charT, traits> sv, size_type pos = 0) const noexcept; size_type find_last_of(const value_type* s, size_type pos, size_type n) const noexcept; size_type find_last_of(const value_type* s, size_type pos = npos) const noexcept; size_type find_last_of(value_type c, size_type pos = npos) const noexcept; size_type find_first_not_of(const basic_string& str, size_type pos = 0) const noexcept; size_type find_first_not_of(basic_string_view<charT, traits> sv, size_type pos = 0) const noexcept; size_type find_first_not_of(const value_type* s, size_type pos, size_type n) const noexcept; size_type find_first_not_of(const value_type* s, size_type pos = 0) const noexcept; size_type find_first_not_of(value_type c, size_type pos = 0) const noexcept; size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept; size_type find_last_not_of(basic_string_view<charT, traits> sv, size_type pos = 0) const noexcept; size_type find_last_not_of(const value_type* s, size_type pos, size_type n) const noexcept; size_type find_last_not_of(const value_type* s, size_type pos = npos) const noexcept; size_type find_last_not_of(value_type c, size_type pos = npos) const noexcept; int compare(const basic_string& str) const noexcept; int compare(basic_string_view<charT, traits> sv) const noexcept; int compare(size_type pos1, size_type n1, const basic_string& str) const; int compare(size_type pos1, size_type n1, basic_string_view<charT, traits> sv) const; int compare(size_type pos1, size_type n1, const basic_string& str, size_type pos2, size_type n2=npos) const; // C++14 template <class T> int compare(size_type pos1, size_type n1, const T& t, size_type pos2, size_type n2=npos) const; // C++17 int compare(const value_type* s) const noexcept; int compare(size_type pos1, size_type n1, const value_type* s) const; int compare(size_type pos1, size_type n1, const value_type* s, size_type n2) const; bool __invariants() const;};template<class charT, class traits, class Allocator>basic_string<charT, traits, Allocator>operator+(const basic_string<charT, traits, Allocator>& lhs, const basic_string<charT, traits, Allocator>& rhs);template<class charT, class traits, class Allocator>basic_string<charT, traits, Allocator>operator+(const charT* lhs , const basic_string<charT,traits,Allocator>&rhs);template<class charT, class traits, class Allocator>basic_string<charT, traits, Allocator>operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs);template<class charT, class traits, class Allocator>basic_string<charT, traits, Allocator>operator+(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs);template<class charT, class traits, class Allocator>basic_string<charT, traits, Allocator>operator+(const basic_string<charT, traits, Allocator>& lhs, charT rhs);template<class charT, class traits, class Allocator>bool operator==(const basic_string<charT, traits, Allocator>& lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;template<class charT, class traits, class Allocator>bool operator==(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;template<class charT, class traits, class Allocator>bool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs) noexcept;template<class charT, class traits, class Allocator>bool operator!=(const basic_string<charT,traits,Allocator>& lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;template<class charT, class traits, class Allocator>bool operator!=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;template<class charT, class traits, class Allocator>bool operator!=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;template<class charT, class traits, class Allocator>bool operator< (const basic_string<charT, traits, Allocator>& lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;template<class charT, class traits, class Allocator>bool operator< (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;template<class charT, class traits, class Allocator>bool operator< (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;template<class charT, class traits, class Allocator>bool operator> (const basic_string<charT, traits, Allocator>& lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;template<class charT, class traits, class Allocator>bool operator> (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;template<class charT, class traits, class Allocator>bool operator> (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;template<class charT, class traits, class Allocator>bool operator<=(const basic_string<charT, traits, Allocator>& lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;template<class charT, class traits, class Allocator>bool operator<=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;template<class charT, class traits, class Allocator>bool operator<=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;template<class charT, class traits, class Allocator>bool operator>=(const basic_string<charT, traits, Allocator>& lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;template<class charT, class traits, class Allocator>bool operator>=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;template<class charT, class traits, class Allocator>bool operator>=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;template<class charT, class traits, class Allocator>void swap(basic_string<charT, traits, Allocator>& lhs, basic_string<charT, traits, Allocator>& rhs) noexcept(noexcept(lhs.swap(rhs)));template<class charT, class traits, class Allocator>basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str);template<class charT, class traits, class Allocator>basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const basic_string<charT, traits, Allocator>& str);template<class charT, class traits, class Allocator>basic_istream<charT, traits>&getline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str, charT delim);template<class charT, class traits, class Allocator>basic_istream<charT, traits>&getline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str);typedef basic_string<char> string;typedef basic_string<wchar_t> wstring;typedef basic_string<char16_t> u16string;typedef basic_string<char32_t> u32string;int stoi (const string& str, size_t* idx = 0, int base = 10);long stol (const string& str, size_t* idx = 0, int base = 10);unsigned long stoul (const string& str, size_t* idx = 0, int base = 10);long long stoll (const string& str, size_t* idx = 0, int base = 10);unsigned long long stoull(const string& str, size_t* idx = 0, int base = 10);float stof (const string& str, size_t* idx = 0);double stod (const string& str, size_t* idx = 0);long double stold(const string& str, size_t* idx = 0);string to_string(int val);string to_string(unsigned val);string to_string(long val);string to_string(unsigned long val);string to_string(long long val);string to_string(unsigned long long val);string to_string(float val);string to_string(double val);string to_string(long double val);int stoi (const wstring& str, size_t* idx = 0, int base = 10);long stol (const wstring& str, size_t* idx = 0, int base = 10);unsigned long stoul (const wstring& str, size_t* idx = 0, int base = 10);long long stoll (const wstring& str, size_t* idx = 0, int base = 10);unsigned long long stoull(const wstring& str, size_t* idx = 0, int base = 10);float stof (const wstring& str, size_t* idx = 0);double stod (const wstring& str, size_t* idx = 0);long double stold(const wstring& str, size_t* idx = 0);wstring to_wstring(int val);wstring to_wstring(unsigned val);wstring to_wstring(long val);wstring to_wstring(unsigned long val);wstring to_wstring(long long val);wstring to_wstring(unsigned long long val);wstring to_wstring(float val);wstring to_wstring(double val);wstring to_wstring(long double val);template <> struct hash<string>;template <> struct hash<u16string>;template <> struct hash<u32string>;template <> struct hash<wstring>;basic_string<char> operator "" s( const char *str, size_t len ); // C++14basic_string<wchar_t> operator "" s( const wchar_t *str, size_t len ); // C++14basic_string<char16_t> operator "" s( const char16_t *str, size_t len ); // C++14basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++14} // std*/#include <__config>#include <string_view>#include <iosfwd>#include <cstring>#include <cstdio> // For EOF.#include <cwchar>#include <algorithm>#include <iterator>#include <utility>#include <memory>#include <stdexcept>#include <type_traits>#include <initializer_list>#include <__functional_base>#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS#include <cstdint>#endif#include <__debug>#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)#pragma GCC system_header#endif_LIBCPP_PUSH_MACROS#include <__undef_macros>_LIBCPP_BEGIN_NAMESPACE_STD// fpostemplate <class _StateT>class _LIBCPP_TEMPLATE_VIS fpos{private: _StateT __st_; streamoff __off_;public: _LIBCPP_INLINE_VISIBILITY fpos(streamoff __off = streamoff()) : __st_(), __off_(__off) {} _LIBCPP_INLINE_VISIBILITY operator streamoff() const {return __off_;} _LIBCPP_INLINE_VISIBILITY _StateT state() const {return __st_;} _LIBCPP_INLINE_VISIBILITY void state(_StateT __st) {__st_ = __st;} _LIBCPP_INLINE_VISIBILITY fpos& operator+=(streamoff __off) {__off_ += __off; return *this;} _LIBCPP_INLINE_VISIBILITY fpos operator+ (streamoff __off) const {fpos __t(*this); __t += __off; return __t;} _LIBCPP_INLINE_VISIBILITY fpos& operator-=(streamoff __off) {__off_ -= __off; return *this;} _LIBCPP_INLINE_VISIBILITY fpos operator- (streamoff __off) const {fpos __t(*this); __t -= __off; return __t;}};template <class _StateT>inline _LIBCPP_INLINE_VISIBILITYstreamoff operator-(const fpos<_StateT>& __x, const fpos<_StateT>& __y) {return streamoff(__x) - streamoff(__y);}template <class _StateT>inline _LIBCPP_INLINE_VISIBILITYbool operator==(const fpos<_StateT>& __x, const fpos<_StateT>& __y) {return streamoff(__x) == streamoff(__y);}template <class _StateT>inline _LIBCPP_INLINE_VISIBILITYbool operator!=(const fpos<_StateT>& __x, const fpos<_StateT>& __y) {return streamoff(__x) != streamoff(__y);}// basic_stringtemplate<class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const basic_string<_CharT, _Traits, _Allocator>& __y);template<class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>operator+(const _CharT* __x, const basic_string<_CharT,_Traits,_Allocator>& __y);template<class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>operator+(_CharT __x, const basic_string<_CharT,_Traits,_Allocator>& __y);template<class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const _CharT* __y);template<class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y);_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&))template <bool>class _LIBCPP_TEMPLATE_VIS __basic_string_common{protected: _LIBCPP_NORETURN void __throw_length_error() const; _LIBCPP_NORETURN void __throw_out_of_range() const;};template <bool __b>void__basic_string_common<__b>::__throw_length_error() const{ _VSTD::__throw_length_error("basic_string");}template <bool __b>void__basic_string_common<__b>::__throw_out_of_range() const{ _VSTD::__throw_out_of_range("basic_string");}_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __basic_string_common<true>)#ifdef _LIBCPP_NO_EXCEPTIONStemplate <class _Iter>struct __libcpp_string_gets_noexcept_iterator_impl : public true_type {};#elif defined(_LIBCPP_HAS_NO_NOEXCEPT)template <class _Iter>struct __libcpp_string_gets_noexcept_iterator_impl : public false_type {};#elsetemplate <class _Iter, bool = __is_forward_iterator<_Iter>::value>struct __libcpp_string_gets_noexcept_iterator_impl : public _LIBCPP_BOOL_CONSTANT(( noexcept(++(declval<_Iter&>())) && is_nothrow_assignable<_Iter&, _Iter>::value && noexcept(declval<_Iter>() == declval<_Iter>()) && noexcept(*declval<_Iter>()))) {};template <class _Iter> struct __libcpp_string_gets_noexcept_iterator_impl<_Iter, false> : public false_type {};#endiftemplate <class _Iter>struct __libcpp_string_gets_noexcept_iterator : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value || __libcpp_string_gets_noexcept_iterator_impl<_Iter>::value) {};template <class _CharT, class _Traits, class _Tp>struct __can_be_converted_to_string_view : public _LIBCPP_BOOL_CONSTANT( ( is_convertible<const _Tp&, basic_string_view<_CharT, _Traits> >::value && !is_convertible<const _Tp&, const _CharT*>::value)) {};#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUTtemplate <class _CharT, size_t = sizeof(_CharT)>struct __padding{ unsigned char __xx[sizeof(_CharT)-1];};template <class _CharT>struct __padding<_CharT, 1>{};#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUTtemplate<class _CharT, class _Traits, class _Allocator>class _LIBCPP_TEMPLATE_VIS basic_string : private __basic_string_common<true>{public: typedef basic_string __self; typedef basic_string_view<_CharT, _Traits> __self_view; typedef _Traits traits_type; typedef _CharT value_type; typedef _Allocator allocator_type; typedef allocator_traits<allocator_type> __alloc_traits; typedef typename __alloc_traits::size_type size_type; typedef typename __alloc_traits::difference_type difference_type; typedef value_type& reference; typedef const value_type& const_reference; typedef typename __alloc_traits::pointer pointer; typedef typename __alloc_traits::const_pointer const_pointer; static_assert(is_pod<value_type>::value, "Character type of basic_string must be a POD"); static_assert((is_same<_CharT, typename traits_type::char_type>::value), "traits_type::char_type must be the same type as CharT"); static_assert((is_same<typename allocator_type::value_type, value_type>::value), "Allocator::value_type must be same type as value_type");#if defined(_LIBCPP_RAW_ITERATORS) typedef pointer iterator; typedef const_pointer const_iterator;#else // defined(_LIBCPP_RAW_ITERATORS) typedef __wrap_iter<pointer> iterator; typedef __wrap_iter<const_pointer> const_iterator;#endif // defined(_LIBCPP_RAW_ITERATORS) typedef _VSTD::reverse_iterator<iterator> reverse_iterator; typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;private:#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT struct __long { pointer __data_; size_type __size_; size_type __cap_; };#if _LIBCPP_BIG_ENDIAN static const size_type __short_mask = 0x01; static const size_type __long_mask = 0x1ul;#else // _LIBCPP_BIG_ENDIAN static const size_type __short_mask = 0x80; static const size_type __long_mask = ~(size_type(~0) >> 1);#endif // _LIBCPP_BIG_ENDIAN enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ? (sizeof(__long) - 1)/sizeof(value_type) : 2}; struct __short { value_type __data_[__min_cap]; struct : __padding<value_type> { unsigned char __size_; }; };#else struct __long { size_type __cap_; size_type __size_; pointer __data_; };#if _LIBCPP_BIG_ENDIAN static const size_type __short_mask = 0x80; static const size_type __long_mask = ~(size_type(~0) >> 1);#else // _LIBCPP_BIG_ENDIAN static const size_type __short_mask = 0x01; static const size_type __long_mask = 0x1ul;#endif // _LIBCPP_BIG_ENDIAN enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ? (sizeof(__long) - 1)/sizeof(value_type) : 2}; struct __short { union { unsigned char __size_; value_type __lx; }; value_type __data_[__min_cap]; };#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT union __ulx{__long __lx; __short __lxx;}; enum {__n_words = sizeof(__ulx) / sizeof(size_type)}; struct __raw { size_type __words[__n_words]; }; struct __rep { union { __long __l; __short __s; __raw __r; }; }; __compressed_pair<__rep, allocator_type> __r_;public: static const size_type npos = -1; _LIBCPP_INLINE_VISIBILITY basic_string() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value); _LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a)#if _LIBCPP_STD_VER <= 14 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);#else _NOEXCEPT;#endif basic_string(const basic_string& __str); basic_string(const basic_string& __str, const allocator_type& __a);#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY basic_string(basic_string&& __str)#if _LIBCPP_STD_VER <= 14 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);#else _NOEXCEPT;#endif _LIBCPP_INLINE_VISIBILITY basic_string(basic_string&& __str, const allocator_type& __a);#endif // _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY basic_string(const _CharT* __s); _LIBCPP_INLINE_VISIBILITY basic_string(const _CharT* __s, const _Allocator& __a); _LIBCPP_INLINE_VISIBILITY basic_string(const _CharT* __s, size_type __n); _LIBCPP_INLINE_VISIBILITY basic_string(const _CharT* __s, size_type __n, const _Allocator& __a); _LIBCPP_INLINE_VISIBILITY basic_string(size_type __n, _CharT __c); _LIBCPP_INLINE_VISIBILITY basic_string(size_type __n, _CharT __c, const _Allocator& __a); basic_string(const basic_string& __str, size_type __pos, size_type __n, const _Allocator& __a = _Allocator()); _LIBCPP_INLINE_VISIBILITY basic_string(const basic_string& __str, size_type __pos, const _Allocator& __a = _Allocator()); template<class _Tp> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS basic_string(const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a = allocator_type(), typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type* = 0); _LIBCPP_INLINE_VISIBILITY explicit basic_string(__self_view __sv); _LIBCPP_INLINE_VISIBILITY basic_string(__self_view __sv, const _Allocator& __a); template<class _InputIterator> _LIBCPP_INLINE_VISIBILITY basic_string(_InputIterator __first, _InputIterator __last); template<class _InputIterator> _LIBCPP_INLINE_VISIBILITY basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a);#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY basic_string(initializer_list<_CharT> __il); _LIBCPP_INLINE_VISIBILITY basic_string(initializer_list<_CharT> __il, const _Allocator& __a);#endif // _LIBCPP_CXX03_LANG inline ~basic_string(); _LIBCPP_INLINE_VISIBILITY operator __self_view() const _NOEXCEPT { return __self_view(data(), size()); } basic_string& operator=(const basic_string& __str);#ifndef _LIBCPP_CXX03_LANG template <class = void>#endif _LIBCPP_INLINE_VISIBILITY basic_string& operator=(__self_view __sv) {return assign(__sv);}#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY basic_string& operator=(basic_string&& __str) _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); _LIBCPP_INLINE_VISIBILITY basic_string& operator=(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());}#endif _LIBCPP_INLINE_VISIBILITY basic_string& operator=(const value_type* __s) {return assign(__s);} basic_string& operator=(value_type __c);#if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return iterator(this, __get_pointer());} _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return const_iterator(this, __get_pointer());} _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return iterator(this, __get_pointer() + size());} _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return const_iterator(this, __get_pointer() + size());}#else _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return iterator(__get_pointer());} _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return const_iterator(__get_pointer());} _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return iterator(__get_pointer() + size());} _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return const_iterator(__get_pointer() + size());}#endif // _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());} _LIBCPP_INLINE_VISIBILITY reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());} _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());} _LIBCPP_INLINE_VISIBILITY const_iterator cbegin() const _NOEXCEPT {return begin();} _LIBCPP_INLINE_VISIBILITY const_iterator cend() const _NOEXCEPT {return end();} _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crend() const _NOEXCEPT {return rend();} _LIBCPP_INLINE_VISIBILITY size_type size() const _NOEXCEPT {return __is_long() ? __get_long_size() : __get_short_size();} _LIBCPP_INLINE_VISIBILITY size_type length() const _NOEXCEPT {return size();} _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type capacity() const _NOEXCEPT {return (__is_long() ? __get_long_cap() : static_cast<size_type>(__min_cap)) - 1;} void resize(size_type __n, value_type __c); _LIBCPP_INLINE_VISIBILITY void resize(size_type __n) {resize(__n, value_type());} void reserve(size_type __res_arg = 0); _LIBCPP_INLINE_VISIBILITY void shrink_to_fit() _NOEXCEPT {reserve();} _LIBCPP_INLINE_VISIBILITY void clear() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY bool empty() const _NOEXCEPT {return size() == 0;} _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __pos) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __pos) _NOEXCEPT; const_reference at(size_type __n) const; reference at(size_type __n); _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const basic_string& __str) {return append(__str);} _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(__self_view __sv) {return append(__sv);} _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const value_type* __s) {return append(__s);} _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(value_type __c) {push_back(__c); return *this;}#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(initializer_list<value_type> __il) {return append(__il);}#endif // _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY basic_string& append(const basic_string& __str); _LIBCPP_INLINE_VISIBILITY basic_string& append(__self_view __sv) { return append(__sv.data(), __sv.size()); } basic_string& append(const basic_string& __str, size_type __pos, size_type __n=npos); template <class _Tp> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS typename enable_if < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, basic_string& >::type append(const _Tp& __t, size_type __pos, size_type __n=npos); basic_string& append(const value_type* __s, size_type __n); basic_string& append(const value_type* __s); basic_string& append(size_type __n, value_type __c); template <class _ForwardIterator> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS basic_string& __append_forward_unsafe(_ForwardIterator, _ForwardIterator); template<class _InputIterator> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS typename enable_if < __is_exactly_input_iterator<_InputIterator>::value || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, basic_string& >::type _LIBCPP_INLINE_VISIBILITY append(_InputIterator __first, _InputIterator __last) { const basic_string __temp (__first, __last, __alloc()); append(__temp.data(), __temp.size()); return *this; } template<class _ForwardIterator> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS typename enable_if < __is_forward_iterator<_ForwardIterator>::value && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, basic_string& >::type _LIBCPP_INLINE_VISIBILITY append(_ForwardIterator __first, _ForwardIterator __last) { return __append_forward_unsafe(__first, __last); }#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY basic_string& append(initializer_list<value_type> __il) {return append(__il.begin(), __il.size());}#endif // _LIBCPP_CXX03_LANG void push_back(value_type __c); _LIBCPP_INLINE_VISIBILITY void pop_back(); _LIBCPP_INLINE_VISIBILITY reference front(); _LIBCPP_INLINE_VISIBILITY const_reference front() const; _LIBCPP_INLINE_VISIBILITY reference back(); _LIBCPP_INLINE_VISIBILITY const_reference back() const; _LIBCPP_INLINE_VISIBILITY basic_string& assign(__self_view __sv) { return assign(__sv.data(), __sv.size()); } _LIBCPP_INLINE_VISIBILITY basic_string& assign(const basic_string& __str) { return *this = __str; }#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY basic_string& assign(basic_string&& __str) _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) {*this = _VSTD::move(__str); return *this;}#endif basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos); template <class _Tp> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS typename enable_if < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, basic_string& >::type assign(const _Tp & __t, size_type __pos, size_type __n=npos); basic_string& assign(const value_type* __s, size_type __n); basic_string& assign(const value_type* __s); basic_string& assign(size_type __n, value_type __c); template<class _InputIterator> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS typename enable_if < __is_exactly_input_iterator<_InputIterator>::value || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, basic_string& >::type assign(_InputIterator __first, _InputIterator __last); template<class _ForwardIterator> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS typename enable_if < __is_forward_iterator<_ForwardIterator>::value && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, basic_string& >::type assign(_ForwardIterator __first, _ForwardIterator __last);#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY basic_string& assign(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());}#endif // _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY basic_string& insert(size_type __pos1, const basic_string& __str); _LIBCPP_INLINE_VISIBILITY basic_string& insert(size_type __pos1, __self_view __sv) { return insert(__pos1, __sv.data(), __sv.size()); } template <class _Tp> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS typename enable_if < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, basic_string& >::type insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n=npos); basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n=npos); basic_string& insert(size_type __pos, const value_type* __s, size_type __n); basic_string& insert(size_type __pos, const value_type* __s); basic_string& insert(size_type __pos, size_type __n, value_type __c); iterator insert(const_iterator __pos, value_type __c); _LIBCPP_INLINE_VISIBILITY iterator insert(const_iterator __pos, size_type __n, value_type __c); template<class _InputIterator> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS typename enable_if < __is_exactly_input_iterator<_InputIterator>::value || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, iterator >::type insert(const_iterator __pos, _InputIterator __first, _InputIterator __last); template<class _ForwardIterator> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS typename enable_if < __is_forward_iterator<_ForwardIterator>::value && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, iterator >::type insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last);#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY iterator insert(const_iterator __pos, initializer_list<value_type> __il) {return insert(__pos, __il.begin(), __il.end());}#endif // _LIBCPP_CXX03_LANG basic_string& erase(size_type __pos = 0, size_type __n = npos); _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __pos); _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __first, const_iterator __last); _LIBCPP_INLINE_VISIBILITY basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str); _LIBCPP_INLINE_VISIBILITY basic_string& replace(size_type __pos1, size_type __n1, __self_view __sv) { return replace(__pos1, __n1, __sv.data(), __sv.size()); } basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos); template <class _Tp> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS typename enable_if < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, basic_string& >::type replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos); basic_string& replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2); basic_string& replace(size_type __pos, size_type __n1, const value_type* __s); basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c); _LIBCPP_INLINE_VISIBILITY basic_string& replace(const_iterator __i1, const_iterator __i2, const basic_string& __str); _LIBCPP_INLINE_VISIBILITY basic_string& replace(const_iterator __i1, const_iterator __i2, __self_view __sv) { return replace(__i1 - begin(), __i2 - __i1, __sv); } _LIBCPP_INLINE_VISIBILITY basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n); _LIBCPP_INLINE_VISIBILITY basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s); _LIBCPP_INLINE_VISIBILITY basic_string& replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c); template<class _InputIterator> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS typename enable_if < __is_input_iterator<_InputIterator>::value, basic_string& >::type replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2);#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY basic_string& replace(const_iterator __i1, const_iterator __i2, initializer_list<value_type> __il) {return replace(__i1, __i2, __il.begin(), __il.end());}#endif // _LIBCPP_CXX03_LANG size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const; _LIBCPP_INLINE_VISIBILITY basic_string substr(size_type __pos = 0, size_type __n = npos) const; _LIBCPP_INLINE_VISIBILITY void swap(basic_string& __str)#if _LIBCPP_STD_VER >= 14 _NOEXCEPT_DEBUG;#else _NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value);#endif _LIBCPP_INLINE_VISIBILITY const value_type* c_str() const _NOEXCEPT {return data();} _LIBCPP_INLINE_VISIBILITY const value_type* data() const _NOEXCEPT {return _VSTD::__to_raw_pointer(__get_pointer());}#if _LIBCPP_STD_VER > 14 _LIBCPP_INLINE_VISIBILITY value_type* data() _NOEXCEPT {return _VSTD::__to_raw_pointer(__get_pointer());}#endif _LIBCPP_INLINE_VISIBILITY allocator_type get_allocator() const _NOEXCEPT {return __alloc();} _LIBCPP_INLINE_VISIBILITY size_type find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find(__self_view __sv, size_type __pos = 0) const _NOEXCEPT; size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type rfind(__self_view __sv, size_type __pos = 0) const _NOEXCEPT; size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_first_of(__self_view __sv, size_type __pos = 0) const _NOEXCEPT; size_type find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_last_of(__self_view __sv, size_type __pos = 0) const _NOEXCEPT; size_type find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(__self_view __sv, size_type __pos = 0) const _NOEXCEPT; size_type find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(__self_view __sv, size_type __pos = 0) const _NOEXCEPT; size_type find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY int compare(const basic_string& __str) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY int compare(__self_view __sv) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY int compare(size_type __pos1, size_type __n1, __self_view __sv) const; _LIBCPP_INLINE_VISIBILITY int compare(size_type __pos1, size_type __n1, const basic_string& __str) const; int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos) const; template <class _Tp> inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int >::type compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos) const; int compare(const value_type* __s) const _NOEXCEPT; int compare(size_type __pos1, size_type __n1, const value_type* __s) const; int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const; _LIBCPP_INLINE_VISIBILITY bool __invariants() const; _LIBCPP_INLINE_VISIBILITY bool __is_long() const _NOEXCEPT {return bool(__r_.first().__s.__size_ & __short_mask);}#if _LIBCPP_DEBUG_LEVEL >= 2 bool __dereferenceable(const const_iterator* __i) const; bool __decrementable(const const_iterator* __i) const; bool __addable(const const_iterator* __i, ptrdiff_t __n) const; bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;#endif // _LIBCPP_DEBUG_LEVEL >= 2private: _LIBCPP_INLINE_VISIBILITY allocator_type& __alloc() _NOEXCEPT {return __r_.second();} _LIBCPP_INLINE_VISIBILITY const allocator_type& __alloc() const _NOEXCEPT {return __r_.second();}#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT _LIBCPP_INLINE_VISIBILITY void __set_short_size(size_type __s) _NOEXCEPT# if _LIBCPP_BIG_ENDIAN {__r_.first().__s.__size_ = (unsigned char)(__s << 1);}# else {__r_.first().__s.__size_ = (unsigned char)(__s);}# endif _LIBCPP_INLINE_VISIBILITY size_type __get_short_size() const _NOEXCEPT# if _LIBCPP_BIG_ENDIAN {return __r_.first().__s.__size_ >> 1;}# else {return __r_.first().__s.__size_;}# endif#else // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT _LIBCPP_INLINE_VISIBILITY void __set_short_size(size_type __s) _NOEXCEPT# if _LIBCPP_BIG_ENDIAN {__r_.first().__s.__size_ = (unsigned char)(__s);}# else {__r_.first().__s.__size_ = (unsigned char)(__s << 1);}# endif _LIBCPP_INLINE_VISIBILITY size_type __get_short_size() const _NOEXCEPT# if _LIBCPP_BIG_ENDIAN {return __r_.first().__s.__size_;}# else {return __r_.first().__s.__size_ >> 1;}# endif#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT _LIBCPP_INLINE_VISIBILITY void __set_long_size(size_type __s) _NOEXCEPT {__r_.first().__l.__size_ = __s;} _LIBCPP_INLINE_VISIBILITY size_type __get_long_size() const _NOEXCEPT {return __r_.first().__l.__size_;} _LIBCPP_INLINE_VISIBILITY void __set_size(size_type __s) _NOEXCEPT {if (__is_long()) __set_long_size(__s); else __set_short_size(__s);} _LIBCPP_INLINE_VISIBILITY void __set_long_cap(size_type __s) _NOEXCEPT {__r_.first().__l.__cap_ = __long_mask | __s;} _LIBCPP_INLINE_VISIBILITY size_type __get_long_cap() const _NOEXCEPT {return __r_.first().__l.__cap_ & size_type(~__long_mask);} _LIBCPP_INLINE_VISIBILITY void __set_long_pointer(pointer __p) _NOEXCEPT {__r_.first().__l.__data_ = __p;} _LIBCPP_INLINE_VISIBILITY pointer __get_long_pointer() _NOEXCEPT {return __r_.first().__l.__data_;} _LIBCPP_INLINE_VISIBILITY const_pointer __get_long_pointer() const _NOEXCEPT {return __r_.first().__l.__data_;} _LIBCPP_INLINE_VISIBILITY pointer __get_short_pointer() _NOEXCEPT {return pointer_traits<pointer>::pointer_to(__r_.first().__s.__data_[0]);} _LIBCPP_INLINE_VISIBILITY const_pointer __get_short_pointer() const _NOEXCEPT {return pointer_traits<const_pointer>::pointer_to(__r_.first().__s.__data_[0]);} _LIBCPP_INLINE_VISIBILITY pointer __get_pointer() _NOEXCEPT {return __is_long() ? __get_long_pointer() : __get_short_pointer();} _LIBCPP_INLINE_VISIBILITY const_pointer __get_pointer() const _NOEXCEPT {return __is_long() ? __get_long_pointer() : __get_short_pointer();} _LIBCPP_INLINE_VISIBILITY void __zero() _NOEXCEPT { size_type (&__a)[__n_words] = __r_.first().__r.__words; for (unsigned __i = 0; __i < __n_words; ++__i) __a[__i] = 0; } template <size_type __a> static _LIBCPP_INLINE_VISIBILITY size_type __align_it(size_type __s) _NOEXCEPT {return (__s + (__a-1)) & ~(__a-1);} enum {__alignment = 16}; static _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __s) _NOEXCEPT {return (__s < __min_cap ? static_cast<size_type>(__min_cap) : __align_it<sizeof(value_type) < __alignment ? __alignment/sizeof(value_type) : 1 > (__s+1)) - 1;} inline void __init(const value_type* __s, size_type __sz, size_type __reserve); inline void __init(const value_type* __s, size_type __sz); inline void __init(size_type __n, value_type __c); template <class _InputIterator> inline typename enable_if < __is_exactly_input_iterator<_InputIterator>::value, void >::type __init(_InputIterator __first, _InputIterator __last); template <class _ForwardIterator> inline typename enable_if < __is_forward_iterator<_ForwardIterator>::value, void >::type __init(_ForwardIterator __first, _ForwardIterator __last); void __grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz, size_type __n_copy, size_type __n_del, size_type __n_add = 0); void __grow_by_and_replace(size_type __old_cap, size_type __delta_cap, size_type __old_sz, size_type __n_copy, size_type __n_del, size_type __n_add, const value_type* __p_new_stuff); _LIBCPP_INLINE_VISIBILITY void __erase_to_end(size_type __pos); _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const basic_string& __str) {__copy_assign_alloc(__str, integral_constant<bool, __alloc_traits::propagate_on_container_copy_assignment::value>());} _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const basic_string& __str, true_type) { if (__alloc() == __str.__alloc()) __alloc() = __str.__alloc(); else { if (!__str.__is_long()) { clear(); shrink_to_fit(); __alloc() = __str.__alloc(); } else { allocator_type __a = __str.__alloc(); pointer __p = __alloc_traits::allocate(__a, __str.__get_long_cap()); clear(); shrink_to_fit(); __alloc() = _VSTD::move(__a); __set_long_pointer(__p); __set_long_cap(__str.__get_long_cap()); __set_long_size(__str.size()); } } } _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT {}#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY void __move_assign(basic_string& __str, false_type) _NOEXCEPT_(__alloc_traits::is_always_equal::value); _LIBCPP_INLINE_VISIBILITY void __move_assign(basic_string& __str, true_type)#if _LIBCPP_STD_VER > 14 _NOEXCEPT;#else _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);#endif#endif _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(basic_string& __str) _NOEXCEPT_( !__alloc_traits::propagate_on_container_move_assignment::value || is_nothrow_move_assignable<allocator_type>::value) {__move_assign_alloc(__str, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());} _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(basic_string& __c, true_type) _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) { __alloc() = _VSTD::move(__c.__alloc()); } _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(basic_string&, false_type) _NOEXCEPT {} _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(size_type); friend basic_string operator+<>(const basic_string&, const basic_string&); friend basic_string operator+<>(const value_type*, const basic_string&); friend basic_string operator+<>(value_type, const basic_string&); friend basic_string operator+<>(const basic_string&, const value_type*); friend basic_string operator+<>(const basic_string&, value_type);};template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYvoidbasic_string<_CharT, _Traits, _Allocator>::__invalidate_all_iterators(){#if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__invalidate_all(this);#endif // _LIBCPP_DEBUG_LEVEL >= 2}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYvoidbasic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type#if _LIBCPP_DEBUG_LEVEL >= 2 __pos#endif ){#if _LIBCPP_DEBUG_LEVEL >= 2 __c_node* __c = __get_db()->__find_c_and_lock(this); if (__c) { const_pointer __new_last = __get_pointer() + __pos; for (__i_node** __p = __c->end_; __p != __c->beg_; ) { --__p; const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_); if (__i->base() > __new_last) { (*__p)->__c_ = nullptr; if (--__c->end_ != __p) memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); } } __get_db()->unlock(); }#endif // _LIBCPP_DEBUG_LEVEL >= 2}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>::basic_string() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value){#if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this);#endif __zero();}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a)#if _LIBCPP_STD_VER <= 14 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)#else _NOEXCEPT#endif: __r_(__second_tag(), __a){#if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this);#endif __zero();}template <class _CharT, class _Traits, class _Allocator>void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz, size_type __reserve){ if (__reserve > max_size()) this->__throw_length_error(); pointer __p; if (__reserve < __min_cap) { __set_short_size(__sz); __p = __get_short_pointer(); } else { size_type __cap = __recommend(__reserve); __p = __alloc_traits::allocate(__alloc(), __cap+1); __set_long_pointer(__p); __set_long_cap(__cap+1); __set_long_size(__sz); } traits_type::copy(_VSTD::__to_raw_pointer(__p), __s, __sz); traits_type::assign(__p[__sz], value_type());}template <class _CharT, class _Traits, class _Allocator>voidbasic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz){ if (__sz > max_size()) this->__throw_length_error(); pointer __p; if (__sz < __min_cap) { __set_short_size(__sz); __p = __get_short_pointer(); } else { size_type __cap = __recommend(__sz); __p = __alloc_traits::allocate(__alloc(), __cap+1); __set_long_pointer(__p); __set_long_cap(__cap+1); __set_long_size(__sz); } traits_type::copy(_VSTD::__to_raw_pointer(__p), __s, __sz); traits_type::assign(__p[__sz], value_type());}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s){ _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr"); __init(__s, traits_type::length(__s));#if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this);#endif}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a) : __r_(__second_tag(), __a){ _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr"); __init(__s, traits_type::length(__s));#if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this);#endif}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n){ _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr"); __init(__s, __n);#if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this);#endif}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n, const _Allocator& __a) : __r_(__second_tag(), __a){ _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr"); __init(__s, __n);#if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this);#endif}template <class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str) : __r_(__second_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc())){ if (!__str.__is_long()) __r_.first().__r = __str.__r_.first().__r; else __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size());#if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this);#endif}template <class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>::basic_string( const basic_string& __str, const allocator_type& __a) : __r_(__second_tag(), __a){ if (!__str.__is_long()) __r_.first().__r = __str.__r_.first().__r; else __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size());#if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this);#endif}#ifndef _LIBCPP_CXX03_LANGtemplate <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str)#if _LIBCPP_STD_VER <= 14 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)#else _NOEXCEPT#endif : __r_(_VSTD::move(__str.__r_)){ __str.__zero();#if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); if (__is_long()) __get_db()->swap(this, &__str);#endif}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a) : __r_(__second_tag(), __a){ if (__str.__is_long() && __a != __str.__alloc()) // copy, not move __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size()); else { __r_.first().__r = __str.__r_.first().__r; __str.__zero(); }#if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); if (__is_long()) __get_db()->swap(this, &__str);#endif}#endif // _LIBCPP_CXX03_LANGtemplate <class _CharT, class _Traits, class _Allocator>voidbasic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c){ if (__n > max_size()) this->__throw_length_error(); pointer __p; if (__n < __min_cap) { __set_short_size(__n); __p = __get_short_pointer(); } else { size_type __cap = __recommend(__n); __p = __alloc_traits::allocate(__alloc(), __cap+1); __set_long_pointer(__p); __set_long_cap(__cap+1); __set_long_size(__n); } traits_type::assign(_VSTD::__to_raw_pointer(__p), __n, __c); traits_type::assign(__p[__n], value_type());}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c){ __init(__n, __c);#if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this);#endif}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c, const _Allocator& __a) : __r_(__second_tag(), __a){ __init(__n, __c);#if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this);#endif}template <class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos, size_type __n, const _Allocator& __a) : __r_(__second_tag(), __a){ size_type __str_sz = __str.size(); if (__pos > __str_sz) this->__throw_out_of_range(); __init(__str.data() + __pos, _VSTD::min(__n, __str_sz - __pos));#if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this);#endif}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos, const _Allocator& __a) : __r_(__second_tag(), __a){ size_type __str_sz = __str.size(); if (__pos > __str_sz) this->__throw_out_of_range(); __init(__str.data() + __pos, __str_sz - __pos);#if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this);#endif}template <class _CharT, class _Traits, class _Allocator>template <class _Tp>basic_string<_CharT, _Traits, _Allocator>::basic_string( const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a, typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type *) : __r_(__second_tag(), __a){ __self_view __sv = __self_view(__t).substr(__pos, __n); __init(__sv.data(), __sv.size());#if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this);#endif}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>::basic_string(__self_view __sv){ __init(__sv.data(), __sv.size());#if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this);#endif}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>::basic_string(__self_view __sv, const _Allocator& __a) : __r_(__second_tag(), __a){ __init(__sv.data(), __sv.size());#if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this);#endif}template <class _CharT, class _Traits, class _Allocator>template <class _InputIterator>typename enable_if< __is_exactly_input_iterator<_InputIterator>::value, void>::typebasic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _InputIterator __last){ __zero();#ifndef _LIBCPP_NO_EXCEPTIONS try {#endif // _LIBCPP_NO_EXCEPTIONS for (; __first != __last; ++__first) push_back(*__first);#ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { if (__is_long()) __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); throw; }#endif // _LIBCPP_NO_EXCEPTIONS}template <class _CharT, class _Traits, class _Allocator>template <class _ForwardIterator>typename enable_if< __is_forward_iterator<_ForwardIterator>::value, void>::typebasic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _ForwardIterator __last){ size_type __sz = static_cast<size_type>(_VSTD::distance(__first, __last)); if (__sz > max_size()) this->__throw_length_error(); pointer __p; if (__sz < __min_cap) { __set_short_size(__sz); __p = __get_short_pointer(); } else { size_type __cap = __recommend(__sz); __p = __alloc_traits::allocate(__alloc(), __cap+1); __set_long_pointer(__p); __set_long_cap(__cap+1); __set_long_size(__sz); } for (; __first != __last; ++__first, (void) ++__p) traits_type::assign(*__p, *__first); traits_type::assign(*__p, value_type());}template <class _CharT, class _Traits, class _Allocator>template<class _InputIterator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last){ __init(__first, __last);#if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this);#endif}template <class _CharT, class _Traits, class _Allocator>template<class _InputIterator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a) : __r_(__second_tag(), __a){ __init(__first, __last);#if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this);#endif}#ifndef _LIBCPP_CXX03_LANGtemplate <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>::basic_string( initializer_list<_CharT> __il){ __init(__il.begin(), __il.end());#if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this);#endif}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>::basic_string( initializer_list<_CharT> __il, const _Allocator& __a) : __r_(__second_tag(), __a){ __init(__il.begin(), __il.end());#if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this);#endif}#endif // _LIBCPP_CXX03_LANGtemplate <class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>::~basic_string(){#if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__erase_c(this);#endif if (__is_long()) __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap());}template <class _CharT, class _Traits, class _Allocator>voidbasic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace (size_type __old_cap, size_type __delta_cap, size_type __old_sz, size_type __n_copy, size_type __n_del, size_type __n_add, const value_type* __p_new_stuff){ size_type __ms = max_size(); if (__delta_cap > __ms - __old_cap - 1) this->__throw_length_error(); pointer __old_p = __get_pointer(); size_type __cap = __old_cap < __ms / 2 - __alignment ? __recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) : __ms - 1; pointer __p = __alloc_traits::allocate(__alloc(), __cap+1); __invalidate_all_iterators(); if (__n_copy != 0) traits_type::copy(_VSTD::__to_raw_pointer(__p), _VSTD::__to_raw_pointer(__old_p), __n_copy); if (__n_add != 0) traits_type::copy(_VSTD::__to_raw_pointer(__p) + __n_copy, __p_new_stuff, __n_add); size_type __sec_cp_sz = __old_sz - __n_del - __n_copy; if (__sec_cp_sz != 0) traits_type::copy(_VSTD::__to_raw_pointer(__p) + __n_copy + __n_add, _VSTD::__to_raw_pointer(__old_p) + __n_copy + __n_del, __sec_cp_sz); if (__old_cap+1 != __min_cap) __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1); __set_long_pointer(__p); __set_long_cap(__cap+1); __old_sz = __n_copy + __n_add + __sec_cp_sz; __set_long_size(__old_sz); traits_type::assign(__p[__old_sz], value_type());}template <class _CharT, class _Traits, class _Allocator>voidbasic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz, size_type __n_copy, size_type __n_del, size_type __n_add){ size_type __ms = max_size(); if (__delta_cap > __ms - __old_cap) this->__throw_length_error(); pointer __old_p = __get_pointer(); size_type __cap = __old_cap < __ms / 2 - __alignment ? __recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) : __ms - 1; pointer __p = __alloc_traits::allocate(__alloc(), __cap+1); __invalidate_all_iterators(); if (__n_copy != 0) traits_type::copy(_VSTD::__to_raw_pointer(__p), _VSTD::__to_raw_pointer(__old_p), __n_copy); size_type __sec_cp_sz = __old_sz - __n_del - __n_copy; if (__sec_cp_sz != 0) traits_type::copy(_VSTD::__to_raw_pointer(__p) + __n_copy + __n_add, _VSTD::__to_raw_pointer(__old_p) + __n_copy + __n_del, __sec_cp_sz); if (__old_cap+1 != __min_cap) __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1); __set_long_pointer(__p); __set_long_cap(__cap+1);}// assigntemplate <class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n){ _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::assign received nullptr"); size_type __cap = capacity(); if (__cap >= __n) { value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); traits_type::move(__p, __s, __n); traits_type::assign(__p[__n], value_type()); __set_size(__n); __invalidate_iterators_past(__n); } else { size_type __sz = size(); __grow_by_and_replace(__cap, __n - __cap, __sz, 0, __sz, __n, __s); } return *this;}template <class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c){ size_type __cap = capacity(); if (__cap < __n) { size_type __sz = size(); __grow_by(__cap, __n - __cap, __sz, 0, __sz); } else __invalidate_iterators_past(__n); value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); traits_type::assign(__p, __n, __c); traits_type::assign(__p[__n], value_type()); __set_size(__n); return *this;}template <class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c){ pointer __p; if (__is_long()) { __p = __get_long_pointer(); __set_long_size(1); } else { __p = __get_short_pointer(); __set_short_size(1); } traits_type::assign(*__p, __c); traits_type::assign(*++__p, value_type()); __invalidate_iterators_past(1); return *this;}template <class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str){ if (this != &__str) { __copy_assign_alloc(__str); assign(__str.data(), __str.size()); } return *this;}#ifndef _LIBCPP_CXX03_LANGtemplate <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYvoidbasic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type) _NOEXCEPT_(__alloc_traits::is_always_equal::value){ if (__alloc() != __str.__alloc()) assign(__str); else __move_assign(__str, true_type());}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYvoidbasic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type)#if _LIBCPP_STD_VER > 14 _NOEXCEPT#else _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)#endif{ clear(); shrink_to_fit(); __r_.first() = __str.__r_.first(); __move_assign_alloc(__str); __str.__zero();}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str) _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)){ __move_assign(__str, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>()); return *this;}#endiftemplate <class _CharT, class _Traits, class _Allocator>template<class _InputIterator>typename enable_if< __is_exactly_input_iterator <_InputIterator>::value || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, basic_string<_CharT, _Traits, _Allocator>&>::typebasic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _InputIterator __last){ const basic_string __temp(__first, __last, __alloc()); assign(__temp.data(), __temp.size()); return *this;}template <class _CharT, class _Traits, class _Allocator>template<class _ForwardIterator>typename enable_if< __is_forward_iterator<_ForwardIterator>::value && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, basic_string<_CharT, _Traits, _Allocator>&>::typebasic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last){ size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); size_type __cap = capacity(); if (__cap < __n) { size_type __sz = size(); __grow_by(__cap, __n - __cap, __sz, 0, __sz); } else __invalidate_iterators_past(__n); pointer __p = __get_pointer(); for (; __first != __last; ++__first, ++__p) traits_type::assign(*__p, *__first); traits_type::assign(*__p, value_type()); __set_size(__n); return *this;}template <class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, size_type __pos, size_type __n){ size_type __sz = __str.size(); if (__pos > __sz) this->__throw_out_of_range(); return assign(__str.data() + __pos, _VSTD::min(__n, __sz - __pos));}template <class _CharT, class _Traits, class _Allocator>template <class _Tp>typename enable_if< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, basic_string<_CharT, _Traits, _Allocator>&>::typebasic_string<_CharT, _Traits, _Allocator>::assign(const _Tp & __t, size_type __pos, size_type __n){ __self_view __sv = __t; size_type __sz = __sv.size(); if (__pos > __sz) this->__throw_out_of_range(); return assign(__sv.data() + __pos, _VSTD::min(__n, __sz - __pos));}template <class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s){ _LIBCPP_ASSERT(__s != nullptr, "string::assign received nullptr"); return assign(__s, traits_type::length(__s));}// appendtemplate <class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n){ _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::append received nullptr"); size_type __cap = capacity(); size_type __sz = size(); if (__cap - __sz >= __n) { if (__n) { value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); traits_type::copy(__p + __sz, __s, __n); __sz += __n; __set_size(__sz); traits_type::assign(__p[__sz], value_type()); } } else __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __sz, 0, __n, __s); return *this;}template <class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c){ if (__n) { size_type __cap = capacity(); size_type __sz = size(); if (__cap - __sz < __n) __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0); pointer __p = __get_pointer(); traits_type::assign(_VSTD::__to_raw_pointer(__p) + __sz, __n, __c); __sz += __n; __set_size(__sz); traits_type::assign(__p[__sz], value_type()); } return *this;}template <class _CharT, class _Traits, class _Allocator>voidbasic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c){ bool __is_short = !__is_long(); size_type __cap; size_type __sz; if (__is_short) { __cap = __min_cap - 1; __sz = __get_short_size(); } else { __cap = __get_long_cap() - 1; __sz = __get_long_size(); } if (__sz == __cap) { __grow_by(__cap, 1, __sz, __sz, 0); __is_short = !__is_long(); } pointer __p; if (__is_short) { __p = __get_short_pointer() + __sz; __set_short_size(__sz+1); } else { __p = __get_long_pointer() + __sz; __set_long_size(__sz+1); } traits_type::assign(*__p, __c); traits_type::assign(*++__p, value_type());}template <class _Tp>bool __ptr_in_range (const _Tp* __p, const _Tp* __first, const _Tp* __last){ return __first <= __p && __p < __last;}template <class _Tp1, class _Tp2>bool __ptr_in_range (const _Tp1*, const _Tp2*, const _Tp2*){ return false;}template <class _CharT, class _Traits, class _Allocator>template<class _ForwardIterator>basic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::__append_forward_unsafe( _ForwardIterator __first, _ForwardIterator __last){ static_assert(__is_forward_iterator<_ForwardIterator>::value, "function requires a ForwardIterator"); size_type __sz = size(); size_type __cap = capacity(); size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); if (__n) { typedef typename iterator_traits<_ForwardIterator>::reference _CharRef; _CharRef __tmp_ref = *__first; if (__ptr_in_range(_VSTD::addressof(__tmp_ref), data(), data() + size())) { const basic_string __temp (__first, __last, __alloc()); append(__temp.data(), __temp.size()); } else { if (__cap - __sz < __n) __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0); pointer __p = __get_pointer() + __sz; for (; __first != __last; ++__p, ++__first) traits_type::assign(*__p, *__first); traits_type::assign(*__p, value_type()); __set_size(__sz + __n); } } return *this;}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str){ return append(__str.data(), __str.size());}template <class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, size_type __pos, size_type __n){ size_type __sz = __str.size(); if (__pos > __sz) this->__throw_out_of_range(); return append(__str.data() + __pos, _VSTD::min(__n, __sz - __pos));}template <class _CharT, class _Traits, class _Allocator>template <class _Tp> typename enable_if < __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, basic_string<_CharT, _Traits, _Allocator>& >::typebasic_string<_CharT, _Traits, _Allocator>::append(const _Tp & __t, size_type __pos, size_type __n){ __self_view __sv = __t; size_type __sz = __sv.size(); if (__pos > __sz) this->__throw_out_of_range(); return append(__sv.data() + __pos, _VSTD::min(__n, __sz - __pos));}template <class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s){ _LIBCPP_ASSERT(__s != nullptr, "string::append received nullptr"); return append(__s, traits_type::length(__s));}// inserttemplate <class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n){ _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::insert received nullptr"); size_type __sz = size(); if (__pos > __sz) this->__throw_out_of_range(); size_type __cap = capacity(); if (__cap - __sz >= __n) { if (__n) { value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); size_type __n_move = __sz - __pos; if (__n_move != 0) { if (__p + __pos <= __s && __s < __p + __sz) __s += __n; traits_type::move(__p + __pos + __n, __p + __pos, __n_move); } traits_type::move(__p + __pos, __s, __n); __sz += __n; __set_size(__sz); traits_type::assign(__p[__sz], value_type()); } } else __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __pos, 0, __n, __s); return *this;}template <class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n, value_type __c){ size_type __sz = size(); if (__pos > __sz) this->__throw_out_of_range(); if (__n) { size_type __cap = capacity(); value_type* __p; if (__cap - __sz >= __n) { __p = _VSTD::__to_raw_pointer(__get_pointer()); size_type __n_move = __sz - __pos; if (__n_move != 0) traits_type::move(__p + __pos + __n, __p + __pos, __n_move); } else { __grow_by(__cap, __sz + __n - __cap, __sz, __pos, 0, __n); __p = _VSTD::__to_raw_pointer(__get_long_pointer()); } traits_type::assign(__p + __pos, __n, __c); __sz += __n; __set_size(__sz); traits_type::assign(__p[__sz], value_type()); } return *this;}template <class _CharT, class _Traits, class _Allocator>template<class _InputIterator>typename enable_if< __is_exactly_input_iterator<_InputIterator>::value || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, typename basic_string<_CharT, _Traits, _Allocator>::iterator>::typebasic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last){#if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, "string::insert(iterator, range) called with an iterator not" " referring to this string");#endif const basic_string __temp(__first, __last, __alloc()); return insert(__pos, __temp.data(), __temp.data() + __temp.size());}template <class _CharT, class _Traits, class _Allocator>template<class _ForwardIterator>typename enable_if< __is_forward_iterator<_ForwardIterator>::value && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, typename basic_string<_CharT, _Traits, _Allocator>::iterator>::typebasic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last){#if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, "string::insert(iterator, range) called with an iterator not" " referring to this string");#endif size_type __ip = static_cast<size_type>(__pos - begin()); size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); if (__n) { typedef typename iterator_traits<_ForwardIterator>::reference _CharRef; _CharRef __tmp_char = *__first; if (__ptr_in_range(_VSTD::addressof(__tmp_char), data(), data() + size())) { const basic_string __temp(__first, __last, __alloc()); return insert(__pos, __temp.data(), __temp.data() + __temp.size()); } size_type __sz = size(); size_type __cap = capacity(); value_type* __p; if (__cap - __sz >= __n) { __p = _VSTD::__to_raw_pointer(__get_pointer()); size_type __n_move = __sz - __ip; if (__n_move != 0) traits_type::move(__p + __ip + __n, __p + __ip, __n_move); } else { __grow_by(__cap, __sz + __n - __cap, __sz, __ip, 0, __n); __p = _VSTD::__to_raw_pointer(__get_long_pointer()); } __sz += __n; __set_size(__sz); traits_type::assign(__p[__sz], value_type()); for (__p += __ip; __first != __last; ++__p, ++__first) traits_type::assign(*__p, *__first); } return begin() + __ip;}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str){ return insert(__pos1, __str.data(), __str.size());}template <class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n){ size_type __str_sz = __str.size(); if (__pos2 > __str_sz) this->__throw_out_of_range(); return insert(__pos1, __str.data() + __pos2, _VSTD::min(__n, __str_sz - __pos2));}template <class _CharT, class _Traits, class _Allocator>template <class _Tp>typename enable_if< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, basic_string<_CharT, _Traits, _Allocator>&>::typebasic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n){ __self_view __sv = __t; size_type __str_sz = __sv.size(); if (__pos2 > __str_sz) this->__throw_out_of_range(); return insert(__pos1, __sv.data() + __pos2, _VSTD::min(__n, __str_sz - __pos2));}template <class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s){ _LIBCPP_ASSERT(__s != nullptr, "string::insert received nullptr"); return insert(__pos, __s, traits_type::length(__s));}template <class _CharT, class _Traits, class _Allocator>typename basic_string<_CharT, _Traits, _Allocator>::iteratorbasic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_type __c){ size_type __ip = static_cast<size_type>(__pos - begin()); size_type __sz = size(); size_type __cap = capacity(); value_type* __p; if (__cap == __sz) { __grow_by(__cap, 1, __sz, __ip, 0, 1); __p = _VSTD::__to_raw_pointer(__get_long_pointer()); } else { __p = _VSTD::__to_raw_pointer(__get_pointer()); size_type __n_move = __sz - __ip; if (__n_move != 0) traits_type::move(__p + __ip + 1, __p + __ip, __n_move); } traits_type::assign(__p[__ip], __c); traits_type::assign(__p[++__sz], value_type()); __set_size(__sz); return begin() + static_cast<difference_type>(__ip);}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::iteratorbasic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_type __n, value_type __c){#if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, "string::insert(iterator, n, value) called with an iterator not" " referring to this string");#endif difference_type __p = __pos - begin(); insert(static_cast<size_type>(__p), __n, __c); return begin() + __p;}// replacetemplate <class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2) _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK{ _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::replace received nullptr"); size_type __sz = size(); if (__pos > __sz) this->__throw_out_of_range(); __n1 = _VSTD::min(__n1, __sz - __pos); size_type __cap = capacity(); if (__cap - __sz + __n1 >= __n2) { value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); if (__n1 != __n2) { size_type __n_move = __sz - __pos - __n1; if (__n_move != 0) { if (__n1 > __n2) { traits_type::move(__p + __pos, __s, __n2); traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); goto __finish; } if (__p + __pos < __s && __s < __p + __sz) { if (__p + __pos + __n1 <= __s) __s += __n2 - __n1; else // __p + __pos < __s < __p + __pos + __n1 { traits_type::move(__p + __pos, __s, __n1); __pos += __n1; __s += __n2; __n2 -= __n1; __n1 = 0; } } traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); } } traits_type::move(__p + __pos, __s, __n2);__finish:// __sz += __n2 - __n1; in this and the below function below can cause unsigned integer overflow,// but this is a safe operation, so we disable the check. __sz += __n2 - __n1; __set_size(__sz); __invalidate_iterators_past(__sz); traits_type::assign(__p[__sz], value_type()); } else __grow_by_and_replace(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2, __s); return *this;}template <class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, size_type __n2, value_type __c) _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK{ size_type __sz = size(); if (__pos > __sz) this->__throw_out_of_range(); __n1 = _VSTD::min(__n1, __sz - __pos); size_type __cap = capacity(); value_type* __p; if (__cap - __sz + __n1 >= __n2) { __p = _VSTD::__to_raw_pointer(__get_pointer()); if (__n1 != __n2) { size_type __n_move = __sz - __pos - __n1; if (__n_move != 0) traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); } } else { __grow_by(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2); __p = _VSTD::__to_raw_pointer(__get_long_pointer()); } traits_type::assign(__p + __pos, __n2, __c); __sz += __n2 - __n1; __set_size(__sz); __invalidate_iterators_past(__sz); traits_type::assign(__p[__sz], value_type()); return *this;}template <class _CharT, class _Traits, class _Allocator>template<class _InputIterator>typename enable_if< __is_input_iterator<_InputIterator>::value, basic_string<_CharT, _Traits, _Allocator>&>::typebasic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2){ const basic_string __temp(__j1, __j2, __alloc()); return this->replace(__i1, __i2, __temp);}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str){ return replace(__pos1, __n1, __str.data(), __str.size());}template <class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2){ size_type __str_sz = __str.size(); if (__pos2 > __str_sz) this->__throw_out_of_range(); return replace(__pos1, __n1, __str.data() + __pos2, _VSTD::min(__n2, __str_sz - __pos2));}template <class _CharT, class _Traits, class _Allocator>template <class _Tp>typename enable_if< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, basic_string<_CharT, _Traits, _Allocator>&>::typebasic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2){ __self_view __sv = __t; size_type __str_sz = __sv.size(); if (__pos2 > __str_sz) this->__throw_out_of_range(); return replace(__pos1, __n1, __sv.data() + __pos2, _VSTD::min(__n2, __str_sz - __pos2));}template <class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s){ _LIBCPP_ASSERT(__s != nullptr, "string::replace received nullptr"); return replace(__pos, __n1, __s, traits_type::length(__s));}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const basic_string& __str){ return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __str.data(), __str.size());}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n){ return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __s, __n);}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s){ return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __s);}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c){ return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __n, __c);}// erasetemplate <class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>&basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, size_type __n){ size_type __sz = size(); if (__pos > __sz) this->__throw_out_of_range(); if (__n) { value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); __n = _VSTD::min(__n, __sz - __pos); size_type __n_move = __sz - __pos - __n; if (__n_move != 0) traits_type::move(__p + __pos, __p + __pos + __n, __n_move); __sz -= __n; __set_size(__sz); __invalidate_iterators_past(__sz); traits_type::assign(__p[__sz], value_type()); } return *this;}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::iteratorbasic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos){#if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, "string::erase(iterator) called with an iterator not" " referring to this string");#endif _LIBCPP_ASSERT(__pos != end(), "string::erase(iterator) called with a non-dereferenceable iterator"); iterator __b = begin(); size_type __r = static_cast<size_type>(__pos - __b); erase(__r, 1); return __b + static_cast<difference_type>(__r);}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::iteratorbasic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last){#if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this, "string::erase(iterator, iterator) called with an iterator not" " referring to this string");#endif _LIBCPP_ASSERT(__first <= __last, "string::erase(first, last) called with invalid range"); iterator __b = begin(); size_type __r = static_cast<size_type>(__first - __b); erase(__r, static_cast<size_type>(__last - __first)); return __b + static_cast<difference_type>(__r);}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYvoidbasic_string<_CharT, _Traits, _Allocator>::pop_back(){ _LIBCPP_ASSERT(!empty(), "string::pop_back(): string is already empty"); size_type __sz; if (__is_long()) { __sz = __get_long_size() - 1; __set_long_size(__sz); traits_type::assign(*(__get_long_pointer() + __sz), value_type()); } else { __sz = __get_short_size() - 1; __set_short_size(__sz); traits_type::assign(*(__get_short_pointer() + __sz), value_type()); } __invalidate_iterators_past(__sz);}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYvoidbasic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT{ __invalidate_all_iterators(); if (__is_long()) { traits_type::assign(*__get_long_pointer(), value_type()); __set_long_size(0); } else { traits_type::assign(*__get_short_pointer(), value_type()); __set_short_size(0); }}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYvoidbasic_string<_CharT, _Traits, _Allocator>::__erase_to_end(size_type __pos){ if (__is_long()) { traits_type::assign(*(__get_long_pointer() + __pos), value_type()); __set_long_size(__pos); } else { traits_type::assign(*(__get_short_pointer() + __pos), value_type()); __set_short_size(__pos); } __invalidate_iterators_past(__pos);}template <class _CharT, class _Traits, class _Allocator>voidbasic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c){ size_type __sz = size(); if (__n > __sz) append(__n - __sz, __c); else __erase_to_end(__n);}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::max_size() const _NOEXCEPT{ size_type __m = __alloc_traits::max_size(__alloc());#if _LIBCPP_BIG_ENDIAN return (__m <= ~__long_mask ? __m : __m/2) - __alignment;#else return __m - __alignment;#endif}template <class _CharT, class _Traits, class _Allocator>voidbasic_string<_CharT, _Traits, _Allocator>::reserve(size_type __res_arg){ if (__res_arg > max_size()) this->__throw_length_error(); size_type __cap = capacity(); size_type __sz = size(); __res_arg = _VSTD::max(__res_arg, __sz); __res_arg = __recommend(__res_arg); if (__res_arg != __cap) { pointer __new_data, __p; bool __was_long, __now_long; if (__res_arg == __min_cap - 1) { __was_long = true; __now_long = false; __new_data = __get_short_pointer(); __p = __get_long_pointer(); } else { if (__res_arg > __cap) __new_data = __alloc_traits::allocate(__alloc(), __res_arg+1); else { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS __new_data = __alloc_traits::allocate(__alloc(), __res_arg+1); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { return; } #else // _LIBCPP_NO_EXCEPTIONS if (__new_data == nullptr) return; #endif // _LIBCPP_NO_EXCEPTIONS } __now_long = true; __was_long = __is_long(); __p = __get_pointer(); } traits_type::copy(_VSTD::__to_raw_pointer(__new_data), _VSTD::__to_raw_pointer(__p), size()+1); if (__was_long) __alloc_traits::deallocate(__alloc(), __p, __cap+1); if (__now_long) { __set_long_cap(__res_arg+1); __set_long_size(__sz); __set_long_pointer(__new_data); } else __set_short_size(__sz); __invalidate_all_iterators(); }}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::const_referencebasic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) const _NOEXCEPT{ _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds"); return *(data() + __pos);}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::referencebasic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) _NOEXCEPT{ _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds"); return *(__get_pointer() + __pos);}template <class _CharT, class _Traits, class _Allocator>typename basic_string<_CharT, _Traits, _Allocator>::const_referencebasic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const{ if (__n >= size()) this->__throw_out_of_range(); return (*this)[__n];}template <class _CharT, class _Traits, class _Allocator>typename basic_string<_CharT, _Traits, _Allocator>::referencebasic_string<_CharT, _Traits, _Allocator>::at(size_type __n){ if (__n >= size()) this->__throw_out_of_range(); return (*this)[__n];}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::referencebasic_string<_CharT, _Traits, _Allocator>::front(){ _LIBCPP_ASSERT(!empty(), "string::front(): string is empty"); return *__get_pointer();}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::const_referencebasic_string<_CharT, _Traits, _Allocator>::front() const{ _LIBCPP_ASSERT(!empty(), "string::front(): string is empty"); return *data();}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::referencebasic_string<_CharT, _Traits, _Allocator>::back(){ _LIBCPP_ASSERT(!empty(), "string::back(): string is empty"); return *(__get_pointer() + size() - 1);}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::const_referencebasic_string<_CharT, _Traits, _Allocator>::back() const{ _LIBCPP_ASSERT(!empty(), "string::back(): string is empty"); return *(data() + size() - 1);}template <class _CharT, class _Traits, class _Allocator>typename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, size_type __pos) const{ size_type __sz = size(); if (__pos > __sz) this->__throw_out_of_range(); size_type __rlen = _VSTD::min(__n, __sz - __pos); traits_type::copy(__s, data() + __pos, __rlen); return __rlen;}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>basic_string<_CharT, _Traits, _Allocator>::substr(size_type __pos, size_type __n) const{ return basic_string(*this, __pos, __n, __alloc());}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYvoidbasic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)#if _LIBCPP_STD_VER >= 14 _NOEXCEPT_DEBUG#else _NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value)#endif{#if _LIBCPP_DEBUG_LEVEL >= 2 if (!__is_long()) __get_db()->__invalidate_all(this); if (!__str.__is_long()) __get_db()->__invalidate_all(&__str); __get_db()->swap(this, &__str);#endif _LIBCPP_ASSERT( __alloc_traits::propagate_on_container_swap::value || __alloc_traits::is_always_equal::value || __alloc() == __str.__alloc(), "swapping non-equal allocators"); _VSTD::swap(__r_.first(), __str.__r_.first()); __swap_allocator(__alloc(), __str.__alloc());}// findtemplate <class _Traits>struct _LIBCPP_HIDDEN __traits_eq{ typedef typename _Traits::char_type char_type; _LIBCPP_INLINE_VISIBILITY bool operator()(const char_type& __x, const char_type& __y) _NOEXCEPT {return _Traits::eq(__x, __y);}};template<class _CharT, class _Traits, class _Allocator>typename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT{ _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find(): received nullptr"); return __str_find<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, __n);}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str, size_type __pos) const _NOEXCEPT{ return __str_find<value_type, size_type, traits_type, npos> (data(), size(), __str.data(), __pos, __str.size());}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::find(__self_view __sv, size_type __pos) const _NOEXCEPT{ return __str_find<value_type, size_type, traits_type, npos> (data(), size(), __sv.data(), __pos, __sv.size());}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos) const _NOEXCEPT{ _LIBCPP_ASSERT(__s != nullptr, "string::find(): received nullptr"); return __str_find<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, traits_type::length(__s));}template<class _CharT, class _Traits, class _Allocator>typename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::find(value_type __c, size_type __pos) const _NOEXCEPT{ return __str_find<value_type, size_type, traits_type, npos> (data(), size(), __c, __pos);}// rfindtemplate<class _CharT, class _Traits, class _Allocator>typename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT{ _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::rfind(): received nullptr"); return __str_rfind<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, __n);}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str, size_type __pos) const _NOEXCEPT{ return __str_rfind<value_type, size_type, traits_type, npos> (data(), size(), __str.data(), __pos, __str.size());}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::rfind(__self_view __sv, size_type __pos) const _NOEXCEPT{ return __str_rfind<value_type, size_type, traits_type, npos> (data(), size(), __sv.data(), __pos, __sv.size());}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, size_type __pos) const _NOEXCEPT{ _LIBCPP_ASSERT(__s != nullptr, "string::rfind(): received nullptr"); return __str_rfind<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, traits_type::length(__s));}template<class _CharT, class _Traits, class _Allocator>typename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c, size_type __pos) const _NOEXCEPT{ return __str_rfind<value_type, size_type, traits_type, npos> (data(), size(), __c, __pos);}// find_first_oftemplate<class _CharT, class _Traits, class _Allocator>typename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT{ _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_of(): received nullptr"); return __str_find_first_of<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, __n);}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str, size_type __pos) const _NOEXCEPT{ return __str_find_first_of<value_type, size_type, traits_type, npos> (data(), size(), __str.data(), __pos, __str.size());}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::find_first_of(__self_view __sv, size_type __pos) const _NOEXCEPT{ return __str_find_first_of<value_type, size_type, traits_type, npos> (data(), size(), __sv.data(), __pos, __sv.size());}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, size_type __pos) const _NOEXCEPT{ _LIBCPP_ASSERT(__s != nullptr, "string::find_first_of(): received nullptr"); return __str_find_first_of<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, traits_type::length(__s));}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c, size_type __pos) const _NOEXCEPT{ return find(__c, __pos);}// find_last_oftemplate<class _CharT, class _Traits, class _Allocator>typename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT{ _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_of(): received nullptr"); return __str_find_last_of<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, __n);}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str, size_type __pos) const _NOEXCEPT{ return __str_find_last_of<value_type, size_type, traits_type, npos> (data(), size(), __str.data(), __pos, __str.size());}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::find_last_of(__self_view __sv, size_type __pos) const _NOEXCEPT{ return __str_find_last_of<value_type, size_type, traits_type, npos> (data(), size(), __sv.data(), __pos, __sv.size());}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, size_type __pos) const _NOEXCEPT{ _LIBCPP_ASSERT(__s != nullptr, "string::find_last_of(): received nullptr"); return __str_find_last_of<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, traits_type::length(__s));}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c, size_type __pos) const _NOEXCEPT{ return rfind(__c, __pos);}// find_first_not_oftemplate<class _CharT, class _Traits, class _Allocator>typename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT{ _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_not_of(): received nullptr"); return __str_find_first_not_of<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, __n);}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& __str, size_type __pos) const _NOEXCEPT{ return __str_find_first_not_of<value_type, size_type, traits_type, npos> (data(), size(), __str.data(), __pos, __str.size());}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::find_first_not_of(__self_view __sv, size_type __pos) const _NOEXCEPT{ return __str_find_first_not_of<value_type, size_type, traits_type, npos> (data(), size(), __sv.data(), __pos, __sv.size());}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, size_type __pos) const _NOEXCEPT{ _LIBCPP_ASSERT(__s != nullptr, "string::find_first_not_of(): received nullptr"); return __str_find_first_not_of<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, traits_type::length(__s));}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c, size_type __pos) const _NOEXCEPT{ return __str_find_first_not_of<value_type, size_type, traits_type, npos> (data(), size(), __c, __pos);}// find_last_not_oftemplate<class _CharT, class _Traits, class _Allocator>typename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT{ _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_not_of(): received nullptr"); return __str_find_last_not_of<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, __n);}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& __str, size_type __pos) const _NOEXCEPT{ return __str_find_last_not_of<value_type, size_type, traits_type, npos> (data(), size(), __str.data(), __pos, __str.size());}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::find_last_not_of(__self_view __sv, size_type __pos) const _NOEXCEPT{ return __str_find_last_not_of<value_type, size_type, traits_type, npos> (data(), size(), __sv.data(), __pos, __sv.size());}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, size_type __pos) const _NOEXCEPT{ _LIBCPP_ASSERT(__s != nullptr, "string::find_last_not_of(): received nullptr"); return __str_find_last_not_of<value_type, size_type, traits_type, npos> (data(), size(), __s, __pos, traits_type::length(__s));}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYtypename basic_string<_CharT, _Traits, _Allocator>::size_typebasic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c, size_type __pos) const _NOEXCEPT{ return __str_find_last_not_of<value_type, size_type, traits_type, npos> (data(), size(), __c, __pos);}// comparetemplate <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYintbasic_string<_CharT, _Traits, _Allocator>::compare(__self_view __sv) const _NOEXCEPT{ size_t __lhs_sz = size(); size_t __rhs_sz = __sv.size(); int __result = traits_type::compare(data(), __sv.data(), _VSTD::min(__lhs_sz, __rhs_sz)); if (__result != 0) return __result; if (__lhs_sz < __rhs_sz) return -1; if (__lhs_sz > __rhs_sz) return 1; return 0;}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYintbasic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT{ return compare(__self_view(__str));}template <class _CharT, class _Traits, class _Allocator>intbasic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const{ _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::compare(): received nullptr"); size_type __sz = size(); if (__pos1 > __sz || __n2 == npos) this->__throw_out_of_range(); size_type __rlen = _VSTD::min(__n1, __sz - __pos1); int __r = traits_type::compare(data() + __pos1, __s, _VSTD::min(__rlen, __n2)); if (__r == 0) { if (__rlen < __n2) __r = -1; else if (__rlen > __n2) __r = 1; } return __r;}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYintbasic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, __self_view __sv) const{ return compare(__pos1, __n1, __sv.data(), __sv.size());}template <class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYintbasic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const basic_string& __str) const{ return compare(__pos1, __n1, __str.data(), __str.size());}template <class _CharT, class _Traits, class _Allocator>template <class _Tp>typename enable_if< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int>::typebasic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2) const{ __self_view __sv = __t; return __self_view(*this).substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));}template <class _CharT, class _Traits, class _Allocator>intbasic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2) const{ return compare(__pos1, __n1, __self_view(__str), __pos2, __n2);}template <class _CharT, class _Traits, class _Allocator>intbasic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT{ _LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr"); return compare(0, npos, __s, traits_type::length(__s));}template <class _CharT, class _Traits, class _Allocator>intbasic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const value_type* __s) const{ _LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr"); return compare(__pos1, __n1, __s, traits_type::length(__s));}// __invariantstemplate<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYboolbasic_string<_CharT, _Traits, _Allocator>::__invariants() const{ if (size() > capacity()) return false; if (capacity() < __min_cap - 1) return false; if (data() == 0) return false; if (data()[size()] != value_type(0)) return false; return true;}// operator==template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbooloperator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT{ size_t __lhs_sz = __lhs.size(); return __lhs_sz == __rhs.size() && _Traits::compare(__lhs.data(), __rhs.data(), __lhs_sz) == 0;}template<class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbooloperator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs, const basic_string<char, char_traits<char>, _Allocator>& __rhs) _NOEXCEPT{ size_t __lhs_sz = __lhs.size(); if (__lhs_sz != __rhs.size()) return false; const char* __lp = __lhs.data(); const char* __rp = __rhs.data(); if (__lhs.__is_long()) return char_traits<char>::compare(__lp, __rp, __lhs_sz) == 0; for (; __lhs_sz != 0; --__lhs_sz, ++__lp, ++__rp) if (*__lp != *__rp) return false; return true;}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbooloperator==(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT{ typedef basic_string<_CharT, _Traits, _Allocator> _String; _LIBCPP_ASSERT(__lhs != nullptr, "operator==(char*, basic_string): received nullptr"); size_t __lhs_len = _Traits::length(__lhs); if (__lhs_len != __rhs.size()) return false; return __rhs.compare(0, _String::npos, __lhs, __lhs_len) == 0;}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbooloperator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT{ typedef basic_string<_CharT, _Traits, _Allocator> _String; _LIBCPP_ASSERT(__rhs != nullptr, "operator==(basic_string, char*): received nullptr"); size_t __rhs_len = _Traits::length(__rhs); if (__rhs_len != __lhs.size()) return false; return __lhs.compare(0, _String::npos, __rhs, __rhs_len) == 0;}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbooloperator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT{ return !(__lhs == __rhs);}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbooloperator!=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT{ return !(__lhs == __rhs);}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbooloperator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT{ return !(__lhs == __rhs);}// operator<template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbooloperator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT{ return __lhs.compare(__rhs) < 0;}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbooloperator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT{ return __lhs.compare(__rhs) < 0;}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbooloperator< (const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT{ return __rhs.compare(__lhs) > 0;}// operator>template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbooloperator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT{ return __rhs < __lhs;}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbooloperator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT{ return __rhs < __lhs;}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbooloperator> (const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT{ return __rhs < __lhs;}// operator<=template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbooloperator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT{ return !(__rhs < __lhs);}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbooloperator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT{ return !(__rhs < __lhs);}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbooloperator<=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT{ return !(__rhs < __lhs);}// operator>=template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbooloperator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT{ return !(__lhs < __rhs);}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbooloperator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT{ return !(__lhs < __rhs);}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbooloperator>=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT{ return !(__lhs < __rhs);}// operator +template<class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs){ basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator()); typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size(); typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size(); __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz); __r.append(__rhs.data(), __rhs_sz); return __r;}template<class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>operator+(const _CharT* __lhs , const basic_string<_CharT,_Traits,_Allocator>& __rhs){ basic_string<_CharT, _Traits, _Allocator> __r(__rhs.get_allocator()); typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = _Traits::length(__lhs); typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size(); __r.__init(__lhs, __lhs_sz, __lhs_sz + __rhs_sz); __r.append(__rhs.data(), __rhs_sz); return __r;}template<class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Allocator>& __rhs){ basic_string<_CharT, _Traits, _Allocator> __r(__rhs.get_allocator()); typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size(); __r.__init(&__lhs, 1, 1 + __rhs_sz); __r.append(__rhs.data(), __rhs_sz); return __r;}template<class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs){ basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator()); typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size(); typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = _Traits::length(__rhs); __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz); __r.append(__rhs, __rhs_sz); return __r;}template<class _CharT, class _Traits, class _Allocator>basic_string<_CharT, _Traits, _Allocator>operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs){ basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator()); typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size(); __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + 1); __r.push_back(__rhs); return __r;}#ifndef _LIBCPP_CXX03_LANGtemplate<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs){ return _VSTD::move(__lhs.append(__rhs));}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs){ return _VSTD::move(__rhs.insert(0, __lhs));}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs){ return _VSTD::move(__lhs.append(__rhs));}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs){ return _VSTD::move(__rhs.insert(0, __lhs));}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>operator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs){ __rhs.insert(__rhs.begin(), __lhs); return _VSTD::move(__rhs);}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs){ return _VSTD::move(__lhs.append(__rhs));}template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_string<_CharT, _Traits, _Allocator>operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs){ __lhs.push_back(__rhs); return _VSTD::move(__lhs);}#endif // _LIBCPP_CXX03_LANG// swaptemplate<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYvoidswap(basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT_(_NOEXCEPT_(__lhs.swap(__rhs))){ __lhs.swap(__rhs);}#ifndef _LIBCPP_HAS_NO_UNICODE_CHARStypedef basic_string<char16_t> u16string;typedef basic_string<char32_t> u32string;#endif // _LIBCPP_HAS_NO_UNICODE_CHARS_LIBCPP_FUNC_VIS int stoi (const string& __str, size_t* __idx = 0, int __base = 10);_LIBCPP_FUNC_VIS long stol (const string& __str, size_t* __idx = 0, int __base = 10);_LIBCPP_FUNC_VIS unsigned long stoul (const string& __str, size_t* __idx = 0, int __base = 10);_LIBCPP_FUNC_VIS long long stoll (const string& __str, size_t* __idx = 0, int __base = 10);_LIBCPP_FUNC_VIS unsigned long long stoull(const string& __str, size_t* __idx = 0, int __base = 10);_LIBCPP_FUNC_VIS float stof (const string& __str, size_t* __idx = 0);_LIBCPP_FUNC_VIS double stod (const string& __str, size_t* __idx = 0);_LIBCPP_FUNC_VIS long double stold(const string& __str, size_t* __idx = 0);_LIBCPP_FUNC_VIS string to_string(int __val);_LIBCPP_FUNC_VIS string to_string(unsigned __val);_LIBCPP_FUNC_VIS string to_string(long __val);_LIBCPP_FUNC_VIS string to_string(unsigned long __val);_LIBCPP_FUNC_VIS string to_string(long long __val);_LIBCPP_FUNC_VIS string to_string(unsigned long long __val);_LIBCPP_FUNC_VIS string to_string(float __val);_LIBCPP_FUNC_VIS string to_string(double __val);_LIBCPP_FUNC_VIS string to_string(long double __val);_LIBCPP_FUNC_VIS int stoi (const wstring& __str, size_t* __idx = 0, int __base = 10);_LIBCPP_FUNC_VIS long stol (const wstring& __str, size_t* __idx = 0, int __base = 10);_LIBCPP_FUNC_VIS unsigned long stoul (const wstring& __str, size_t* __idx = 0, int __base = 10);_LIBCPP_FUNC_VIS long long stoll (const wstring& __str, size_t* __idx = 0, int __base = 10);_LIBCPP_FUNC_VIS unsigned long long stoull(const wstring& __str, size_t* __idx = 0, int __base = 10);_LIBCPP_FUNC_VIS float stof (const wstring& __str, size_t* __idx = 0);_LIBCPP_FUNC_VIS double stod (const wstring& __str, size_t* __idx = 0);_LIBCPP_FUNC_VIS long double stold(const wstring& __str, size_t* __idx = 0);_LIBCPP_FUNC_VIS wstring to_wstring(int __val);_LIBCPP_FUNC_VIS wstring to_wstring(unsigned __val);_LIBCPP_FUNC_VIS wstring to_wstring(long __val);_LIBCPP_FUNC_VIS wstring to_wstring(unsigned long __val);_LIBCPP_FUNC_VIS wstring to_wstring(long long __val);_LIBCPP_FUNC_VIS wstring to_wstring(unsigned long long __val);_LIBCPP_FUNC_VIS wstring to_wstring(float __val);_LIBCPP_FUNC_VIS wstring to_wstring(double __val);_LIBCPP_FUNC_VIS wstring to_wstring(long double __val);template<class _CharT, class _Traits, class _Allocator> const typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::npos;template<class _CharT, class _Traits, class _Allocator>struct _LIBCPP_TEMPLATE_VIS hash<basic_string<_CharT, _Traits, _Allocator> > : public unary_function<basic_string<_CharT, _Traits, _Allocator>, size_t>{ size_t operator()(const basic_string<_CharT, _Traits, _Allocator>& __val) const _NOEXCEPT;};template<class _CharT, class _Traits, class _Allocator>size_thash<basic_string<_CharT, _Traits, _Allocator> >::operator()( const basic_string<_CharT, _Traits, _Allocator>& __val) const _NOEXCEPT{ return __do_string_hash(__val.data(), __val.data() + __val.size());}template<class _CharT, class _Traits, class _Allocator>basic_ostream<_CharT, _Traits>&operator<<(basic_ostream<_CharT, _Traits>& __os, const basic_string<_CharT, _Traits, _Allocator>& __str);template<class _CharT, class _Traits, class _Allocator>basic_istream<_CharT, _Traits>&operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Allocator>& __str);template<class _CharT, class _Traits, class _Allocator>basic_istream<_CharT, _Traits>&getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm);template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_istream<_CharT, _Traits>&getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Allocator>& __str);#ifndef _LIBCPP_CXX03_LANGtemplate<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_istream<_CharT, _Traits>&getline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm);template<class _CharT, class _Traits, class _Allocator>inline _LIBCPP_INLINE_VISIBILITYbasic_istream<_CharT, _Traits>&getline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Allocator>& __str);#endif // _LIBCPP_CXX03_LANG#if _LIBCPP_DEBUG_LEVEL >= 2template<class _CharT, class _Traits, class _Allocator>boolbasic_string<_CharT, _Traits, _Allocator>::__dereferenceable(const const_iterator* __i) const{ return this->data() <= _VSTD::__to_raw_pointer(__i->base()) && _VSTD::__to_raw_pointer(__i->base()) < this->data() + this->size();}template<class _CharT, class _Traits, class _Allocator>boolbasic_string<_CharT, _Traits, _Allocator>::__decrementable(const const_iterator* __i) const{ return this->data() < _VSTD::__to_raw_pointer(__i->base()) && _VSTD::__to_raw_pointer(__i->base()) <= this->data() + this->size();}template<class _CharT, class _Traits, class _Allocator>boolbasic_string<_CharT, _Traits, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const{ const value_type* __p = _VSTD::__to_raw_pointer(__i->base()) + __n; return this->data() <= __p && __p <= this->data() + this->size();}template<class _CharT, class _Traits, class _Allocator>boolbasic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const{ const value_type* __p = _VSTD::__to_raw_pointer(__i->base()) + __n; return this->data() <= __p && __p < this->data() + this->size();}#endif // _LIBCPP_DEBUG_LEVEL >= 2_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_string<char>)_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_string<wchar_t>)#if _LIBCPP_STD_VER > 11 // Literal suffixes for basic_string [basic.string.literals]inline namespace literals{ inline namespace string_literals { inline _LIBCPP_INLINE_VISIBILITY basic_string<char> operator "" s( const char *__str, size_t __len ) { return basic_string<char> (__str, __len); } inline _LIBCPP_INLINE_VISIBILITY basic_string<wchar_t> operator "" s( const wchar_t *__str, size_t __len ) { return basic_string<wchar_t> (__str, __len); } inline _LIBCPP_INLINE_VISIBILITY basic_string<char16_t> operator "" s( const char16_t *__str, size_t __len ) { return basic_string<char16_t> (__str, __len); } inline _LIBCPP_INLINE_VISIBILITY basic_string<char32_t> operator "" s( const char32_t *__str, size_t __len ) { return basic_string<char32_t> (__str, __len); } }}#endif_LIBCPP_END_NAMESPACE_STD_LIBCPP_POP_MACROS#endif // _LIBCPP_STRING