type_traits 153 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704
  1. // -*- C++ -*-
  2. //===------------------------ type_traits ---------------------------------===//
  3. //
  4. // The LLVM Compiler Infrastructure
  5. //
  6. // This file is dual licensed under the MIT and the University of Illinois Open
  7. // Source Licenses. See LICENSE.TXT for details.
  8. //
  9. //===----------------------------------------------------------------------===//
  10. #ifndef _LIBCPP_TYPE_TRAITS
  11. #define _LIBCPP_TYPE_TRAITS
  12. /*
  13. type_traits synopsis
  14. namespace std
  15. {
  16. // helper class:
  17. template <class T, T v> struct integral_constant;
  18. typedef integral_constant<bool, true> true_type; // C++11
  19. typedef integral_constant<bool, false> false_type; // C++11
  20. template <bool B> // C++14
  21. using bool_constant = integral_constant<bool, B>; // C++14
  22. typedef bool_constant<true> true_type; // C++14
  23. typedef bool_constant<false> false_type; // C++14
  24. // helper traits
  25. template <bool, class T = void> struct enable_if;
  26. template <bool, class T, class F> struct conditional;
  27. // Primary classification traits:
  28. template <class T> struct is_void;
  29. template <class T> struct is_null_pointer; // C++14
  30. template <class T> struct is_integral;
  31. template <class T> struct is_floating_point;
  32. template <class T> struct is_array;
  33. template <class T> struct is_pointer;
  34. template <class T> struct is_lvalue_reference;
  35. template <class T> struct is_rvalue_reference;
  36. template <class T> struct is_member_object_pointer;
  37. template <class T> struct is_member_function_pointer;
  38. template <class T> struct is_enum;
  39. template <class T> struct is_union;
  40. template <class T> struct is_class;
  41. template <class T> struct is_function;
  42. // Secondary classification traits:
  43. template <class T> struct is_reference;
  44. template <class T> struct is_arithmetic;
  45. template <class T> struct is_fundamental;
  46. template <class T> struct is_member_pointer;
  47. template <class T> struct is_scalar;
  48. template <class T> struct is_object;
  49. template <class T> struct is_compound;
  50. // Const-volatile properties and transformations:
  51. template <class T> struct is_const;
  52. template <class T> struct is_volatile;
  53. template <class T> struct remove_const;
  54. template <class T> struct remove_volatile;
  55. template <class T> struct remove_cv;
  56. template <class T> struct add_const;
  57. template <class T> struct add_volatile;
  58. template <class T> struct add_cv;
  59. // Reference transformations:
  60. template <class T> struct remove_reference;
  61. template <class T> struct add_lvalue_reference;
  62. template <class T> struct add_rvalue_reference;
  63. // Pointer transformations:
  64. template <class T> struct remove_pointer;
  65. template <class T> struct add_pointer;
  66. // Integral properties:
  67. template <class T> struct is_signed;
  68. template <class T> struct is_unsigned;
  69. template <class T> struct make_signed;
  70. template <class T> struct make_unsigned;
  71. // Array properties and transformations:
  72. template <class T> struct rank;
  73. template <class T, unsigned I = 0> struct extent;
  74. template <class T> struct remove_extent;
  75. template <class T> struct remove_all_extents;
  76. // Member introspection:
  77. template <class T> struct is_pod;
  78. template <class T> struct is_trivial;
  79. template <class T> struct is_trivially_copyable;
  80. template <class T> struct is_standard_layout;
  81. template <class T> struct is_literal_type;
  82. template <class T> struct is_empty;
  83. template <class T> struct is_polymorphic;
  84. template <class T> struct is_abstract;
  85. template <class T> struct is_final; // C++14
  86. template <class T, class... Args> struct is_constructible;
  87. template <class T> struct is_default_constructible;
  88. template <class T> struct is_copy_constructible;
  89. template <class T> struct is_move_constructible;
  90. template <class T, class U> struct is_assignable;
  91. template <class T> struct is_copy_assignable;
  92. template <class T> struct is_move_assignable;
  93. template <class T, class U> struct is_swappable_with; // C++17
  94. template <class T> struct is_swappable; // C++17
  95. template <class T> struct is_destructible;
  96. template <class T, class... Args> struct is_trivially_constructible;
  97. template <class T> struct is_trivially_default_constructible;
  98. template <class T> struct is_trivially_copy_constructible;
  99. template <class T> struct is_trivially_move_constructible;
  100. template <class T, class U> struct is_trivially_assignable;
  101. template <class T> struct is_trivially_copy_assignable;
  102. template <class T> struct is_trivially_move_assignable;
  103. template <class T> struct is_trivially_destructible;
  104. template <class T, class... Args> struct is_nothrow_constructible;
  105. template <class T> struct is_nothrow_default_constructible;
  106. template <class T> struct is_nothrow_copy_constructible;
  107. template <class T> struct is_nothrow_move_constructible;
  108. template <class T, class U> struct is_nothrow_assignable;
  109. template <class T> struct is_nothrow_copy_assignable;
  110. template <class T> struct is_nothrow_move_assignable;
  111. template <class T, class U> struct is_nothrow_swappable_with; // C++17
  112. template <class T> struct is_nothrow_swappable; // C++17
  113. template <class T> struct is_nothrow_destructible;
  114. template <class T> struct has_virtual_destructor;
  115. // Relationships between types:
  116. template <class T, class U> struct is_same;
  117. template <class Base, class Derived> struct is_base_of;
  118. template <class From, class To> struct is_convertible;
  119. template <class, class R = void> struct is_callable; // not defined
  120. template <class Fn, class... ArgTypes, class R>
  121. struct is_callable<Fn(ArgTypes...), R>;
  122. template <class, class R = void> struct is_nothrow_callable; // not defined
  123. template <class Fn, class... ArgTypes, class R>
  124. struct is_nothrow_callable<Fn(ArgTypes...), R>;
  125. // Alignment properties and transformations:
  126. template <class T> struct alignment_of;
  127. template <size_t Len, size_t Align = most_stringent_alignment_requirement>
  128. struct aligned_storage;
  129. template <size_t Len, class... Types> struct aligned_union;
  130. template <class T> struct decay;
  131. template <class... T> struct common_type;
  132. template <class T> struct underlying_type;
  133. template <class> class result_of; // undefined
  134. template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
  135. // const-volatile modifications:
  136. template <class T>
  137. using remove_const_t = typename remove_const<T>::type; // C++14
  138. template <class T>
  139. using remove_volatile_t = typename remove_volatile<T>::type; // C++14
  140. template <class T>
  141. using remove_cv_t = typename remove_cv<T>::type; // C++14
  142. template <class T>
  143. using add_const_t = typename add_const<T>::type; // C++14
  144. template <class T>
  145. using add_volatile_t = typename add_volatile<T>::type; // C++14
  146. template <class T>
  147. using add_cv_t = typename add_cv<T>::type; // C++14
  148. // reference modifications:
  149. template <class T>
  150. using remove_reference_t = typename remove_reference<T>::type; // C++14
  151. template <class T>
  152. using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14
  153. template <class T>
  154. using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14
  155. // sign modifications:
  156. template <class T>
  157. using make_signed_t = typename make_signed<T>::type; // C++14
  158. template <class T>
  159. using make_unsigned_t = typename make_unsigned<T>::type; // C++14
  160. // array modifications:
  161. template <class T>
  162. using remove_extent_t = typename remove_extent<T>::type; // C++14
  163. template <class T>
  164. using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14
  165. // pointer modifications:
  166. template <class T>
  167. using remove_pointer_t = typename remove_pointer<T>::type; // C++14
  168. template <class T>
  169. using add_pointer_t = typename add_pointer<T>::type; // C++14
  170. // other transformations:
  171. template <size_t Len, std::size_t Align=default-alignment>
  172. using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14
  173. template <std::size_t Len, class... Types>
  174. using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14
  175. template <class T>
  176. using decay_t = typename decay<T>::type; // C++14
  177. template <bool b, class T=void>
  178. using enable_if_t = typename enable_if<b,T>::type; // C++14
  179. template <bool b, class T, class F>
  180. using conditional_t = typename conditional<b,T,F>::type; // C++14
  181. template <class... T>
  182. using common_type_t = typename common_type<T...>::type; // C++14
  183. template <class T>
  184. using underlying_type_t = typename underlying_type<T>::type; // C++14
  185. template <class F, class... ArgTypes>
  186. using result_of_t = typename result_of<F(ArgTypes...)>::type; // C++14
  187. template <class...>
  188. using void_t = void; // C++17
  189. // See C++14 20.10.4.1, primary type categories
  190. template <class T> constexpr bool is_void_v
  191. = is_void<T>::value; // C++17
  192. template <class T> constexpr bool is_null_pointer_v
  193. = is_null_pointer<T>::value; // C++17
  194. template <class T> constexpr bool is_integral_v
  195. = is_integral<T>::value; // C++17
  196. template <class T> constexpr bool is_floating_point_v
  197. = is_floating_point<T>::value; // C++17
  198. template <class T> constexpr bool is_array_v
  199. = is_array<T>::value; // C++17
  200. template <class T> constexpr bool is_pointer_v
  201. = is_pointer<T>::value; // C++17
  202. template <class T> constexpr bool is_lvalue_reference_v
  203. = is_lvalue_reference<T>::value; // C++17
  204. template <class T> constexpr bool is_rvalue_reference_v
  205. = is_rvalue_reference<T>::value; // C++17
  206. template <class T> constexpr bool is_member_object_pointer_v
  207. = is_member_object_pointer<T>::value; // C++17
  208. template <class T> constexpr bool is_member_function_pointer_v
  209. = is_member_function_pointer<T>::value; // C++17
  210. template <class T> constexpr bool is_enum_v
  211. = is_enum<T>::value; // C++17
  212. template <class T> constexpr bool is_union_v
  213. = is_union<T>::value; // C++17
  214. template <class T> constexpr bool is_class_v
  215. = is_class<T>::value; // C++17
  216. template <class T> constexpr bool is_function_v
  217. = is_function<T>::value; // C++17
  218. // See C++14 20.10.4.2, composite type categories
  219. template <class T> constexpr bool is_reference_v
  220. = is_reference<T>::value; // C++17
  221. template <class T> constexpr bool is_arithmetic_v
  222. = is_arithmetic<T>::value; // C++17
  223. template <class T> constexpr bool is_fundamental_v
  224. = is_fundamental<T>::value; // C++17
  225. template <class T> constexpr bool is_object_v
  226. = is_object<T>::value; // C++17
  227. template <class T> constexpr bool is_scalar_v
  228. = is_scalar<T>::value; // C++17
  229. template <class T> constexpr bool is_compound_v
  230. = is_compound<T>::value; // C++17
  231. template <class T> constexpr bool is_member_pointer_v
  232. = is_member_pointer<T>::value; // C++17
  233. // See C++14 20.10.4.3, type properties
  234. template <class T> constexpr bool is_const_v
  235. = is_const<T>::value; // C++17
  236. template <class T> constexpr bool is_volatile_v
  237. = is_volatile<T>::value; // C++17
  238. template <class T> constexpr bool is_trivial_v
  239. = is_trivial<T>::value; // C++17
  240. template <class T> constexpr bool is_trivially_copyable_v
  241. = is_trivially_copyable<T>::value; // C++17
  242. template <class T> constexpr bool is_standard_layout_v
  243. = is_standard_layout<T>::value; // C++17
  244. template <class T> constexpr bool is_pod_v
  245. = is_pod<T>::value; // C++17
  246. template <class T> constexpr bool is_literal_type_v
  247. = is_literal_type<T>::value; // C++17
  248. template <class T> constexpr bool is_empty_v
  249. = is_empty<T>::value; // C++17
  250. template <class T> constexpr bool is_polymorphic_v
  251. = is_polymorphic<T>::value; // C++17
  252. template <class T> constexpr bool is_abstract_v
  253. = is_abstract<T>::value; // C++17
  254. template <class T> constexpr bool is_final_v
  255. = is_final<T>::value; // C++17
  256. template <class T> constexpr bool is_signed_v
  257. = is_signed<T>::value; // C++17
  258. template <class T> constexpr bool is_unsigned_v
  259. = is_unsigned<T>::value; // C++17
  260. template <class T, class... Args> constexpr bool is_constructible_v
  261. = is_constructible<T, Args...>::value; // C++17
  262. template <class T> constexpr bool is_default_constructible_v
  263. = is_default_constructible<T>::value; // C++17
  264. template <class T> constexpr bool is_copy_constructible_v
  265. = is_copy_constructible<T>::value; // C++17
  266. template <class T> constexpr bool is_move_constructible_v
  267. = is_move_constructible<T>::value; // C++17
  268. template <class T, class U> constexpr bool is_assignable_v
  269. = is_assignable<T, U>::value; // C++17
  270. template <class T> constexpr bool is_copy_assignable_v
  271. = is_copy_assignable<T>::value; // C++17
  272. template <class T> constexpr bool is_move_assignable_v
  273. = is_move_assignable<T>::value; // C++17
  274. template <class T, class U> constexpr bool is_swappable_with_v
  275. = is_swappable_with<T, U>::value; // C++17
  276. template <class T> constexpr bool is_swappable_v
  277. = is_swappable<T>::value; // C++17
  278. template <class T> constexpr bool is_destructible_v
  279. = is_destructible<T>::value; // C++17
  280. template <class T, class... Args> constexpr bool is_trivially_constructible_v
  281. = is_trivially_constructible<T, Args...>::value; // C++17
  282. template <class T> constexpr bool is_trivially_default_constructible_v
  283. = is_trivially_default_constructible<T>::value; // C++17
  284. template <class T> constexpr bool is_trivially_copy_constructible_v
  285. = is_trivially_copy_constructible<T>::value; // C++17
  286. template <class T> constexpr bool is_trivially_move_constructible_v
  287. = is_trivially_move_constructible<T>::value; // C++17
  288. template <class T, class U> constexpr bool is_trivially_assignable_v
  289. = is_trivially_assignable<T, U>::value; // C++17
  290. template <class T> constexpr bool is_trivially_copy_assignable_v
  291. = is_trivially_copy_assignable<T>::value; // C++17
  292. template <class T> constexpr bool is_trivially_move_assignable_v
  293. = is_trivially_move_assignable<T>::value; // C++17
  294. template <class T> constexpr bool is_trivially_destructible_v
  295. = is_trivially_destructible<T>::value; // C++17
  296. template <class T, class... Args> constexpr bool is_nothrow_constructible_v
  297. = is_nothrow_constructible<T, Args...>::value; // C++17
  298. template <class T> constexpr bool is_nothrow_default_constructible_v
  299. = is_nothrow_default_constructible<T>::value; // C++17
  300. template <class T> constexpr bool is_nothrow_copy_constructible_v
  301. = is_nothrow_copy_constructible<T>::value; // C++17
  302. template <class T> constexpr bool is_nothrow_move_constructible_v
  303. = is_nothrow_move_constructible<T>::value; // C++17
  304. template <class T, class U> constexpr bool is_nothrow_assignable_v
  305. = is_nothrow_assignable<T, U>::value; // C++17
  306. template <class T> constexpr bool is_nothrow_copy_assignable_v
  307. = is_nothrow_copy_assignable<T>::value; // C++17
  308. template <class T> constexpr bool is_nothrow_move_assignable_v
  309. = is_nothrow_move_assignable<T>::value; // C++17
  310. template <class T, class U> constexpr bool is_nothrow_swappable_with_v
  311. = is_nothrow_swappable_with<T, U>::value; // C++17
  312. template <class T> constexpr bool is_nothrow_swappable_v
  313. = is_nothrow_swappable<T>::value; // C++17
  314. template <class T> constexpr bool is_nothrow_destructible_v
  315. = is_nothrow_destructible<T>::value; // C++17
  316. template <class T> constexpr bool has_virtual_destructor_v
  317. = has_virtual_destructor<T>::value; // C++17
  318. // See C++14 20.10.5, type property queries
  319. template <class T> constexpr size_t alignment_of_v
  320. = alignment_of<T>::value; // C++17
  321. template <class T> constexpr size_t rank_v
  322. = rank<T>::value; // C++17
  323. template <class T, unsigned I = 0> constexpr size_t extent_v
  324. = extent<T, I>::value; // C++17
  325. // See C++14 20.10.6, type relations
  326. template <class T, class U> constexpr bool is_same_v
  327. = is_same<T, U>::value; // C++17
  328. template <class Base, class Derived> constexpr bool is_base_of_v
  329. = is_base_of<Base, Derived>::value; // C++17
  330. template <class From, class To> constexpr bool is_convertible_v
  331. = is_convertible<From, To>::value; // C++17
  332. template <class T, class R = void> constexpr bool is_callable_v
  333. = is_callable<T, R>::value; // C++17
  334. template <class T, class R = void> constexpr bool is_nothrow_callable_v
  335. = is_nothrow_callable<T, R>::value; // C++17
  336. // [meta.logical], logical operator traits:
  337. template<class... B> struct conjunction; // C++17
  338. template<class... B>
  339. constexpr bool conjunction_v = conjunction<B...>::value; // C++17
  340. template<class... B> struct disjunction; // C++17
  341. template<class... B>
  342. constexpr bool disjunction_v = disjunction<B...>::value; // C++17
  343. template<class B> struct negation; // C++17
  344. template<class B>
  345. constexpr bool negation_v = negation<B>::value; // C++17
  346. }
  347. */
  348. #include <__config>
  349. #include <cstddef>
  350. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  351. #pragma GCC system_header
  352. #endif
  353. _LIBCPP_BEGIN_NAMESPACE_STD
  354. template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY pair;
  355. template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper;
  356. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY hash;
  357. template <class>
  358. struct __void_t { typedef void type; };
  359. template <class _Tp>
  360. struct __identity { typedef _Tp type; };
  361. template <class _Tp, bool>
  362. struct _LIBCPP_TYPE_VIS_ONLY __dependent_type : public _Tp {};
  363. template <bool _Bp, class _If, class _Then>
  364. struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _If type;};
  365. template <class _If, class _Then>
  366. struct _LIBCPP_TYPE_VIS_ONLY conditional<false, _If, _Then> {typedef _Then type;};
  367. #if _LIBCPP_STD_VER > 11
  368. template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
  369. #endif
  370. template <bool, class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __lazy_enable_if {};
  371. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __lazy_enable_if<true, _Tp> {typedef typename _Tp::type type;};
  372. template <bool, class _Tp = void> struct _LIBCPP_TYPE_VIS_ONLY enable_if {};
  373. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY enable_if<true, _Tp> {typedef _Tp type;};
  374. #if _LIBCPP_STD_VER > 11
  375. template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
  376. #endif
  377. // addressof
  378. #if __has_builtin(__builtin_addressof)
  379. template <class _Tp>
  380. inline _LIBCPP_CONSTEXPR_AFTER_CXX14
  381. _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
  382. _Tp*
  383. addressof(_Tp& __x) _NOEXCEPT
  384. {
  385. return __builtin_addressof(__x);
  386. }
  387. #else
  388. template <class _Tp>
  389. inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
  390. _Tp*
  391. addressof(_Tp& __x) _NOEXCEPT
  392. {
  393. return (_Tp*)&reinterpret_cast<const volatile char&>(__x);
  394. }
  395. #endif // __has_builtin(__builtin_addressof)
  396. #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
  397. // Objective-C++ Automatic Reference Counting uses qualified pointers
  398. // that require special addressof() signatures. When
  399. // _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
  400. // itself is providing these definitions. Otherwise, we provide them.
  401. template <class _Tp>
  402. inline _LIBCPP_INLINE_VISIBILITY
  403. __strong _Tp*
  404. addressof(__strong _Tp& __x) _NOEXCEPT
  405. {
  406. return &__x;
  407. }
  408. #ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
  409. template <class _Tp>
  410. inline _LIBCPP_INLINE_VISIBILITY
  411. __weak _Tp*
  412. addressof(__weak _Tp& __x) _NOEXCEPT
  413. {
  414. return &__x;
  415. }
  416. #endif
  417. template <class _Tp>
  418. inline _LIBCPP_INLINE_VISIBILITY
  419. __autoreleasing _Tp*
  420. addressof(__autoreleasing _Tp& __x) _NOEXCEPT
  421. {
  422. return &__x;
  423. }
  424. template <class _Tp>
  425. inline _LIBCPP_INLINE_VISIBILITY
  426. __unsafe_unretained _Tp*
  427. addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
  428. {
  429. return &__x;
  430. }
  431. #endif
  432. struct __two {char __lx[2];};
  433. // helper class:
  434. template <class _Tp, _Tp __v>
  435. struct _LIBCPP_TYPE_VIS_ONLY integral_constant
  436. {
  437. static _LIBCPP_CONSTEXPR const _Tp value = __v;
  438. typedef _Tp value_type;
  439. typedef integral_constant type;
  440. _LIBCPP_INLINE_VISIBILITY
  441. _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
  442. #if _LIBCPP_STD_VER > 11
  443. _LIBCPP_INLINE_VISIBILITY
  444. constexpr value_type operator ()() const _NOEXCEPT {return value;}
  445. #endif
  446. };
  447. template <class _Tp, _Tp __v>
  448. _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
  449. #if _LIBCPP_STD_VER > 14
  450. template <bool __b>
  451. using bool_constant = integral_constant<bool, __b>;
  452. #define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)>
  453. #else
  454. #define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)>
  455. #endif
  456. typedef _LIBCPP_BOOL_CONSTANT(true) true_type;
  457. typedef _LIBCPP_BOOL_CONSTANT(false) false_type;
  458. #if !defined(_LIBCPP_HAS_NO_VARIADICS)
  459. // __lazy_and
  460. template <bool _Last, class ..._Preds>
  461. struct __lazy_and_impl;
  462. template <class ..._Preds>
  463. struct __lazy_and_impl<false, _Preds...> : false_type {};
  464. template <>
  465. struct __lazy_and_impl<true> : true_type {};
  466. template <class _Pred>
  467. struct __lazy_and_impl<true, _Pred> : integral_constant<bool, _Pred::type::value> {};
  468. template <class _Hp, class ..._Tp>
  469. struct __lazy_and_impl<true, _Hp, _Tp...> : __lazy_and_impl<_Hp::type::value, _Tp...> {};
  470. template <class _P1, class ..._Pr>
  471. struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {};
  472. // __lazy_or
  473. template <bool _List, class ..._Preds>
  474. struct __lazy_or_impl;
  475. template <class ..._Preds>
  476. struct __lazy_or_impl<true, _Preds...> : true_type {};
  477. template <>
  478. struct __lazy_or_impl<false> : false_type {};
  479. template <class _Hp, class ..._Tp>
  480. struct __lazy_or_impl<false, _Hp, _Tp...>
  481. : __lazy_or_impl<_Hp::type::value, _Tp...> {};
  482. template <class _P1, class ..._Pr>
  483. struct __lazy_or : __lazy_or_impl<_P1::type::value, _Pr...> {};
  484. // __lazy_not
  485. template <class _Pred>
  486. struct __lazy_not : integral_constant<bool, !_Pred::type::value> {};
  487. // __and_
  488. template<class...> struct __and_;
  489. template<> struct __and_<> : true_type {};
  490. template<class _B0> struct __and_<_B0> : _B0 {};
  491. template<class _B0, class _B1>
  492. struct __and_<_B0, _B1> : conditional<_B0::value, _B1, _B0>::type {};
  493. template<class _B0, class _B1, class _B2, class... _Bn>
  494. struct __and_<_B0, _B1, _B2, _Bn...>
  495. : conditional<_B0::value, __and_<_B1, _B2, _Bn...>, _B0>::type {};
  496. // __or_
  497. template<class...> struct __or_;
  498. template<> struct __or_<> : false_type {};
  499. template<class _B0> struct __or_<_B0> : _B0 {};
  500. template<class _B0, class _B1>
  501. struct __or_<_B0, _B1> : conditional<_B0::value, _B0, _B1>::type {};
  502. template<class _B0, class _B1, class _B2, class... _Bn>
  503. struct __or_<_B0, _B1, _B2, _Bn...>
  504. : conditional<_B0::value, _B0, __or_<_B1, _B2, _Bn...> >::type {};
  505. // __not_
  506. template<class _Tp>
  507. struct __not_ : conditional<_Tp::value, false_type, true_type>::type {};
  508. #endif // !defined(_LIBCPP_HAS_NO_VARIADICS)
  509. // is_const
  510. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const : public false_type {};
  511. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const<_Tp const> : public true_type {};
  512. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  513. template <class _Tp> _LIBCPP_CONSTEXPR bool is_const_v
  514. = is_const<_Tp>::value;
  515. #endif
  516. // is_volatile
  517. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile : public false_type {};
  518. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile<_Tp volatile> : public true_type {};
  519. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  520. template <class _Tp> _LIBCPP_CONSTEXPR bool is_volatile_v
  521. = is_volatile<_Tp>::value;
  522. #endif
  523. // remove_const
  524. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const {typedef _Tp type;};
  525. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const<const _Tp> {typedef _Tp type;};
  526. #if _LIBCPP_STD_VER > 11
  527. template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
  528. #endif
  529. // remove_volatile
  530. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile {typedef _Tp type;};
  531. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile<volatile _Tp> {typedef _Tp type;};
  532. #if _LIBCPP_STD_VER > 11
  533. template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
  534. #endif
  535. // remove_cv
  536. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_cv
  537. {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
  538. #if _LIBCPP_STD_VER > 11
  539. template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
  540. #endif
  541. // is_void
  542. template <class _Tp> struct __libcpp_is_void : public false_type {};
  543. template <> struct __libcpp_is_void<void> : public true_type {};
  544. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_void
  545. : public __libcpp_is_void<typename remove_cv<_Tp>::type> {};
  546. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  547. template <class _Tp> _LIBCPP_CONSTEXPR bool is_void_v
  548. = is_void<_Tp>::value;
  549. #endif
  550. // __is_nullptr_t
  551. template <class _Tp> struct __is_nullptr_t_impl : public false_type {};
  552. template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
  553. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __is_nullptr_t
  554. : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
  555. #if _LIBCPP_STD_VER > 11
  556. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_null_pointer
  557. : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
  558. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  559. template <class _Tp> _LIBCPP_CONSTEXPR bool is_null_pointer_v
  560. = is_null_pointer<_Tp>::value;
  561. #endif
  562. #endif
  563. // is_integral
  564. template <class _Tp> struct __libcpp_is_integral : public false_type {};
  565. template <> struct __libcpp_is_integral<bool> : public true_type {};
  566. template <> struct __libcpp_is_integral<char> : public true_type {};
  567. template <> struct __libcpp_is_integral<signed char> : public true_type {};
  568. template <> struct __libcpp_is_integral<unsigned char> : public true_type {};
  569. template <> struct __libcpp_is_integral<wchar_t> : public true_type {};
  570. #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
  571. template <> struct __libcpp_is_integral<char16_t> : public true_type {};
  572. template <> struct __libcpp_is_integral<char32_t> : public true_type {};
  573. #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
  574. template <> struct __libcpp_is_integral<short> : public true_type {};
  575. template <> struct __libcpp_is_integral<unsigned short> : public true_type {};
  576. template <> struct __libcpp_is_integral<int> : public true_type {};
  577. template <> struct __libcpp_is_integral<unsigned int> : public true_type {};
  578. template <> struct __libcpp_is_integral<long> : public true_type {};
  579. template <> struct __libcpp_is_integral<unsigned long> : public true_type {};
  580. template <> struct __libcpp_is_integral<long long> : public true_type {};
  581. template <> struct __libcpp_is_integral<unsigned long long> : public true_type {};
  582. #ifndef _LIBCPP_HAS_NO_INT128
  583. template <> struct __libcpp_is_integral<__int128_t> : public true_type {};
  584. template <> struct __libcpp_is_integral<__uint128_t> : public true_type {};
  585. #endif
  586. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_integral
  587. : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {};
  588. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  589. template <class _Tp> _LIBCPP_CONSTEXPR bool is_integral_v
  590. = is_integral<_Tp>::value;
  591. #endif
  592. // is_floating_point
  593. template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
  594. template <> struct __libcpp_is_floating_point<float> : public true_type {};
  595. template <> struct __libcpp_is_floating_point<double> : public true_type {};
  596. template <> struct __libcpp_is_floating_point<long double> : public true_type {};
  597. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_floating_point
  598. : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
  599. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  600. template <class _Tp> _LIBCPP_CONSTEXPR bool is_floating_point_v
  601. = is_floating_point<_Tp>::value;
  602. #endif
  603. // is_array
  604. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array
  605. : public false_type {};
  606. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[]>
  607. : public true_type {};
  608. template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[_Np]>
  609. : public true_type {};
  610. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  611. template <class _Tp> _LIBCPP_CONSTEXPR bool is_array_v
  612. = is_array<_Tp>::value;
  613. #endif
  614. // is_pointer
  615. template <class _Tp> struct __libcpp_is_pointer : public false_type {};
  616. template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
  617. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pointer
  618. : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {};
  619. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  620. template <class _Tp> _LIBCPP_CONSTEXPR bool is_pointer_v
  621. = is_pointer<_Tp>::value;
  622. #endif
  623. // is_reference
  624. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference : public false_type {};
  625. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference<_Tp&> : public true_type {};
  626. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference : public false_type {};
  627. #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  628. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference<_Tp&&> : public true_type {};
  629. #endif
  630. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference : public false_type {};
  631. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&> : public true_type {};
  632. #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  633. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&&> : public true_type {};
  634. #endif
  635. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  636. template <class _Tp> _LIBCPP_CONSTEXPR bool is_reference_v
  637. = is_reference<_Tp>::value;
  638. template <class _Tp> _LIBCPP_CONSTEXPR bool is_lvalue_reference_v
  639. = is_lvalue_reference<_Tp>::value;
  640. template <class _Tp> _LIBCPP_CONSTEXPR bool is_rvalue_reference_v
  641. = is_rvalue_reference<_Tp>::value;
  642. #endif
  643. // is_union
  644. #if __has_feature(is_union) || (_GNUC_VER >= 403)
  645. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union
  646. : public integral_constant<bool, __is_union(_Tp)> {};
  647. #else
  648. template <class _Tp> struct __libcpp_union : public false_type {};
  649. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union
  650. : public __libcpp_union<typename remove_cv<_Tp>::type> {};
  651. #endif
  652. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  653. template <class _Tp> _LIBCPP_CONSTEXPR bool is_union_v
  654. = is_union<_Tp>::value;
  655. #endif
  656. // is_class
  657. #if __has_feature(is_class) || (_GNUC_VER >= 403)
  658. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class
  659. : public integral_constant<bool, __is_class(_Tp)> {};
  660. #else
  661. namespace __is_class_imp
  662. {
  663. template <class _Tp> char __test(int _Tp::*);
  664. template <class _Tp> __two __test(...);
  665. }
  666. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class
  667. : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {};
  668. #endif
  669. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  670. template <class _Tp> _LIBCPP_CONSTEXPR bool is_class_v
  671. = is_class<_Tp>::value;
  672. #endif
  673. // is_same
  674. template <class _Tp, class _Up> struct _LIBCPP_TYPE_VIS_ONLY is_same : public false_type {};
  675. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_same<_Tp, _Tp> : public true_type {};
  676. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  677. template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_same_v
  678. = is_same<_Tp, _Up>::value;
  679. #endif
  680. // is_function
  681. namespace __libcpp_is_function_imp
  682. {
  683. struct __dummy_type {};
  684. template <class _Tp> char __test(_Tp*);
  685. template <class _Tp> char __test(__dummy_type);
  686. template <class _Tp> __two __test(...);
  687. template <class _Tp> _Tp& __source(int);
  688. template <class _Tp> __dummy_type __source(...);
  689. }
  690. template <class _Tp, bool = is_class<_Tp>::value ||
  691. is_union<_Tp>::value ||
  692. is_void<_Tp>::value ||
  693. is_reference<_Tp>::value ||
  694. __is_nullptr_t<_Tp>::value >
  695. struct __libcpp_is_function
  696. : public integral_constant<bool, sizeof(__libcpp_is_function_imp::__test<_Tp>(__libcpp_is_function_imp::__source<_Tp>(0))) == 1>
  697. {};
  698. template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {};
  699. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_function
  700. : public __libcpp_is_function<_Tp> {};
  701. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  702. template <class _Tp> _LIBCPP_CONSTEXPR bool is_function_v
  703. = is_function<_Tp>::value;
  704. #endif
  705. // is_member_function_pointer
  706. // template <class _Tp> struct __libcpp_is_member_function_pointer : public false_type {};
  707. // template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
  708. //
  709. template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
  710. struct __member_pointer_traits_imp
  711. { // forward declaration; specializations later
  712. };
  713. template <class _Tp> struct __libcpp_is_member_function_pointer
  714. : public false_type {};
  715. template <class _Ret, class _Class>
  716. struct __libcpp_is_member_function_pointer<_Ret _Class::*>
  717. : public is_function<_Ret> {};
  718. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer
  719. : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type>::type {};
  720. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  721. template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
  722. = is_member_function_pointer<_Tp>::value;
  723. #endif
  724. // is_member_pointer
  725. template <class _Tp> struct __libcpp_is_member_pointer : public false_type {};
  726. template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {};
  727. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_pointer
  728. : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {};
  729. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  730. template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_pointer_v
  731. = is_member_pointer<_Tp>::value;
  732. #endif
  733. // is_member_object_pointer
  734. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_object_pointer
  735. : public integral_constant<bool, is_member_pointer<_Tp>::value &&
  736. !is_member_function_pointer<_Tp>::value> {};
  737. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  738. template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
  739. = is_member_object_pointer<_Tp>::value;
  740. #endif
  741. // is_enum
  742. #if __has_feature(is_enum) || (_GNUC_VER >= 403)
  743. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum
  744. : public integral_constant<bool, __is_enum(_Tp)> {};
  745. #else
  746. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum
  747. : public integral_constant<bool, !is_void<_Tp>::value &&
  748. !is_integral<_Tp>::value &&
  749. !is_floating_point<_Tp>::value &&
  750. !is_array<_Tp>::value &&
  751. !is_pointer<_Tp>::value &&
  752. !is_reference<_Tp>::value &&
  753. !is_member_pointer<_Tp>::value &&
  754. !is_union<_Tp>::value &&
  755. !is_class<_Tp>::value &&
  756. !is_function<_Tp>::value > {};
  757. #endif
  758. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  759. template <class _Tp> _LIBCPP_CONSTEXPR bool is_enum_v
  760. = is_enum<_Tp>::value;
  761. #endif
  762. // is_arithmetic
  763. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_arithmetic
  764. : public integral_constant<bool, is_integral<_Tp>::value ||
  765. is_floating_point<_Tp>::value> {};
  766. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  767. template <class _Tp> _LIBCPP_CONSTEXPR bool is_arithmetic_v
  768. = is_arithmetic<_Tp>::value;
  769. #endif
  770. // is_fundamental
  771. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_fundamental
  772. : public integral_constant<bool, is_void<_Tp>::value ||
  773. __is_nullptr_t<_Tp>::value ||
  774. is_arithmetic<_Tp>::value> {};
  775. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  776. template <class _Tp> _LIBCPP_CONSTEXPR bool is_fundamental_v
  777. = is_fundamental<_Tp>::value;
  778. #endif
  779. // is_scalar
  780. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_scalar
  781. : public integral_constant<bool, is_arithmetic<_Tp>::value ||
  782. is_member_pointer<_Tp>::value ||
  783. is_pointer<_Tp>::value ||
  784. __is_nullptr_t<_Tp>::value ||
  785. is_enum<_Tp>::value > {};
  786. template <> struct _LIBCPP_TYPE_VIS_ONLY is_scalar<nullptr_t> : public true_type {};
  787. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  788. template <class _Tp> _LIBCPP_CONSTEXPR bool is_scalar_v
  789. = is_scalar<_Tp>::value;
  790. #endif
  791. // is_object
  792. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_object
  793. : public integral_constant<bool, is_scalar<_Tp>::value ||
  794. is_array<_Tp>::value ||
  795. is_union<_Tp>::value ||
  796. is_class<_Tp>::value > {};
  797. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  798. template <class _Tp> _LIBCPP_CONSTEXPR bool is_object_v
  799. = is_object<_Tp>::value;
  800. #endif
  801. // is_compound
  802. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_compound
  803. : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
  804. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  805. template <class _Tp> _LIBCPP_CONSTEXPR bool is_compound_v
  806. = is_compound<_Tp>::value;
  807. #endif
  808. // __is_referenceable [defns.referenceable]
  809. struct __is_referenceable_impl {
  810. template <class _Tp> static _Tp& __test(int);
  811. template <class _Tp> static __two __test(...);
  812. };
  813. template <class _Tp>
  814. struct __is_referenceable : integral_constant<bool,
  815. !is_same<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {};
  816. // add_const
  817. template <class _Tp, bool = is_reference<_Tp>::value ||
  818. is_function<_Tp>::value ||
  819. is_const<_Tp>::value >
  820. struct __add_const {typedef _Tp type;};
  821. template <class _Tp>
  822. struct __add_const<_Tp, false> {typedef const _Tp type;};
  823. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_const
  824. {typedef typename __add_const<_Tp>::type type;};
  825. #if _LIBCPP_STD_VER > 11
  826. template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
  827. #endif
  828. // add_volatile
  829. template <class _Tp, bool = is_reference<_Tp>::value ||
  830. is_function<_Tp>::value ||
  831. is_volatile<_Tp>::value >
  832. struct __add_volatile {typedef _Tp type;};
  833. template <class _Tp>
  834. struct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
  835. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_volatile
  836. {typedef typename __add_volatile<_Tp>::type type;};
  837. #if _LIBCPP_STD_VER > 11
  838. template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
  839. #endif
  840. // add_cv
  841. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_cv
  842. {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
  843. #if _LIBCPP_STD_VER > 11
  844. template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
  845. #endif
  846. // remove_reference
  847. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference {typedef _Tp type;};
  848. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&> {typedef _Tp type;};
  849. #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  850. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&&> {typedef _Tp type;};
  851. #endif
  852. #if _LIBCPP_STD_VER > 11
  853. template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
  854. #endif
  855. // add_lvalue_reference
  856. template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _Tp type; };
  857. template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _Tp& type; };
  858. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference
  859. {typedef typename __add_lvalue_reference_impl<_Tp>::type type;};
  860. #if _LIBCPP_STD_VER > 11
  861. template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
  862. #endif
  863. #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  864. template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _Tp type; };
  865. template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _Tp&& type; };
  866. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference
  867. {typedef typename __add_rvalue_reference_impl<_Tp>::type type;};
  868. #if _LIBCPP_STD_VER > 11
  869. template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
  870. #endif
  871. #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
  872. #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  873. template <class _Tp> _Tp&& __declval(int);
  874. template <class _Tp> _Tp __declval(long);
  875. template <class _Tp>
  876. decltype(_VSTD::__declval<_Tp>(0))
  877. declval() _NOEXCEPT;
  878. #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
  879. template <class _Tp>
  880. typename add_lvalue_reference<_Tp>::type
  881. declval();
  882. #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
  883. // __uncvref
  884. template <class _Tp>
  885. struct __uncvref {
  886. typedef typename remove_cv<typename remove_reference<_Tp>::type>::type type;
  887. };
  888. template <class _Tp>
  889. struct __unconstref {
  890. typedef typename remove_const<typename remove_reference<_Tp>::type>::type type;
  891. };
  892. // __is_same_uncvref
  893. template <class _Tp, class _Up>
  894. struct __is_same_uncvref : is_same<typename __uncvref<_Tp>::type,
  895. typename __uncvref<_Up>::type> {};
  896. struct __any
  897. {
  898. __any(...);
  899. };
  900. // remove_pointer
  901. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer {typedef _Tp type;};
  902. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp*> {typedef _Tp type;};
  903. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const> {typedef _Tp type;};
  904. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* volatile> {typedef _Tp type;};
  905. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const volatile> {typedef _Tp type;};
  906. #if _LIBCPP_STD_VER > 11
  907. template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
  908. #endif
  909. // add_pointer
  910. template <class _Tp,
  911. bool = __is_referenceable<_Tp>::value ||
  912. is_same<typename remove_cv<_Tp>::type, void>::value>
  913. struct __add_pointer_impl
  914. {typedef typename remove_reference<_Tp>::type* type;};
  915. template <class _Tp> struct __add_pointer_impl<_Tp, false>
  916. {typedef _Tp type;};
  917. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_pointer
  918. {typedef typename __add_pointer_impl<_Tp>::type type;};
  919. #if _LIBCPP_STD_VER > 11
  920. template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
  921. #endif
  922. // is_signed
  923. template <class _Tp, bool = is_integral<_Tp>::value>
  924. struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
  925. template <class _Tp>
  926. struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
  927. template <class _Tp, bool = is_arithmetic<_Tp>::value>
  928. struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
  929. template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
  930. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_signed : public __libcpp_is_signed<_Tp> {};
  931. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  932. template <class _Tp> _LIBCPP_CONSTEXPR bool is_signed_v
  933. = is_signed<_Tp>::value;
  934. #endif
  935. // is_unsigned
  936. template <class _Tp, bool = is_integral<_Tp>::value>
  937. struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
  938. template <class _Tp>
  939. struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point
  940. template <class _Tp, bool = is_arithmetic<_Tp>::value>
  941. struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
  942. template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
  943. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_unsigned : public __libcpp_is_unsigned<_Tp> {};
  944. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  945. template <class _Tp> _LIBCPP_CONSTEXPR bool is_unsigned_v
  946. = is_unsigned<_Tp>::value;
  947. #endif
  948. // rank
  949. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank
  950. : public integral_constant<size_t, 0> {};
  951. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[]>
  952. : public integral_constant<size_t, rank<_Tp>::value + 1> {};
  953. template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[_Np]>
  954. : public integral_constant<size_t, rank<_Tp>::value + 1> {};
  955. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  956. template <class _Tp> _LIBCPP_CONSTEXPR size_t rank_v
  957. = rank<_Tp>::value;
  958. #endif
  959. // extent
  960. template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TYPE_VIS_ONLY extent
  961. : public integral_constant<size_t, 0> {};
  962. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], 0>
  963. : public integral_constant<size_t, 0> {};
  964. template <class _Tp, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], _Ip>
  965. : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
  966. template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], 0>
  967. : public integral_constant<size_t, _Np> {};
  968. template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], _Ip>
  969. : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
  970. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  971. template <class _Tp, unsigned _Ip = 0> _LIBCPP_CONSTEXPR size_t extent_v
  972. = extent<_Tp, _Ip>::value;
  973. #endif
  974. // remove_extent
  975. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent
  976. {typedef _Tp type;};
  977. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[]>
  978. {typedef _Tp type;};
  979. template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[_Np]>
  980. {typedef _Tp type;};
  981. #if _LIBCPP_STD_VER > 11
  982. template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
  983. #endif
  984. // remove_all_extents
  985. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents
  986. {typedef _Tp type;};
  987. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[]>
  988. {typedef typename remove_all_extents<_Tp>::type type;};
  989. template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[_Np]>
  990. {typedef typename remove_all_extents<_Tp>::type type;};
  991. #if _LIBCPP_STD_VER > 11
  992. template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
  993. #endif
  994. // decay
  995. template <class _Tp>
  996. struct _LIBCPP_TYPE_VIS_ONLY decay
  997. {
  998. private:
  999. typedef typename remove_reference<_Tp>::type _Up;
  1000. public:
  1001. typedef typename conditional
  1002. <
  1003. is_array<_Up>::value,
  1004. typename remove_extent<_Up>::type*,
  1005. typename conditional
  1006. <
  1007. is_function<_Up>::value,
  1008. typename add_pointer<_Up>::type,
  1009. typename remove_cv<_Up>::type
  1010. >::type
  1011. >::type type;
  1012. };
  1013. #if _LIBCPP_STD_VER > 11
  1014. template <class _Tp> using decay_t = typename decay<_Tp>::type;
  1015. #endif
  1016. // is_abstract
  1017. namespace __is_abstract_imp
  1018. {
  1019. template <class _Tp> char __test(_Tp (*)[1]);
  1020. template <class _Tp> __two __test(...);
  1021. }
  1022. template <class _Tp, bool = is_class<_Tp>::value>
  1023. struct __libcpp_abstract : public integral_constant<bool, sizeof(__is_abstract_imp::__test<_Tp>(0)) != 1> {};
  1024. template <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {};
  1025. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_abstract<_Tp> {};
  1026. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  1027. template <class _Tp> _LIBCPP_CONSTEXPR bool is_abstract_v
  1028. = is_abstract<_Tp>::value;
  1029. #endif
  1030. // is_final
  1031. #if defined(_LIBCPP_HAS_IS_FINAL)
  1032. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
  1033. __libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
  1034. #else
  1035. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
  1036. __libcpp_is_final : public false_type {};
  1037. #endif
  1038. #if defined(_LIBCPP_HAS_IS_FINAL) && _LIBCPP_STD_VER > 11
  1039. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
  1040. is_final : public integral_constant<bool, __is_final(_Tp)> {};
  1041. #endif
  1042. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  1043. template <class _Tp> _LIBCPP_CONSTEXPR bool is_final_v
  1044. = is_final<_Tp>::value;
  1045. #endif
  1046. // is_base_of
  1047. #ifdef _LIBCPP_HAS_IS_BASE_OF
  1048. template <class _Bp, class _Dp>
  1049. struct _LIBCPP_TYPE_VIS_ONLY is_base_of
  1050. : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
  1051. #else // _LIBCPP_HAS_IS_BASE_OF
  1052. namespace __is_base_of_imp
  1053. {
  1054. template <class _Tp>
  1055. struct _Dst
  1056. {
  1057. _Dst(const volatile _Tp &);
  1058. };
  1059. template <class _Tp>
  1060. struct _Src
  1061. {
  1062. operator const volatile _Tp &();
  1063. template <class _Up> operator const _Dst<_Up> &();
  1064. };
  1065. template <size_t> struct __one { typedef char type; };
  1066. template <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int);
  1067. template <class _Bp, class _Dp> __two __test(...);
  1068. }
  1069. template <class _Bp, class _Dp>
  1070. struct _LIBCPP_TYPE_VIS_ONLY is_base_of
  1071. : public integral_constant<bool, is_class<_Bp>::value &&
  1072. sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {};
  1073. #endif // _LIBCPP_HAS_IS_BASE_OF
  1074. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  1075. template <class _Bp, class _Dp> _LIBCPP_CONSTEXPR bool is_base_of_v
  1076. = is_base_of<_Bp, _Dp>::value;
  1077. #endif
  1078. // is_convertible
  1079. #if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
  1080. template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
  1081. : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
  1082. !is_abstract<_T2>::value> {};
  1083. #else // __has_feature(is_convertible_to)
  1084. namespace __is_convertible_imp
  1085. {
  1086. template <class _Tp> void __test_convert(_Tp);
  1087. template <class _From, class _To, class = void>
  1088. struct __is_convertible_test : public false_type {};
  1089. template <class _From, class _To>
  1090. struct __is_convertible_test<_From, _To,
  1091. decltype(_VSTD::__is_convertible_imp::__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
  1092. {};
  1093. template <class _Tp, bool _IsArray = is_array<_Tp>::value,
  1094. bool _IsFunction = is_function<_Tp>::value,
  1095. bool _IsVoid = is_void<_Tp>::value>
  1096. struct __is_array_function_or_void {enum {value = 0};};
  1097. template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
  1098. template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
  1099. template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
  1100. }
  1101. template <class _Tp,
  1102. unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
  1103. struct __is_convertible_check
  1104. {
  1105. static const size_t __v = 0;
  1106. };
  1107. template <class _Tp>
  1108. struct __is_convertible_check<_Tp, 0>
  1109. {
  1110. static const size_t __v = sizeof(_Tp);
  1111. };
  1112. template <class _T1, class _T2,
  1113. unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
  1114. unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
  1115. struct __is_convertible
  1116. : public integral_constant<bool,
  1117. __is_convertible_imp::__is_convertible_test<_T1, _T2>::value
  1118. #if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
  1119. && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
  1120. && (!is_const<typename remove_reference<_T2>::type>::value
  1121. || is_volatile<typename remove_reference<_T2>::type>::value)
  1122. && (is_same<typename remove_cv<_T1>::type,
  1123. typename remove_cv<typename remove_reference<_T2>::type>::type>::value
  1124. || is_base_of<typename remove_reference<_T2>::type, _T1>::value))
  1125. #endif
  1126. >
  1127. {};
  1128. template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
  1129. template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
  1130. template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
  1131. template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
  1132. template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
  1133. template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
  1134. template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
  1135. template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
  1136. template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
  1137. template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
  1138. template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
  1139. template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
  1140. template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
  1141. : public __is_convertible<_T1, _T2>
  1142. {
  1143. static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
  1144. static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
  1145. };
  1146. #endif // __has_feature(is_convertible_to)
  1147. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  1148. template <class _From, class _To> _LIBCPP_CONSTEXPR bool is_convertible_v
  1149. = is_convertible<_From, _To>::value;
  1150. #endif
  1151. // is_empty
  1152. #if __has_feature(is_empty) || (_GNUC_VER >= 407)
  1153. template <class _Tp>
  1154. struct _LIBCPP_TYPE_VIS_ONLY is_empty
  1155. : public integral_constant<bool, __is_empty(_Tp)> {};
  1156. #else // __has_feature(is_empty)
  1157. template <class _Tp>
  1158. struct __is_empty1
  1159. : public _Tp
  1160. {
  1161. double __lx;
  1162. };
  1163. struct __is_empty2
  1164. {
  1165. double __lx;
  1166. };
  1167. template <class _Tp, bool = is_class<_Tp>::value>
  1168. struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
  1169. template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
  1170. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_empty : public __libcpp_empty<_Tp> {};
  1171. #endif // __has_feature(is_empty)
  1172. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  1173. template <class _Tp> _LIBCPP_CONSTEXPR bool is_empty_v
  1174. = is_empty<_Tp>::value;
  1175. #endif
  1176. // is_polymorphic
  1177. #if __has_feature(is_polymorphic) || defined(_LIBCPP_MSVC)
  1178. template <class _Tp>
  1179. struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic
  1180. : public integral_constant<bool, __is_polymorphic(_Tp)> {};
  1181. #else
  1182. template<typename _Tp> char &__is_polymorphic_impl(
  1183. typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
  1184. int>::type);
  1185. template<typename _Tp> __two &__is_polymorphic_impl(...);
  1186. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic
  1187. : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
  1188. #endif // __has_feature(is_polymorphic)
  1189. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  1190. template <class _Tp> _LIBCPP_CONSTEXPR bool is_polymorphic_v
  1191. = is_polymorphic<_Tp>::value;
  1192. #endif
  1193. // has_virtual_destructor
  1194. #if __has_feature(has_virtual_destructor) || (_GNUC_VER >= 403)
  1195. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor
  1196. : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
  1197. #else
  1198. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor
  1199. : public false_type {};
  1200. #endif
  1201. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  1202. template <class _Tp> _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
  1203. = has_virtual_destructor<_Tp>::value;
  1204. #endif
  1205. // alignment_of
  1206. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY alignment_of
  1207. : public integral_constant<size_t, __alignof__(_Tp)> {};
  1208. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  1209. template <class _Tp> _LIBCPP_CONSTEXPR size_t alignment_of_v
  1210. = alignment_of<_Tp>::value;
  1211. #endif
  1212. // aligned_storage
  1213. template <class _Hp, class _Tp>
  1214. struct __type_list
  1215. {
  1216. typedef _Hp _Head;
  1217. typedef _Tp _Tail;
  1218. };
  1219. struct __nat
  1220. {
  1221. #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
  1222. __nat() = delete;
  1223. __nat(const __nat&) = delete;
  1224. __nat& operator=(const __nat&) = delete;
  1225. ~__nat() = delete;
  1226. #endif
  1227. };
  1228. template <class _Tp>
  1229. struct __align_type
  1230. {
  1231. static const size_t value = alignment_of<_Tp>::value;
  1232. typedef _Tp type;
  1233. };
  1234. struct __struct_double {long double __lx;};
  1235. struct __struct_double4 {double __lx[4];};
  1236. typedef
  1237. __type_list<__align_type<unsigned char>,
  1238. __type_list<__align_type<unsigned short>,
  1239. __type_list<__align_type<unsigned int>,
  1240. __type_list<__align_type<unsigned long>,
  1241. __type_list<__align_type<unsigned long long>,
  1242. __type_list<__align_type<double>,
  1243. __type_list<__align_type<long double>,
  1244. __type_list<__align_type<__struct_double>,
  1245. __type_list<__align_type<__struct_double4>,
  1246. __type_list<__align_type<int*>,
  1247. __nat
  1248. > > > > > > > > > > __all_types;
  1249. template <class _TL, size_t _Align> struct __find_pod;
  1250. template <class _Hp, size_t _Align>
  1251. struct __find_pod<__type_list<_Hp, __nat>, _Align>
  1252. {
  1253. typedef typename conditional<
  1254. _Align == _Hp::value,
  1255. typename _Hp::type,
  1256. void
  1257. >::type type;
  1258. };
  1259. template <class _Hp, class _Tp, size_t _Align>
  1260. struct __find_pod<__type_list<_Hp, _Tp>, _Align>
  1261. {
  1262. typedef typename conditional<
  1263. _Align == _Hp::value,
  1264. typename _Hp::type,
  1265. typename __find_pod<_Tp, _Align>::type
  1266. >::type type;
  1267. };
  1268. template <class _TL, size_t _Len> struct __find_max_align;
  1269. template <class _Hp, size_t _Len>
  1270. struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
  1271. template <size_t _Len, size_t _A1, size_t _A2>
  1272. struct __select_align
  1273. {
  1274. private:
  1275. static const size_t __min = _A2 < _A1 ? _A2 : _A1;
  1276. static const size_t __max = _A1 < _A2 ? _A2 : _A1;
  1277. public:
  1278. static const size_t value = _Len < __max ? __min : __max;
  1279. };
  1280. template <class _Hp, class _Tp, size_t _Len>
  1281. struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
  1282. : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
  1283. template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
  1284. struct _LIBCPP_TYPE_VIS_ONLY aligned_storage
  1285. {
  1286. typedef typename __find_pod<__all_types, _Align>::type _Aligner;
  1287. static_assert(!is_void<_Aligner>::value, "");
  1288. union type
  1289. {
  1290. _Aligner __align;
  1291. unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
  1292. };
  1293. };
  1294. #if _LIBCPP_STD_VER > 11
  1295. template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
  1296. using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
  1297. #endif
  1298. #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
  1299. template <size_t _Len>\
  1300. struct _LIBCPP_TYPE_VIS_ONLY aligned_storage<_Len, n>\
  1301. {\
  1302. struct _ALIGNAS(n) type\
  1303. {\
  1304. unsigned char __lx[(_Len + n - 1)/n * n];\
  1305. };\
  1306. }
  1307. _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
  1308. _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
  1309. _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
  1310. _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
  1311. _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
  1312. _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
  1313. _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
  1314. _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
  1315. _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
  1316. _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
  1317. _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
  1318. _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
  1319. _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
  1320. _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
  1321. // MSDN says that MSVC does not support alignment beyond 8192 (=0x2000)
  1322. #if !defined(_LIBCPP_MSVC)
  1323. _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
  1324. #endif // !_LIBCPP_MSVC
  1325. #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
  1326. #ifndef _LIBCPP_HAS_NO_VARIADICS
  1327. // aligned_union
  1328. template <size_t _I0, size_t ..._In>
  1329. struct __static_max;
  1330. template <size_t _I0>
  1331. struct __static_max<_I0>
  1332. {
  1333. static const size_t value = _I0;
  1334. };
  1335. template <size_t _I0, size_t _I1, size_t ..._In>
  1336. struct __static_max<_I0, _I1, _In...>
  1337. {
  1338. static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
  1339. __static_max<_I1, _In...>::value;
  1340. };
  1341. template <size_t _Len, class _Type0, class ..._Types>
  1342. struct aligned_union
  1343. {
  1344. static const size_t alignment_value = __static_max<__alignof__(_Type0),
  1345. __alignof__(_Types)...>::value;
  1346. static const size_t __len = __static_max<_Len, sizeof(_Type0),
  1347. sizeof(_Types)...>::value;
  1348. typedef typename aligned_storage<__len, alignment_value>::type type;
  1349. };
  1350. #if _LIBCPP_STD_VER > 11
  1351. template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
  1352. #endif
  1353. #endif // _LIBCPP_HAS_NO_VARIADICS
  1354. template <class _Tp>
  1355. struct __numeric_type
  1356. {
  1357. static void __test(...);
  1358. static float __test(float);
  1359. static double __test(char);
  1360. static double __test(int);
  1361. static double __test(unsigned);
  1362. static double __test(long);
  1363. static double __test(unsigned long);
  1364. static double __test(long long);
  1365. static double __test(unsigned long long);
  1366. static double __test(double);
  1367. static long double __test(long double);
  1368. typedef decltype(__test(declval<_Tp>())) type;
  1369. static const bool value = !is_same<type, void>::value;
  1370. };
  1371. template <>
  1372. struct __numeric_type<void>
  1373. {
  1374. static const bool value = true;
  1375. };
  1376. // __promote
  1377. template <class _A1, class _A2 = void, class _A3 = void,
  1378. bool = __numeric_type<_A1>::value &&
  1379. __numeric_type<_A2>::value &&
  1380. __numeric_type<_A3>::value>
  1381. class __promote_imp
  1382. {
  1383. public:
  1384. static const bool value = false;
  1385. };
  1386. template <class _A1, class _A2, class _A3>
  1387. class __promote_imp<_A1, _A2, _A3, true>
  1388. {
  1389. private:
  1390. typedef typename __promote_imp<_A1>::type __type1;
  1391. typedef typename __promote_imp<_A2>::type __type2;
  1392. typedef typename __promote_imp<_A3>::type __type3;
  1393. public:
  1394. typedef decltype(__type1() + __type2() + __type3()) type;
  1395. static const bool value = true;
  1396. };
  1397. template <class _A1, class _A2>
  1398. class __promote_imp<_A1, _A2, void, true>
  1399. {
  1400. private:
  1401. typedef typename __promote_imp<_A1>::type __type1;
  1402. typedef typename __promote_imp<_A2>::type __type2;
  1403. public:
  1404. typedef decltype(__type1() + __type2()) type;
  1405. static const bool value = true;
  1406. };
  1407. template <class _A1>
  1408. class __promote_imp<_A1, void, void, true>
  1409. {
  1410. public:
  1411. typedef typename __numeric_type<_A1>::type type;
  1412. static const bool value = true;
  1413. };
  1414. template <class _A1, class _A2 = void, class _A3 = void>
  1415. class __promote : public __promote_imp<_A1, _A2, _A3> {};
  1416. // make_signed / make_unsigned
  1417. typedef
  1418. __type_list<signed char,
  1419. __type_list<signed short,
  1420. __type_list<signed int,
  1421. __type_list<signed long,
  1422. __type_list<signed long long,
  1423. #ifndef _LIBCPP_HAS_NO_INT128
  1424. __type_list<__int128_t,
  1425. #endif
  1426. __nat
  1427. #ifndef _LIBCPP_HAS_NO_INT128
  1428. >
  1429. #endif
  1430. > > > > > __signed_types;
  1431. typedef
  1432. __type_list<unsigned char,
  1433. __type_list<unsigned short,
  1434. __type_list<unsigned int,
  1435. __type_list<unsigned long,
  1436. __type_list<unsigned long long,
  1437. #ifndef _LIBCPP_HAS_NO_INT128
  1438. __type_list<__uint128_t,
  1439. #endif
  1440. __nat
  1441. #ifndef _LIBCPP_HAS_NO_INT128
  1442. >
  1443. #endif
  1444. > > > > > __unsigned_types;
  1445. template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
  1446. template <class _Hp, class _Tp, size_t _Size>
  1447. struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
  1448. {
  1449. typedef _Hp type;
  1450. };
  1451. template <class _Hp, class _Tp, size_t _Size>
  1452. struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
  1453. {
  1454. typedef typename __find_first<_Tp, _Size>::type type;
  1455. };
  1456. template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
  1457. bool = is_volatile<typename remove_reference<_Tp>::type>::value>
  1458. struct __apply_cv
  1459. {
  1460. typedef _Up type;
  1461. };
  1462. template <class _Tp, class _Up>
  1463. struct __apply_cv<_Tp, _Up, true, false>
  1464. {
  1465. typedef const _Up type;
  1466. };
  1467. template <class _Tp, class _Up>
  1468. struct __apply_cv<_Tp, _Up, false, true>
  1469. {
  1470. typedef volatile _Up type;
  1471. };
  1472. template <class _Tp, class _Up>
  1473. struct __apply_cv<_Tp, _Up, true, true>
  1474. {
  1475. typedef const volatile _Up type;
  1476. };
  1477. template <class _Tp, class _Up>
  1478. struct __apply_cv<_Tp&, _Up, false, false>
  1479. {
  1480. typedef _Up& type;
  1481. };
  1482. template <class _Tp, class _Up>
  1483. struct __apply_cv<_Tp&, _Up, true, false>
  1484. {
  1485. typedef const _Up& type;
  1486. };
  1487. template <class _Tp, class _Up>
  1488. struct __apply_cv<_Tp&, _Up, false, true>
  1489. {
  1490. typedef volatile _Up& type;
  1491. };
  1492. template <class _Tp, class _Up>
  1493. struct __apply_cv<_Tp&, _Up, true, true>
  1494. {
  1495. typedef const volatile _Up& type;
  1496. };
  1497. template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
  1498. struct __make_signed {};
  1499. template <class _Tp>
  1500. struct __make_signed<_Tp, true>
  1501. {
  1502. typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
  1503. };
  1504. template <> struct __make_signed<bool, true> {};
  1505. template <> struct __make_signed< signed short, true> {typedef short type;};
  1506. template <> struct __make_signed<unsigned short, true> {typedef short type;};
  1507. template <> struct __make_signed< signed int, true> {typedef int type;};
  1508. template <> struct __make_signed<unsigned int, true> {typedef int type;};
  1509. template <> struct __make_signed< signed long, true> {typedef long type;};
  1510. template <> struct __make_signed<unsigned long, true> {typedef long type;};
  1511. template <> struct __make_signed< signed long long, true> {typedef long long type;};
  1512. template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
  1513. #ifndef _LIBCPP_HAS_NO_INT128
  1514. template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
  1515. template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
  1516. #endif
  1517. template <class _Tp>
  1518. struct _LIBCPP_TYPE_VIS_ONLY make_signed
  1519. {
  1520. typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
  1521. };
  1522. #if _LIBCPP_STD_VER > 11
  1523. template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
  1524. #endif
  1525. template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
  1526. struct __make_unsigned {};
  1527. template <class _Tp>
  1528. struct __make_unsigned<_Tp, true>
  1529. {
  1530. typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
  1531. };
  1532. template <> struct __make_unsigned<bool, true> {};
  1533. template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
  1534. template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
  1535. template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
  1536. template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
  1537. template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
  1538. template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
  1539. template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
  1540. template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
  1541. #ifndef _LIBCPP_HAS_NO_INT128
  1542. template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
  1543. template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
  1544. #endif
  1545. template <class _Tp>
  1546. struct _LIBCPP_TYPE_VIS_ONLY make_unsigned
  1547. {
  1548. typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
  1549. };
  1550. #if _LIBCPP_STD_VER > 11
  1551. template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
  1552. #endif
  1553. #ifdef _LIBCPP_HAS_NO_VARIADICS
  1554. template <class _Tp, class _Up = void, class _Vp = void>
  1555. struct _LIBCPP_TYPE_VIS_ONLY common_type
  1556. {
  1557. public:
  1558. typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp>::type type;
  1559. };
  1560. template <class _Tp>
  1561. struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, void, void>
  1562. {
  1563. public:
  1564. typedef typename decay<_Tp>::type type;
  1565. };
  1566. template <class _Tp, class _Up>
  1567. struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, void>
  1568. {
  1569. typedef typename decay<decltype(
  1570. true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
  1571. )>::type type;
  1572. };
  1573. #else // _LIBCPP_HAS_NO_VARIADICS
  1574. // bullet 1 - sizeof...(Tp) == 0
  1575. template <class ..._Tp>
  1576. struct _LIBCPP_TYPE_VIS_ONLY common_type {};
  1577. // bullet 2 - sizeof...(Tp) == 1
  1578. template <class _Tp>
  1579. struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp>
  1580. {
  1581. typedef typename decay<_Tp>::type type;
  1582. };
  1583. // bullet 3 - sizeof...(Tp) == 2
  1584. template <class _Tp, class _Up, class = void>
  1585. struct __common_type2 {};
  1586. template <class _Tp, class _Up>
  1587. struct __common_type2<_Tp, _Up,
  1588. typename __void_t<decltype(
  1589. true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
  1590. )>::type>
  1591. {
  1592. typedef typename decay<decltype(
  1593. true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
  1594. )>::type type;
  1595. };
  1596. template <class _Tp, class _Up>
  1597. struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up>
  1598. : __common_type2<_Tp, _Up> {};
  1599. // bullet 4 - sizeof...(Tp) > 2
  1600. template <class ...Tp> struct __common_types;
  1601. template <class, class = void>
  1602. struct __common_type_impl {};
  1603. template <class _Tp, class _Up, class ..._Vp>
  1604. struct __common_type_impl<__common_types<_Tp, _Up, _Vp...>,
  1605. typename __void_t<typename common_type<_Tp, _Up>::type>::type>
  1606. {
  1607. typedef typename common_type<
  1608. typename common_type<_Tp, _Up>::type, _Vp...
  1609. >::type type;
  1610. };
  1611. template <class _Tp, class _Up, class ..._Vp>
  1612. struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, _Vp...>
  1613. : __common_type_impl<__common_types<_Tp, _Up, _Vp...> > {};
  1614. #if _LIBCPP_STD_VER > 11
  1615. template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
  1616. #endif
  1617. #endif // _LIBCPP_HAS_NO_VARIADICS
  1618. // is_assignable
  1619. template<typename, typename _Tp> struct __select_2nd { typedef _Tp type; };
  1620. template <class _Tp, class _Arg>
  1621. typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
  1622. #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  1623. __is_assignable_test(_Tp&&, _Arg&&);
  1624. #else
  1625. __is_assignable_test(_Tp, _Arg&);
  1626. #endif
  1627. template <class _Arg>
  1628. false_type
  1629. #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  1630. __is_assignable_test(__any, _Arg&&);
  1631. #else
  1632. __is_assignable_test(__any, _Arg&);
  1633. #endif
  1634. template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
  1635. struct __is_assignable_imp
  1636. : public common_type
  1637. <
  1638. decltype(_VSTD::__is_assignable_test(declval<_Tp>(), declval<_Arg>()))
  1639. >::type {};
  1640. template <class _Tp, class _Arg>
  1641. struct __is_assignable_imp<_Tp, _Arg, true>
  1642. : public false_type
  1643. {
  1644. };
  1645. template <class _Tp, class _Arg>
  1646. struct is_assignable
  1647. : public __is_assignable_imp<_Tp, _Arg> {};
  1648. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  1649. template <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_assignable_v
  1650. = is_assignable<_Tp, _Arg>::value;
  1651. #endif
  1652. // is_copy_assignable
  1653. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_copy_assignable
  1654. : public is_assignable<typename add_lvalue_reference<_Tp>::type,
  1655. typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
  1656. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  1657. template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_assignable_v
  1658. = is_copy_assignable<_Tp>::value;
  1659. #endif
  1660. // is_move_assignable
  1661. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable
  1662. #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  1663. : public is_assignable<typename add_lvalue_reference<_Tp>::type,
  1664. const typename add_rvalue_reference<_Tp>::type> {};
  1665. #else
  1666. : public is_copy_assignable<_Tp> {};
  1667. #endif
  1668. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  1669. template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_assignable_v
  1670. = is_move_assignable<_Tp>::value;
  1671. #endif
  1672. // is_destructible
  1673. // if it's a reference, return true
  1674. // if it's a function, return false
  1675. // if it's void, return false
  1676. // if it's an array of unknown bound, return false
  1677. // Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed
  1678. // where _Up is remove_all_extents<_Tp>::type
  1679. template <class>
  1680. struct __is_destructible_apply { typedef int type; };
  1681. template <typename _Tp>
  1682. struct __is_destructor_wellformed {
  1683. template <typename _Tp1>
  1684. static char __test (
  1685. typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
  1686. );
  1687. template <typename _Tp1>
  1688. static __two __test (...);
  1689. static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
  1690. };
  1691. template <class _Tp, bool>
  1692. struct __destructible_imp;
  1693. template <class _Tp>
  1694. struct __destructible_imp<_Tp, false>
  1695. : public _VSTD::integral_constant<bool,
  1696. __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {};
  1697. template <class _Tp>
  1698. struct __destructible_imp<_Tp, true>
  1699. : public _VSTD::true_type {};
  1700. template <class _Tp, bool>
  1701. struct __destructible_false;
  1702. template <class _Tp>
  1703. struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {};
  1704. template <class _Tp>
  1705. struct __destructible_false<_Tp, true> : public _VSTD::false_type {};
  1706. template <class _Tp>
  1707. struct is_destructible
  1708. : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {};
  1709. template <class _Tp>
  1710. struct is_destructible<_Tp[]>
  1711. : public _VSTD::false_type {};
  1712. template <>
  1713. struct is_destructible<void>
  1714. : public _VSTD::false_type {};
  1715. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  1716. template <class _Tp> _LIBCPP_CONSTEXPR bool is_destructible_v
  1717. = is_destructible<_Tp>::value;
  1718. #endif
  1719. // move
  1720. #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  1721. template <class _Tp>
  1722. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1723. typename remove_reference<_Tp>::type&&
  1724. move(_Tp&& __t) _NOEXCEPT
  1725. {
  1726. typedef typename remove_reference<_Tp>::type _Up;
  1727. return static_cast<_Up&&>(__t);
  1728. }
  1729. template <class _Tp>
  1730. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1731. _Tp&&
  1732. forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
  1733. {
  1734. return static_cast<_Tp&&>(__t);
  1735. }
  1736. template <class _Tp>
  1737. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1738. _Tp&&
  1739. forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT
  1740. {
  1741. static_assert(!is_lvalue_reference<_Tp>::value,
  1742. "Can not forward an rvalue as an lvalue.");
  1743. return static_cast<_Tp&&>(__t);
  1744. }
  1745. #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
  1746. template <class _Tp>
  1747. inline _LIBCPP_INLINE_VISIBILITY
  1748. _Tp&
  1749. move(_Tp& __t)
  1750. {
  1751. return __t;
  1752. }
  1753. template <class _Tp>
  1754. inline _LIBCPP_INLINE_VISIBILITY
  1755. const _Tp&
  1756. move(const _Tp& __t)
  1757. {
  1758. return __t;
  1759. }
  1760. template <class _Tp>
  1761. inline _LIBCPP_INLINE_VISIBILITY
  1762. _Tp&
  1763. forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
  1764. {
  1765. return __t;
  1766. }
  1767. template <class _Tp>
  1768. class __rv
  1769. {
  1770. typedef typename remove_reference<_Tp>::type _Trr;
  1771. _Trr& t_;
  1772. public:
  1773. _LIBCPP_INLINE_VISIBILITY
  1774. _Trr* operator->() {return &t_;}
  1775. _LIBCPP_INLINE_VISIBILITY
  1776. explicit __rv(_Trr& __t) : t_(__t) {}
  1777. };
  1778. #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
  1779. #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  1780. template <class _Tp>
  1781. inline _LIBCPP_INLINE_VISIBILITY
  1782. typename decay<_Tp>::type
  1783. __decay_copy(_Tp&& __t)
  1784. {
  1785. return _VSTD::forward<_Tp>(__t);
  1786. }
  1787. #else
  1788. template <class _Tp>
  1789. inline _LIBCPP_INLINE_VISIBILITY
  1790. typename decay<_Tp>::type
  1791. __decay_copy(const _Tp& __t)
  1792. {
  1793. return _VSTD::forward<_Tp>(__t);
  1794. }
  1795. #endif
  1796. #ifndef _LIBCPP_HAS_NO_VARIADICS
  1797. template <class _Rp, class _Class, class ..._Param>
  1798. struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
  1799. {
  1800. typedef _Class _ClassType;
  1801. typedef _Rp _ReturnType;
  1802. typedef _Rp (_FnType) (_Param...);
  1803. };
  1804. template <class _Rp, class _Class, class ..._Param>
  1805. struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
  1806. {
  1807. typedef _Class _ClassType;
  1808. typedef _Rp _ReturnType;
  1809. typedef _Rp (_FnType) (_Param..., ...);
  1810. };
  1811. template <class _Rp, class _Class, class ..._Param>
  1812. struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
  1813. {
  1814. typedef _Class const _ClassType;
  1815. typedef _Rp _ReturnType;
  1816. typedef _Rp (_FnType) (_Param...);
  1817. };
  1818. template <class _Rp, class _Class, class ..._Param>
  1819. struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
  1820. {
  1821. typedef _Class const _ClassType;
  1822. typedef _Rp _ReturnType;
  1823. typedef _Rp (_FnType) (_Param..., ...);
  1824. };
  1825. template <class _Rp, class _Class, class ..._Param>
  1826. struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
  1827. {
  1828. typedef _Class volatile _ClassType;
  1829. typedef _Rp _ReturnType;
  1830. typedef _Rp (_FnType) (_Param...);
  1831. };
  1832. template <class _Rp, class _Class, class ..._Param>
  1833. struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
  1834. {
  1835. typedef _Class volatile _ClassType;
  1836. typedef _Rp _ReturnType;
  1837. typedef _Rp (_FnType) (_Param..., ...);
  1838. };
  1839. template <class _Rp, class _Class, class ..._Param>
  1840. struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
  1841. {
  1842. typedef _Class const volatile _ClassType;
  1843. typedef _Rp _ReturnType;
  1844. typedef _Rp (_FnType) (_Param...);
  1845. };
  1846. template <class _Rp, class _Class, class ..._Param>
  1847. struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
  1848. {
  1849. typedef _Class const volatile _ClassType;
  1850. typedef _Rp _ReturnType;
  1851. typedef _Rp (_FnType) (_Param..., ...);
  1852. };
  1853. #if __has_feature(cxx_reference_qualified_functions) || \
  1854. (defined(_GNUC_VER) && _GNUC_VER >= 409)
  1855. template <class _Rp, class _Class, class ..._Param>
  1856. struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
  1857. {
  1858. typedef _Class& _ClassType;
  1859. typedef _Rp _ReturnType;
  1860. typedef _Rp (_FnType) (_Param...);
  1861. };
  1862. template <class _Rp, class _Class, class ..._Param>
  1863. struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
  1864. {
  1865. typedef _Class& _ClassType;
  1866. typedef _Rp _ReturnType;
  1867. typedef _Rp (_FnType) (_Param..., ...);
  1868. };
  1869. template <class _Rp, class _Class, class ..._Param>
  1870. struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
  1871. {
  1872. typedef _Class const& _ClassType;
  1873. typedef _Rp _ReturnType;
  1874. typedef _Rp (_FnType) (_Param...);
  1875. };
  1876. template <class _Rp, class _Class, class ..._Param>
  1877. struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
  1878. {
  1879. typedef _Class const& _ClassType;
  1880. typedef _Rp _ReturnType;
  1881. typedef _Rp (_FnType) (_Param..., ...);
  1882. };
  1883. template <class _Rp, class _Class, class ..._Param>
  1884. struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
  1885. {
  1886. typedef _Class volatile& _ClassType;
  1887. typedef _Rp _ReturnType;
  1888. typedef _Rp (_FnType) (_Param...);
  1889. };
  1890. template <class _Rp, class _Class, class ..._Param>
  1891. struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
  1892. {
  1893. typedef _Class volatile& _ClassType;
  1894. typedef _Rp _ReturnType;
  1895. typedef _Rp (_FnType) (_Param..., ...);
  1896. };
  1897. template <class _Rp, class _Class, class ..._Param>
  1898. struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
  1899. {
  1900. typedef _Class const volatile& _ClassType;
  1901. typedef _Rp _ReturnType;
  1902. typedef _Rp (_FnType) (_Param...);
  1903. };
  1904. template <class _Rp, class _Class, class ..._Param>
  1905. struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
  1906. {
  1907. typedef _Class const volatile& _ClassType;
  1908. typedef _Rp _ReturnType;
  1909. typedef _Rp (_FnType) (_Param..., ...);
  1910. };
  1911. template <class _Rp, class _Class, class ..._Param>
  1912. struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
  1913. {
  1914. typedef _Class&& _ClassType;
  1915. typedef _Rp _ReturnType;
  1916. typedef _Rp (_FnType) (_Param...);
  1917. };
  1918. template <class _Rp, class _Class, class ..._Param>
  1919. struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
  1920. {
  1921. typedef _Class&& _ClassType;
  1922. typedef _Rp _ReturnType;
  1923. typedef _Rp (_FnType) (_Param..., ...);
  1924. };
  1925. template <class _Rp, class _Class, class ..._Param>
  1926. struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
  1927. {
  1928. typedef _Class const&& _ClassType;
  1929. typedef _Rp _ReturnType;
  1930. typedef _Rp (_FnType) (_Param...);
  1931. };
  1932. template <class _Rp, class _Class, class ..._Param>
  1933. struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
  1934. {
  1935. typedef _Class const&& _ClassType;
  1936. typedef _Rp _ReturnType;
  1937. typedef _Rp (_FnType) (_Param..., ...);
  1938. };
  1939. template <class _Rp, class _Class, class ..._Param>
  1940. struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
  1941. {
  1942. typedef _Class volatile&& _ClassType;
  1943. typedef _Rp _ReturnType;
  1944. typedef _Rp (_FnType) (_Param...);
  1945. };
  1946. template <class _Rp, class _Class, class ..._Param>
  1947. struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
  1948. {
  1949. typedef _Class volatile&& _ClassType;
  1950. typedef _Rp _ReturnType;
  1951. typedef _Rp (_FnType) (_Param..., ...);
  1952. };
  1953. template <class _Rp, class _Class, class ..._Param>
  1954. struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
  1955. {
  1956. typedef _Class const volatile&& _ClassType;
  1957. typedef _Rp _ReturnType;
  1958. typedef _Rp (_FnType) (_Param...);
  1959. };
  1960. template <class _Rp, class _Class, class ..._Param>
  1961. struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
  1962. {
  1963. typedef _Class const volatile&& _ClassType;
  1964. typedef _Rp _ReturnType;
  1965. typedef _Rp (_FnType) (_Param..., ...);
  1966. };
  1967. #endif // __has_feature(cxx_reference_qualified_functions) || _GNUC_VER >= 409
  1968. #else // _LIBCPP_HAS_NO_VARIADICS
  1969. template <class _Rp, class _Class>
  1970. struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
  1971. {
  1972. typedef _Class _ClassType;
  1973. typedef _Rp _ReturnType;
  1974. typedef _Rp (_FnType) ();
  1975. };
  1976. template <class _Rp, class _Class>
  1977. struct __member_pointer_traits_imp<_Rp (_Class::*)(...), true, false>
  1978. {
  1979. typedef _Class _ClassType;
  1980. typedef _Rp _ReturnType;
  1981. typedef _Rp (_FnType) (...);
  1982. };
  1983. template <class _Rp, class _Class, class _P0>
  1984. struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
  1985. {
  1986. typedef _Class _ClassType;
  1987. typedef _Rp _ReturnType;
  1988. typedef _Rp (_FnType) (_P0);
  1989. };
  1990. template <class _Rp, class _Class, class _P0>
  1991. struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...), true, false>
  1992. {
  1993. typedef _Class _ClassType;
  1994. typedef _Rp _ReturnType;
  1995. typedef _Rp (_FnType) (_P0, ...);
  1996. };
  1997. template <class _Rp, class _Class, class _P0, class _P1>
  1998. struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
  1999. {
  2000. typedef _Class _ClassType;
  2001. typedef _Rp _ReturnType;
  2002. typedef _Rp (_FnType) (_P0, _P1);
  2003. };
  2004. template <class _Rp, class _Class, class _P0, class _P1>
  2005. struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...), true, false>
  2006. {
  2007. typedef _Class _ClassType;
  2008. typedef _Rp _ReturnType;
  2009. typedef _Rp (_FnType) (_P0, _P1, ...);
  2010. };
  2011. template <class _Rp, class _Class, class _P0, class _P1, class _P2>
  2012. struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
  2013. {
  2014. typedef _Class _ClassType;
  2015. typedef _Rp _ReturnType;
  2016. typedef _Rp (_FnType) (_P0, _P1, _P2);
  2017. };
  2018. template <class _Rp, class _Class, class _P0, class _P1, class _P2>
  2019. struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...), true, false>
  2020. {
  2021. typedef _Class _ClassType;
  2022. typedef _Rp _ReturnType;
  2023. typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
  2024. };
  2025. template <class _Rp, class _Class>
  2026. struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
  2027. {
  2028. typedef _Class const _ClassType;
  2029. typedef _Rp _ReturnType;
  2030. typedef _Rp (_FnType) ();
  2031. };
  2032. template <class _Rp, class _Class>
  2033. struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const, true, false>
  2034. {
  2035. typedef _Class const _ClassType;
  2036. typedef _Rp _ReturnType;
  2037. typedef _Rp (_FnType) (...);
  2038. };
  2039. template <class _Rp, class _Class, class _P0>
  2040. struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
  2041. {
  2042. typedef _Class const _ClassType;
  2043. typedef _Rp _ReturnType;
  2044. typedef _Rp (_FnType) (_P0);
  2045. };
  2046. template <class _Rp, class _Class, class _P0>
  2047. struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const, true, false>
  2048. {
  2049. typedef _Class const _ClassType;
  2050. typedef _Rp _ReturnType;
  2051. typedef _Rp (_FnType) (_P0, ...);
  2052. };
  2053. template <class _Rp, class _Class, class _P0, class _P1>
  2054. struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
  2055. {
  2056. typedef _Class const _ClassType;
  2057. typedef _Rp _ReturnType;
  2058. typedef _Rp (_FnType) (_P0, _P1);
  2059. };
  2060. template <class _Rp, class _Class, class _P0, class _P1>
  2061. struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const, true, false>
  2062. {
  2063. typedef _Class const _ClassType;
  2064. typedef _Rp _ReturnType;
  2065. typedef _Rp (_FnType) (_P0, _P1, ...);
  2066. };
  2067. template <class _Rp, class _Class, class _P0, class _P1, class _P2>
  2068. struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
  2069. {
  2070. typedef _Class const _ClassType;
  2071. typedef _Rp _ReturnType;
  2072. typedef _Rp (_FnType) (_P0, _P1, _P2);
  2073. };
  2074. template <class _Rp, class _Class, class _P0, class _P1, class _P2>
  2075. struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const, true, false>
  2076. {
  2077. typedef _Class const _ClassType;
  2078. typedef _Rp _ReturnType;
  2079. typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
  2080. };
  2081. template <class _Rp, class _Class>
  2082. struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
  2083. {
  2084. typedef _Class volatile _ClassType;
  2085. typedef _Rp _ReturnType;
  2086. typedef _Rp (_FnType) ();
  2087. };
  2088. template <class _Rp, class _Class>
  2089. struct __member_pointer_traits_imp<_Rp (_Class::*)(...) volatile, true, false>
  2090. {
  2091. typedef _Class volatile _ClassType;
  2092. typedef _Rp _ReturnType;
  2093. typedef _Rp (_FnType) (...);
  2094. };
  2095. template <class _Rp, class _Class, class _P0>
  2096. struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
  2097. {
  2098. typedef _Class volatile _ClassType;
  2099. typedef _Rp _ReturnType;
  2100. typedef _Rp (_FnType) (_P0);
  2101. };
  2102. template <class _Rp, class _Class, class _P0>
  2103. struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) volatile, true, false>
  2104. {
  2105. typedef _Class volatile _ClassType;
  2106. typedef _Rp _ReturnType;
  2107. typedef _Rp (_FnType) (_P0, ...);
  2108. };
  2109. template <class _Rp, class _Class, class _P0, class _P1>
  2110. struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
  2111. {
  2112. typedef _Class volatile _ClassType;
  2113. typedef _Rp _ReturnType;
  2114. typedef _Rp (_FnType) (_P0, _P1);
  2115. };
  2116. template <class _Rp, class _Class, class _P0, class _P1>
  2117. struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) volatile, true, false>
  2118. {
  2119. typedef _Class volatile _ClassType;
  2120. typedef _Rp _ReturnType;
  2121. typedef _Rp (_FnType) (_P0, _P1, ...);
  2122. };
  2123. template <class _Rp, class _Class, class _P0, class _P1, class _P2>
  2124. struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
  2125. {
  2126. typedef _Class volatile _ClassType;
  2127. typedef _Rp _ReturnType;
  2128. typedef _Rp (_FnType) (_P0, _P1, _P2);
  2129. };
  2130. template <class _Rp, class _Class, class _P0, class _P1, class _P2>
  2131. struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) volatile, true, false>
  2132. {
  2133. typedef _Class volatile _ClassType;
  2134. typedef _Rp _ReturnType;
  2135. typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
  2136. };
  2137. template <class _Rp, class _Class>
  2138. struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
  2139. {
  2140. typedef _Class const volatile _ClassType;
  2141. typedef _Rp _ReturnType;
  2142. typedef _Rp (_FnType) ();
  2143. };
  2144. template <class _Rp, class _Class>
  2145. struct __member_pointer_traits_imp<_Rp (_Class::*)(...) const volatile, true, false>
  2146. {
  2147. typedef _Class const volatile _ClassType;
  2148. typedef _Rp _ReturnType;
  2149. typedef _Rp (_FnType) (...);
  2150. };
  2151. template <class _Rp, class _Class, class _P0>
  2152. struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
  2153. {
  2154. typedef _Class const volatile _ClassType;
  2155. typedef _Rp _ReturnType;
  2156. typedef _Rp (_FnType) (_P0);
  2157. };
  2158. template <class _Rp, class _Class, class _P0>
  2159. struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, ...) const volatile, true, false>
  2160. {
  2161. typedef _Class const volatile _ClassType;
  2162. typedef _Rp _ReturnType;
  2163. typedef _Rp (_FnType) (_P0, ...);
  2164. };
  2165. template <class _Rp, class _Class, class _P0, class _P1>
  2166. struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
  2167. {
  2168. typedef _Class const volatile _ClassType;
  2169. typedef _Rp _ReturnType;
  2170. typedef _Rp (_FnType) (_P0, _P1);
  2171. };
  2172. template <class _Rp, class _Class, class _P0, class _P1>
  2173. struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, ...) const volatile, true, false>
  2174. {
  2175. typedef _Class const volatile _ClassType;
  2176. typedef _Rp _ReturnType;
  2177. typedef _Rp (_FnType) (_P0, _P1, ...);
  2178. };
  2179. template <class _Rp, class _Class, class _P0, class _P1, class _P2>
  2180. struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
  2181. {
  2182. typedef _Class const volatile _ClassType;
  2183. typedef _Rp _ReturnType;
  2184. typedef _Rp (_FnType) (_P0, _P1, _P2);
  2185. };
  2186. template <class _Rp, class _Class, class _P0, class _P1, class _P2>
  2187. struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2, ...) const volatile, true, false>
  2188. {
  2189. typedef _Class const volatile _ClassType;
  2190. typedef _Rp _ReturnType;
  2191. typedef _Rp (_FnType) (_P0, _P1, _P2, ...);
  2192. };
  2193. #endif // _LIBCPP_HAS_NO_VARIADICS
  2194. template <class _Rp, class _Class>
  2195. struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
  2196. {
  2197. typedef _Class _ClassType;
  2198. typedef _Rp _ReturnType;
  2199. };
  2200. template <class _MP>
  2201. struct __member_pointer_traits
  2202. : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
  2203. is_member_function_pointer<_MP>::value,
  2204. is_member_object_pointer<_MP>::value>
  2205. {
  2206. // typedef ... _ClassType;
  2207. // typedef ... _ReturnType;
  2208. // typedef ... _FnType;
  2209. };
  2210. template <class _DecayedFp>
  2211. struct __member_pointer_class_type {};
  2212. template <class _Ret, class _ClassType>
  2213. struct __member_pointer_class_type<_Ret _ClassType::*> {
  2214. typedef _ClassType type;
  2215. };
  2216. // result_of
  2217. template <class _Callable> class result_of;
  2218. #ifdef _LIBCPP_HAS_NO_VARIADICS
  2219. template <class _Fn, bool, bool>
  2220. class __result_of
  2221. {
  2222. };
  2223. template <class _Fn>
  2224. class __result_of<_Fn(), true, false>
  2225. {
  2226. public:
  2227. typedef decltype(declval<_Fn>()()) type;
  2228. };
  2229. template <class _Fn, class _A0>
  2230. class __result_of<_Fn(_A0), true, false>
  2231. {
  2232. public:
  2233. typedef decltype(declval<_Fn>()(declval<_A0>())) type;
  2234. };
  2235. template <class _Fn, class _A0, class _A1>
  2236. class __result_of<_Fn(_A0, _A1), true, false>
  2237. {
  2238. public:
  2239. typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
  2240. };
  2241. template <class _Fn, class _A0, class _A1, class _A2>
  2242. class __result_of<_Fn(_A0, _A1, _A2), true, false>
  2243. {
  2244. public:
  2245. typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
  2246. };
  2247. template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
  2248. struct __result_of_mp;
  2249. // member function pointer
  2250. template <class _MP, class _Tp>
  2251. struct __result_of_mp<_MP, _Tp, true>
  2252. : public __identity<typename __member_pointer_traits<_MP>::_ReturnType>
  2253. {
  2254. };
  2255. // member data pointer
  2256. template <class _MP, class _Tp, bool>
  2257. struct __result_of_mdp;
  2258. template <class _Rp, class _Class, class _Tp>
  2259. struct __result_of_mdp<_Rp _Class::*, _Tp, false>
  2260. {
  2261. typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
  2262. };
  2263. template <class _Rp, class _Class, class _Tp>
  2264. struct __result_of_mdp<_Rp _Class::*, _Tp, true>
  2265. {
  2266. typedef typename __apply_cv<_Tp, _Rp>::type& type;
  2267. };
  2268. template <class _Rp, class _Class, class _Tp>
  2269. struct __result_of_mp<_Rp _Class::*, _Tp, false>
  2270. : public __result_of_mdp<_Rp _Class::*, _Tp,
  2271. is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
  2272. {
  2273. };
  2274. template <class _Fn, class _Tp>
  2275. class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer
  2276. : public __result_of_mp<typename remove_reference<_Fn>::type,
  2277. _Tp,
  2278. is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
  2279. {
  2280. };
  2281. template <class _Fn, class _Tp, class _A0>
  2282. class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer
  2283. : public __result_of_mp<typename remove_reference<_Fn>::type,
  2284. _Tp,
  2285. is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
  2286. {
  2287. };
  2288. template <class _Fn, class _Tp, class _A0, class _A1>
  2289. class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer
  2290. : public __result_of_mp<typename remove_reference<_Fn>::type,
  2291. _Tp,
  2292. is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
  2293. {
  2294. };
  2295. template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
  2296. class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer
  2297. : public __result_of_mp<typename remove_reference<_Fn>::type,
  2298. _Tp,
  2299. is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
  2300. {
  2301. };
  2302. // result_of
  2303. template <class _Fn>
  2304. class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn()>
  2305. : public __result_of<_Fn(),
  2306. is_class<typename remove_reference<_Fn>::type>::value ||
  2307. is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
  2308. is_member_pointer<typename remove_reference<_Fn>::type>::value
  2309. >
  2310. {
  2311. };
  2312. template <class _Fn, class _A0>
  2313. class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0)>
  2314. : public __result_of<_Fn(_A0),
  2315. is_class<typename remove_reference<_Fn>::type>::value ||
  2316. is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
  2317. is_member_pointer<typename remove_reference<_Fn>::type>::value
  2318. >
  2319. {
  2320. };
  2321. template <class _Fn, class _A0, class _A1>
  2322. class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1)>
  2323. : public __result_of<_Fn(_A0, _A1),
  2324. is_class<typename remove_reference<_Fn>::type>::value ||
  2325. is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
  2326. is_member_pointer<typename remove_reference<_Fn>::type>::value
  2327. >
  2328. {
  2329. };
  2330. template <class _Fn, class _A0, class _A1, class _A2>
  2331. class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1, _A2)>
  2332. : public __result_of<_Fn(_A0, _A1, _A2),
  2333. is_class<typename remove_reference<_Fn>::type>::value ||
  2334. is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
  2335. is_member_pointer<typename remove_reference<_Fn>::type>::value
  2336. >
  2337. {
  2338. };
  2339. #endif // _LIBCPP_HAS_NO_VARIADICS
  2340. // template <class T, class... Args> struct is_constructible;
  2341. namespace __is_construct
  2342. {
  2343. struct __nat {};
  2344. }
  2345. #if __has_feature(is_constructible)
  2346. template <class _Tp, class ..._Args>
  2347. struct _LIBCPP_TYPE_VIS_ONLY is_constructible
  2348. : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
  2349. {};
  2350. #else
  2351. #ifndef _LIBCPP_HAS_NO_VARIADICS
  2352. // main is_constructible test
  2353. template <class _Tp, class ..._Args>
  2354. typename __select_2nd<decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...))), true_type>::type
  2355. __is_constructible_test(_Tp&&, _Args&& ...);
  2356. template <class ..._Args>
  2357. false_type
  2358. __is_constructible_test(__any, _Args&& ...);
  2359. template <bool, class _Tp, class... _Args>
  2360. struct __libcpp_is_constructible // false, _Tp is not a scalar
  2361. : public common_type
  2362. <
  2363. decltype(__is_constructible_test(declval<_Tp>(), declval<_Args>()...))
  2364. >::type
  2365. {};
  2366. // function types are not constructible
  2367. template <class _Rp, class... _A1, class... _A2>
  2368. struct __libcpp_is_constructible<false, _Rp(_A1...), _A2...>
  2369. : public false_type
  2370. {};
  2371. // handle scalars and reference types
  2372. // Scalars are default constructible, references are not
  2373. template <class _Tp>
  2374. struct __libcpp_is_constructible<true, _Tp>
  2375. : public is_scalar<_Tp>
  2376. {};
  2377. // Scalars and references are constructible from one arg if that arg is
  2378. // implicitly convertible to the scalar or reference.
  2379. template <class _Tp>
  2380. struct __is_constructible_ref
  2381. {
  2382. true_type static __lxx(_Tp);
  2383. false_type static __lxx(...);
  2384. };
  2385. template <class _Tp, class _A0>
  2386. struct __libcpp_is_constructible<true, _Tp, _A0>
  2387. : public common_type
  2388. <
  2389. decltype(__is_constructible_ref<_Tp>::__lxx(declval<_A0>()))
  2390. >::type
  2391. {};
  2392. // Scalars and references are not constructible from multiple args.
  2393. template <class _Tp, class _A0, class ..._Args>
  2394. struct __libcpp_is_constructible<true, _Tp, _A0, _Args...>
  2395. : public false_type
  2396. {};
  2397. // Treat scalars and reference types separately
  2398. template <bool, class _Tp, class... _Args>
  2399. struct __is_constructible_void_check
  2400. : public __libcpp_is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value,
  2401. _Tp, _Args...>
  2402. {};
  2403. // If any of T or Args is void, is_constructible should be false
  2404. template <class _Tp, class... _Args>
  2405. struct __is_constructible_void_check<true, _Tp, _Args...>
  2406. : public false_type
  2407. {};
  2408. template <class ..._Args> struct __contains_void;
  2409. template <> struct __contains_void<> : false_type {};
  2410. template <class _A0, class ..._Args>
  2411. struct __contains_void<_A0, _Args...>
  2412. {
  2413. static const bool value = is_void<_A0>::value ||
  2414. __contains_void<_Args...>::value;
  2415. };
  2416. // is_constructible entry point
  2417. template <class _Tp, class... _Args>
  2418. struct _LIBCPP_TYPE_VIS_ONLY is_constructible
  2419. : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value
  2420. || is_abstract<_Tp>::value,
  2421. _Tp, _Args...>
  2422. {};
  2423. // Array types are default constructible if their element type
  2424. // is default constructible
  2425. template <class _Ap, size_t _Np>
  2426. struct __libcpp_is_constructible<false, _Ap[_Np]>
  2427. : public is_constructible<typename remove_all_extents<_Ap>::type>
  2428. {};
  2429. // Otherwise array types are not constructible by this syntax
  2430. template <class _Ap, size_t _Np, class ..._Args>
  2431. struct __libcpp_is_constructible<false, _Ap[_Np], _Args...>
  2432. : public false_type
  2433. {};
  2434. // Incomplete array types are not constructible
  2435. template <class _Ap, class ..._Args>
  2436. struct __libcpp_is_constructible<false, _Ap[], _Args...>
  2437. : public false_type
  2438. {};
  2439. #else // _LIBCPP_HAS_NO_VARIADICS
  2440. // template <class T> struct is_constructible0;
  2441. // main is_constructible0 test
  2442. template <class _Tp>
  2443. decltype((_Tp(), true_type()))
  2444. __is_constructible0_test(_Tp&);
  2445. false_type
  2446. __is_constructible0_test(__any);
  2447. template <class _Tp, class _A0>
  2448. decltype((_Tp(_VSTD::declval<_A0>()), true_type()))
  2449. __is_constructible1_test(_Tp&, _A0&);
  2450. template <class _A0>
  2451. false_type
  2452. __is_constructible1_test(__any, _A0&);
  2453. template <class _Tp, class _A0, class _A1>
  2454. decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
  2455. __is_constructible2_test(_Tp&, _A0&, _A1&);
  2456. template <class _A0, class _A1>
  2457. false_type
  2458. __is_constructible2_test(__any, _A0&, _A1&);
  2459. template <bool, class _Tp>
  2460. struct __is_constructible0_imp // false, _Tp is not a scalar
  2461. : public common_type
  2462. <
  2463. decltype(__is_constructible0_test(declval<_Tp&>()))
  2464. >::type
  2465. {};
  2466. template <bool, class _Tp, class _A0>
  2467. struct __is_constructible1_imp // false, _Tp is not a scalar
  2468. : public common_type
  2469. <
  2470. decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
  2471. >::type
  2472. {};
  2473. template <bool, class _Tp, class _A0, class _A1>
  2474. struct __is_constructible2_imp // false, _Tp is not a scalar
  2475. : public common_type
  2476. <
  2477. decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
  2478. >::type
  2479. {};
  2480. // handle scalars and reference types
  2481. // Scalars are default constructible, references are not
  2482. template <class _Tp>
  2483. struct __is_constructible0_imp<true, _Tp>
  2484. : public is_scalar<_Tp>
  2485. {};
  2486. template <class _Tp, class _A0>
  2487. struct __is_constructible1_imp<true, _Tp, _A0>
  2488. : public is_convertible<_A0, _Tp>
  2489. {};
  2490. template <class _Tp, class _A0, class _A1>
  2491. struct __is_constructible2_imp<true, _Tp, _A0, _A1>
  2492. : public false_type
  2493. {};
  2494. // Treat scalars and reference types separately
  2495. template <bool, class _Tp>
  2496. struct __is_constructible0_void_check
  2497. : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
  2498. _Tp>
  2499. {};
  2500. template <bool, class _Tp, class _A0>
  2501. struct __is_constructible1_void_check
  2502. : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
  2503. _Tp, _A0>
  2504. {};
  2505. template <bool, class _Tp, class _A0, class _A1>
  2506. struct __is_constructible2_void_check
  2507. : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
  2508. _Tp, _A0, _A1>
  2509. {};
  2510. // If any of T or Args is void, is_constructible should be false
  2511. template <class _Tp>
  2512. struct __is_constructible0_void_check<true, _Tp>
  2513. : public false_type
  2514. {};
  2515. template <class _Tp, class _A0>
  2516. struct __is_constructible1_void_check<true, _Tp, _A0>
  2517. : public false_type
  2518. {};
  2519. template <class _Tp, class _A0, class _A1>
  2520. struct __is_constructible2_void_check<true, _Tp, _A0, _A1>
  2521. : public false_type
  2522. {};
  2523. // is_constructible entry point
  2524. template <class _Tp, class _A0 = __is_construct::__nat,
  2525. class _A1 = __is_construct::__nat>
  2526. struct _LIBCPP_TYPE_VIS_ONLY is_constructible
  2527. : public __is_constructible2_void_check<is_void<_Tp>::value
  2528. || is_abstract<_Tp>::value
  2529. || is_function<_Tp>::value
  2530. || is_void<_A0>::value
  2531. || is_void<_A1>::value,
  2532. _Tp, _A0, _A1>
  2533. {};
  2534. template <class _Tp>
  2535. struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
  2536. : public __is_constructible0_void_check<is_void<_Tp>::value
  2537. || is_abstract<_Tp>::value
  2538. || is_function<_Tp>::value,
  2539. _Tp>
  2540. {};
  2541. template <class _Tp, class _A0>
  2542. struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, _A0, __is_construct::__nat>
  2543. : public __is_constructible1_void_check<is_void<_Tp>::value
  2544. || is_abstract<_Tp>::value
  2545. || is_function<_Tp>::value
  2546. || is_void<_A0>::value,
  2547. _Tp, _A0>
  2548. {};
  2549. // Array types are default constructible if their element type
  2550. // is default constructible
  2551. template <class _Ap, size_t _Np>
  2552. struct __is_constructible0_imp<false, _Ap[_Np]>
  2553. : public is_constructible<typename remove_all_extents<_Ap>::type>
  2554. {};
  2555. template <class _Ap, size_t _Np, class _A0>
  2556. struct __is_constructible1_imp<false, _Ap[_Np], _A0>
  2557. : public false_type
  2558. {};
  2559. template <class _Ap, size_t _Np, class _A0, class _A1>
  2560. struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1>
  2561. : public false_type
  2562. {};
  2563. // Incomplete array types are not constructible
  2564. template <class _Ap>
  2565. struct __is_constructible0_imp<false, _Ap[]>
  2566. : public false_type
  2567. {};
  2568. template <class _Ap, class _A0>
  2569. struct __is_constructible1_imp<false, _Ap[], _A0>
  2570. : public false_type
  2571. {};
  2572. template <class _Ap, class _A0, class _A1>
  2573. struct __is_constructible2_imp<false, _Ap[], _A0, _A1>
  2574. : public false_type
  2575. {};
  2576. #endif // _LIBCPP_HAS_NO_VARIADICS
  2577. #endif // __has_feature(is_constructible)
  2578. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
  2579. template <class _Tp, class ..._Args> _LIBCPP_CONSTEXPR bool is_constructible_v
  2580. = is_constructible<_Tp, _Args...>::value;
  2581. #endif
  2582. // is_default_constructible
  2583. template <class _Tp>
  2584. struct _LIBCPP_TYPE_VIS_ONLY is_default_constructible
  2585. : public is_constructible<_Tp>
  2586. {};
  2587. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  2588. template <class _Tp> _LIBCPP_CONSTEXPR bool is_default_constructible_v
  2589. = is_default_constructible<_Tp>::value;
  2590. #endif
  2591. // is_copy_constructible
  2592. template <class _Tp>
  2593. struct _LIBCPP_TYPE_VIS_ONLY is_copy_constructible
  2594. : public is_constructible<_Tp,
  2595. typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
  2596. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  2597. template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_constructible_v
  2598. = is_copy_constructible<_Tp>::value;
  2599. #endif
  2600. // is_move_constructible
  2601. template <class _Tp>
  2602. struct _LIBCPP_TYPE_VIS_ONLY is_move_constructible
  2603. #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  2604. : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
  2605. #else
  2606. : public is_copy_constructible<_Tp>
  2607. #endif
  2608. {};
  2609. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  2610. template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_constructible_v
  2611. = is_move_constructible<_Tp>::value;
  2612. #endif
  2613. // is_trivially_constructible
  2614. #ifndef _LIBCPP_HAS_NO_VARIADICS
  2615. #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
  2616. template <class _Tp, class... _Args>
  2617. struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
  2618. : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
  2619. {
  2620. };
  2621. #else // !__has_feature(is_trivially_constructible)
  2622. template <class _Tp, class... _Args>
  2623. struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
  2624. : false_type
  2625. {
  2626. };
  2627. template <class _Tp>
  2628. struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp>
  2629. #if __has_feature(has_trivial_constructor) || (_GNUC_VER >= 403)
  2630. : integral_constant<bool, __has_trivial_constructor(_Tp)>
  2631. #else
  2632. : integral_constant<bool, is_scalar<_Tp>::value>
  2633. #endif
  2634. {
  2635. };
  2636. template <class _Tp>
  2637. #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  2638. struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&&>
  2639. #else
  2640. struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp>
  2641. #endif
  2642. : integral_constant<bool, is_scalar<_Tp>::value>
  2643. {
  2644. };
  2645. template <class _Tp>
  2646. struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&>
  2647. : integral_constant<bool, is_scalar<_Tp>::value>
  2648. {
  2649. };
  2650. template <class _Tp>
  2651. struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&>
  2652. : integral_constant<bool, is_scalar<_Tp>::value>
  2653. {
  2654. };
  2655. #endif // !__has_feature(is_trivially_constructible)
  2656. #else // _LIBCPP_HAS_NO_VARIADICS
  2657. template <class _Tp, class _A0 = __is_construct::__nat,
  2658. class _A1 = __is_construct::__nat>
  2659. struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
  2660. : false_type
  2661. {
  2662. };
  2663. #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
  2664. template <class _Tp>
  2665. struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat,
  2666. __is_construct::__nat>
  2667. : integral_constant<bool, __is_trivially_constructible(_Tp)>
  2668. {
  2669. };
  2670. template <class _Tp>
  2671. struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp,
  2672. __is_construct::__nat>
  2673. : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
  2674. {
  2675. };
  2676. template <class _Tp>
  2677. struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&,
  2678. __is_construct::__nat>
  2679. : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
  2680. {
  2681. };
  2682. template <class _Tp>
  2683. struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&,
  2684. __is_construct::__nat>
  2685. : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
  2686. {
  2687. };
  2688. #else // !__has_feature(is_trivially_constructible)
  2689. template <class _Tp>
  2690. struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat,
  2691. __is_construct::__nat>
  2692. : integral_constant<bool, is_scalar<_Tp>::value>
  2693. {
  2694. };
  2695. template <class _Tp>
  2696. struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp,
  2697. __is_construct::__nat>
  2698. : integral_constant<bool, is_scalar<_Tp>::value>
  2699. {
  2700. };
  2701. template <class _Tp>
  2702. struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&,
  2703. __is_construct::__nat>
  2704. : integral_constant<bool, is_scalar<_Tp>::value>
  2705. {
  2706. };
  2707. template <class _Tp>
  2708. struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&,
  2709. __is_construct::__nat>
  2710. : integral_constant<bool, is_scalar<_Tp>::value>
  2711. {
  2712. };
  2713. #endif // !__has_feature(is_trivially_constructible)
  2714. #endif // _LIBCPP_HAS_NO_VARIADICS
  2715. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
  2716. template <class _Tp, class... _Args> _LIBCPP_CONSTEXPR bool is_trivially_constructible_v
  2717. = is_trivially_constructible<_Tp, _Args...>::value;
  2718. #endif
  2719. // is_trivially_default_constructible
  2720. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_default_constructible
  2721. : public is_trivially_constructible<_Tp>
  2722. {};
  2723. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  2724. template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v
  2725. = is_trivially_default_constructible<_Tp>::value;
  2726. #endif
  2727. // is_trivially_copy_constructible
  2728. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_constructible
  2729. : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
  2730. {};
  2731. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  2732. template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v
  2733. = is_trivially_copy_constructible<_Tp>::value;
  2734. #endif
  2735. // is_trivially_move_constructible
  2736. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructible
  2737. #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  2738. : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
  2739. #else
  2740. : public is_trivially_copy_constructible<_Tp>
  2741. #endif
  2742. {};
  2743. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  2744. template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v
  2745. = is_trivially_move_constructible<_Tp>::value;
  2746. #endif
  2747. // is_trivially_assignable
  2748. #if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501
  2749. template <class _Tp, class _Arg>
  2750. struct is_trivially_assignable
  2751. : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
  2752. {
  2753. };
  2754. #else // !__has_feature(is_trivially_assignable)
  2755. template <class _Tp, class _Arg>
  2756. struct is_trivially_assignable
  2757. : public false_type {};
  2758. template <class _Tp>
  2759. struct is_trivially_assignable<_Tp&, _Tp>
  2760. : integral_constant<bool, is_scalar<_Tp>::value> {};
  2761. template <class _Tp>
  2762. struct is_trivially_assignable<_Tp&, _Tp&>
  2763. : integral_constant<bool, is_scalar<_Tp>::value> {};
  2764. template <class _Tp>
  2765. struct is_trivially_assignable<_Tp&, const _Tp&>
  2766. : integral_constant<bool, is_scalar<_Tp>::value> {};
  2767. #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  2768. template <class _Tp>
  2769. struct is_trivially_assignable<_Tp&, _Tp&&>
  2770. : integral_constant<bool, is_scalar<_Tp>::value> {};
  2771. #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
  2772. #endif // !__has_feature(is_trivially_assignable)
  2773. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  2774. template <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_trivially_assignable_v
  2775. = is_trivially_assignable<_Tp, _Arg>::value;
  2776. #endif
  2777. // is_trivially_copy_assignable
  2778. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_assignable
  2779. : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
  2780. typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
  2781. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  2782. template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v
  2783. = is_trivially_copy_assignable<_Tp>::value;
  2784. #endif
  2785. // is_trivially_move_assignable
  2786. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable
  2787. : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
  2788. #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  2789. typename add_rvalue_reference<_Tp>::type>
  2790. #else
  2791. typename add_lvalue_reference<_Tp>::type>
  2792. #endif
  2793. {};
  2794. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  2795. template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v
  2796. = is_trivially_move_assignable<_Tp>::value;
  2797. #endif
  2798. // is_trivially_destructible
  2799. #if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403)
  2800. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
  2801. : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
  2802. #else
  2803. template <class _Tp> struct __libcpp_trivial_destructor
  2804. : public integral_constant<bool, is_scalar<_Tp>::value ||
  2805. is_reference<_Tp>::value> {};
  2806. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
  2807. : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
  2808. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible<_Tp[]>
  2809. : public false_type {};
  2810. #endif
  2811. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  2812. template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_destructible_v
  2813. = is_trivially_destructible<_Tp>::value;
  2814. #endif
  2815. // is_nothrow_constructible
  2816. #if 0
  2817. template <class _Tp, class... _Args>
  2818. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
  2819. : public integral_constant<bool, __is_nothrow_constructible(_Tp(_Args...))>
  2820. {
  2821. };
  2822. #else
  2823. #ifndef _LIBCPP_HAS_NO_VARIADICS
  2824. #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
  2825. template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
  2826. template <class _Tp, class... _Args>
  2827. struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
  2828. : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
  2829. {
  2830. };
  2831. template <class _Tp>
  2832. void __implicit_conversion_to(_Tp) noexcept { }
  2833. template <class _Tp, class _Arg>
  2834. struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
  2835. : public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))>
  2836. {
  2837. };
  2838. template <class _Tp, bool _IsReference, class... _Args>
  2839. struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
  2840. : public false_type
  2841. {
  2842. };
  2843. template <class _Tp, class... _Args>
  2844. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
  2845. : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
  2846. {
  2847. };
  2848. template <class _Tp, size_t _Ns>
  2849. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp[_Ns]>
  2850. : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
  2851. {
  2852. };
  2853. #else // __has_feature(cxx_noexcept)
  2854. template <class _Tp, class... _Args>
  2855. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
  2856. : false_type
  2857. {
  2858. };
  2859. template <class _Tp>
  2860. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp>
  2861. #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
  2862. : integral_constant<bool, __has_nothrow_constructor(_Tp)>
  2863. #else
  2864. : integral_constant<bool, is_scalar<_Tp>::value>
  2865. #endif
  2866. {
  2867. };
  2868. template <class _Tp>
  2869. #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  2870. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&&>
  2871. #else
  2872. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp>
  2873. #endif
  2874. #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
  2875. : integral_constant<bool, __has_nothrow_copy(_Tp)>
  2876. #else
  2877. : integral_constant<bool, is_scalar<_Tp>::value>
  2878. #endif
  2879. {
  2880. };
  2881. template <class _Tp>
  2882. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&>
  2883. #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
  2884. : integral_constant<bool, __has_nothrow_copy(_Tp)>
  2885. #else
  2886. : integral_constant<bool, is_scalar<_Tp>::value>
  2887. #endif
  2888. {
  2889. };
  2890. template <class _Tp>
  2891. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&>
  2892. #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
  2893. : integral_constant<bool, __has_nothrow_copy(_Tp)>
  2894. #else
  2895. : integral_constant<bool, is_scalar<_Tp>::value>
  2896. #endif
  2897. {
  2898. };
  2899. #endif // __has_feature(cxx_noexcept)
  2900. #else // _LIBCPP_HAS_NO_VARIADICS
  2901. template <class _Tp, class _A0 = __is_construct::__nat,
  2902. class _A1 = __is_construct::__nat>
  2903. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
  2904. : false_type
  2905. {
  2906. };
  2907. template <class _Tp>
  2908. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, __is_construct::__nat,
  2909. __is_construct::__nat>
  2910. #if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
  2911. : integral_constant<bool, __has_nothrow_constructor(_Tp)>
  2912. #else
  2913. : integral_constant<bool, is_scalar<_Tp>::value>
  2914. #endif
  2915. {
  2916. };
  2917. template <class _Tp>
  2918. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp,
  2919. __is_construct::__nat>
  2920. #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
  2921. : integral_constant<bool, __has_nothrow_copy(_Tp)>
  2922. #else
  2923. : integral_constant<bool, is_scalar<_Tp>::value>
  2924. #endif
  2925. {
  2926. };
  2927. template <class _Tp>
  2928. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&,
  2929. __is_construct::__nat>
  2930. #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
  2931. : integral_constant<bool, __has_nothrow_copy(_Tp)>
  2932. #else
  2933. : integral_constant<bool, is_scalar<_Tp>::value>
  2934. #endif
  2935. {
  2936. };
  2937. template <class _Tp>
  2938. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&,
  2939. __is_construct::__nat>
  2940. #if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
  2941. : integral_constant<bool, __has_nothrow_copy(_Tp)>
  2942. #else
  2943. : integral_constant<bool, is_scalar<_Tp>::value>
  2944. #endif
  2945. {
  2946. };
  2947. #endif // _LIBCPP_HAS_NO_VARIADICS
  2948. #endif // __has_feature(is_nothrow_constructible)
  2949. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
  2950. template <class _Tp, class ..._Args> _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v
  2951. = is_nothrow_constructible<_Tp, _Args...>::value;
  2952. #endif
  2953. // is_nothrow_default_constructible
  2954. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_default_constructible
  2955. : public is_nothrow_constructible<_Tp>
  2956. {};
  2957. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  2958. template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v
  2959. = is_nothrow_default_constructible<_Tp>::value;
  2960. #endif
  2961. // is_nothrow_copy_constructible
  2962. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_constructible
  2963. : public is_nothrow_constructible<_Tp,
  2964. typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
  2965. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  2966. template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v
  2967. = is_nothrow_copy_constructible<_Tp>::value;
  2968. #endif
  2969. // is_nothrow_move_constructible
  2970. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible
  2971. #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  2972. : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
  2973. #else
  2974. : public is_nothrow_copy_constructible<_Tp>
  2975. #endif
  2976. {};
  2977. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  2978. template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v
  2979. = is_nothrow_move_constructible<_Tp>::value;
  2980. #endif
  2981. // is_nothrow_assignable
  2982. #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
  2983. template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
  2984. template <class _Tp, class _Arg>
  2985. struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
  2986. : public false_type
  2987. {
  2988. };
  2989. template <class _Tp, class _Arg>
  2990. struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
  2991. : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
  2992. {
  2993. };
  2994. template <class _Tp, class _Arg>
  2995. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable
  2996. : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
  2997. {
  2998. };
  2999. #else // __has_feature(cxx_noexcept)
  3000. template <class _Tp, class _Arg>
  3001. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable
  3002. : public false_type {};
  3003. template <class _Tp>
  3004. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp>
  3005. #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
  3006. : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
  3007. #else
  3008. : integral_constant<bool, is_scalar<_Tp>::value> {};
  3009. #endif
  3010. template <class _Tp>
  3011. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp&>
  3012. #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
  3013. : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
  3014. #else
  3015. : integral_constant<bool, is_scalar<_Tp>::value> {};
  3016. #endif
  3017. template <class _Tp>
  3018. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, const _Tp&>
  3019. #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
  3020. : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
  3021. #else
  3022. : integral_constant<bool, is_scalar<_Tp>::value> {};
  3023. #endif
  3024. #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  3025. template <class _Tp>
  3026. struct is_nothrow_assignable<_Tp&, _Tp&&>
  3027. #if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
  3028. : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
  3029. #else
  3030. : integral_constant<bool, is_scalar<_Tp>::value> {};
  3031. #endif
  3032. #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
  3033. #endif // __has_feature(cxx_noexcept)
  3034. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  3035. template <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v
  3036. = is_nothrow_assignable<_Tp, _Arg>::value;
  3037. #endif
  3038. // is_nothrow_copy_assignable
  3039. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_assignable
  3040. : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
  3041. typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
  3042. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  3043. template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v
  3044. = is_nothrow_copy_assignable<_Tp>::value;
  3045. #endif
  3046. // is_nothrow_move_assignable
  3047. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable
  3048. : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
  3049. #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  3050. typename add_rvalue_reference<_Tp>::type>
  3051. #else
  3052. typename add_lvalue_reference<_Tp>::type>
  3053. #endif
  3054. {};
  3055. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  3056. template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v
  3057. = is_nothrow_move_assignable<_Tp>::value;
  3058. #endif
  3059. // is_nothrow_destructible
  3060. #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
  3061. template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
  3062. template <class _Tp>
  3063. struct __libcpp_is_nothrow_destructible<false, _Tp>
  3064. : public false_type
  3065. {
  3066. };
  3067. template <class _Tp>
  3068. struct __libcpp_is_nothrow_destructible<true, _Tp>
  3069. : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
  3070. {
  3071. };
  3072. template <class _Tp>
  3073. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
  3074. : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
  3075. {
  3076. };
  3077. template <class _Tp, size_t _Ns>
  3078. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[_Ns]>
  3079. : public is_nothrow_destructible<_Tp>
  3080. {
  3081. };
  3082. template <class _Tp>
  3083. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&>
  3084. : public true_type
  3085. {
  3086. };
  3087. #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  3088. template <class _Tp>
  3089. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&&>
  3090. : public true_type
  3091. {
  3092. };
  3093. #endif
  3094. #else
  3095. template <class _Tp> struct __libcpp_nothrow_destructor
  3096. : public integral_constant<bool, is_scalar<_Tp>::value ||
  3097. is_reference<_Tp>::value> {};
  3098. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
  3099. : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
  3100. template <class _Tp>
  3101. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[]>
  3102. : public false_type {};
  3103. #endif
  3104. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  3105. template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v
  3106. = is_nothrow_destructible<_Tp>::value;
  3107. #endif
  3108. // is_pod
  3109. #if __has_feature(is_pod) || (_GNUC_VER >= 403)
  3110. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
  3111. : public integral_constant<bool, __is_pod(_Tp)> {};
  3112. #else
  3113. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
  3114. : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
  3115. is_trivially_copy_constructible<_Tp>::value &&
  3116. is_trivially_copy_assignable<_Tp>::value &&
  3117. is_trivially_destructible<_Tp>::value> {};
  3118. #endif
  3119. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  3120. template <class _Tp> _LIBCPP_CONSTEXPR bool is_pod_v
  3121. = is_pod<_Tp>::value;
  3122. #endif
  3123. // is_literal_type;
  3124. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_literal_type
  3125. #ifdef _LIBCPP_IS_LITERAL
  3126. : public integral_constant<bool, _LIBCPP_IS_LITERAL(_Tp)>
  3127. #else
  3128. : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
  3129. is_reference<typename remove_all_extents<_Tp>::type>::value>
  3130. #endif
  3131. {};
  3132. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  3133. template <class _Tp> _LIBCPP_CONSTEXPR bool is_literal_type_v
  3134. = is_literal_type<_Tp>::value;
  3135. #endif
  3136. // is_standard_layout;
  3137. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout
  3138. #if __has_feature(is_standard_layout) || (_GNUC_VER >= 407)
  3139. : public integral_constant<bool, __is_standard_layout(_Tp)>
  3140. #else
  3141. : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
  3142. #endif
  3143. {};
  3144. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  3145. template <class _Tp> _LIBCPP_CONSTEXPR bool is_standard_layout_v
  3146. = is_standard_layout<_Tp>::value;
  3147. #endif
  3148. // is_trivially_copyable;
  3149. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable
  3150. #if __has_feature(is_trivially_copyable)
  3151. : public integral_constant<bool, __is_trivially_copyable(_Tp)>
  3152. #elif _GNUC_VER >= 501
  3153. : public integral_constant<bool, !is_volatile<_Tp>::value && __is_trivially_copyable(_Tp)>
  3154. #else
  3155. : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
  3156. #endif
  3157. {};
  3158. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  3159. template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
  3160. = is_trivially_copyable<_Tp>::value;
  3161. #endif
  3162. // is_trivial;
  3163. template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivial
  3164. #if __has_feature(is_trivial) || _GNUC_VER >= 407
  3165. : public integral_constant<bool, __is_trivial(_Tp)>
  3166. #else
  3167. : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
  3168. is_trivially_default_constructible<_Tp>::value>
  3169. #endif
  3170. {};
  3171. #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
  3172. template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivial_v
  3173. = is_trivial<_Tp>::value;
  3174. #endif
  3175. template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
  3176. template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
  3177. template <class _Tp> struct __is_reference_wrapper
  3178. : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
  3179. #ifndef _LIBCPP_CXX03_LANG
  3180. // Check for complete types
  3181. template <class ..._Tp> struct __check_complete;
  3182. template <>
  3183. struct __check_complete<>
  3184. {
  3185. };
  3186. template <class _Hp, class _T0, class ..._Tp>
  3187. struct __check_complete<_Hp, _T0, _Tp...>
  3188. : private __check_complete<_Hp>,
  3189. private __check_complete<_T0, _Tp...>
  3190. {
  3191. };
  3192. template <class _Hp>
  3193. struct __check_complete<_Hp, _Hp>
  3194. : private __check_complete<_Hp>
  3195. {
  3196. };
  3197. template <class _Tp>
  3198. struct __check_complete<_Tp>
  3199. {
  3200. static_assert(sizeof(_Tp) > 0, "Type must be complete.");
  3201. };
  3202. template <class _Tp>
  3203. struct __check_complete<_Tp&>
  3204. : private __check_complete<_Tp>
  3205. {
  3206. };
  3207. template <class _Tp>
  3208. struct __check_complete<_Tp&&>
  3209. : private __check_complete<_Tp>
  3210. {
  3211. };
  3212. template <class _Rp, class ..._Param>
  3213. struct __check_complete<_Rp (*)(_Param...)>
  3214. : private __check_complete<_Rp>
  3215. {
  3216. };
  3217. template <class ..._Param>
  3218. struct __check_complete<void (*)(_Param...)>
  3219. {
  3220. };
  3221. template <class _Rp, class ..._Param>
  3222. struct __check_complete<_Rp (_Param...)>
  3223. : private __check_complete<_Rp>
  3224. {
  3225. };
  3226. template <class ..._Param>
  3227. struct __check_complete<void (_Param...)>
  3228. {
  3229. };
  3230. template <class _Rp, class _Class, class ..._Param>
  3231. struct __check_complete<_Rp (_Class::*)(_Param...)>
  3232. : private __check_complete<_Class>
  3233. {
  3234. };
  3235. template <class _Rp, class _Class, class ..._Param>
  3236. struct __check_complete<_Rp (_Class::*)(_Param...) const>
  3237. : private __check_complete<_Class>
  3238. {
  3239. };
  3240. template <class _Rp, class _Class, class ..._Param>
  3241. struct __check_complete<_Rp (_Class::*)(_Param...) volatile>
  3242. : private __check_complete<_Class>
  3243. {
  3244. };
  3245. template <class _Rp, class _Class, class ..._Param>
  3246. struct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
  3247. : private __check_complete<_Class>
  3248. {
  3249. };
  3250. template <class _Rp, class _Class, class ..._Param>
  3251. struct __check_complete<_Rp (_Class::*)(_Param...) &>
  3252. : private __check_complete<_Class>
  3253. {
  3254. };
  3255. template <class _Rp, class _Class, class ..._Param>
  3256. struct __check_complete<_Rp (_Class::*)(_Param...) const&>
  3257. : private __check_complete<_Class>
  3258. {
  3259. };
  3260. template <class _Rp, class _Class, class ..._Param>
  3261. struct __check_complete<_Rp (_Class::*)(_Param...) volatile&>
  3262. : private __check_complete<_Class>
  3263. {
  3264. };
  3265. template <class _Rp, class _Class, class ..._Param>
  3266. struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&>
  3267. : private __check_complete<_Class>
  3268. {
  3269. };
  3270. template <class _Rp, class _Class, class ..._Param>
  3271. struct __check_complete<_Rp (_Class::*)(_Param...) &&>
  3272. : private __check_complete<_Class>
  3273. {
  3274. };
  3275. template <class _Rp, class _Class, class ..._Param>
  3276. struct __check_complete<_Rp (_Class::*)(_Param...) const&&>
  3277. : private __check_complete<_Class>
  3278. {
  3279. };
  3280. template <class _Rp, class _Class, class ..._Param>
  3281. struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&>
  3282. : private __check_complete<_Class>
  3283. {
  3284. };
  3285. template <class _Rp, class _Class, class ..._Param>
  3286. struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
  3287. : private __check_complete<_Class>
  3288. {
  3289. };
  3290. template <class _Rp, class _Class>
  3291. struct __check_complete<_Rp _Class::*>
  3292. : private __check_complete<_Class>
  3293. {
  3294. };
  3295. template <class _Fp, class _A0,
  3296. class _DecayFp = typename decay<_Fp>::type,
  3297. class _DecayA0 = typename decay<_A0>::type,
  3298. class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
  3299. using __enable_if_bullet1 = typename enable_if
  3300. <
  3301. is_member_function_pointer<_DecayFp>::value
  3302. && is_base_of<_ClassT, _DecayA0>::value
  3303. >::type;
  3304. template <class _Fp, class _A0,
  3305. class _DecayFp = typename decay<_Fp>::type,
  3306. class _DecayA0 = typename decay<_A0>::type>
  3307. using __enable_if_bullet2 = typename enable_if
  3308. <
  3309. is_member_function_pointer<_DecayFp>::value
  3310. && __is_reference_wrapper<_DecayA0>::value
  3311. >::type;
  3312. template <class _Fp, class _A0,
  3313. class _DecayFp = typename decay<_Fp>::type,
  3314. class _DecayA0 = typename decay<_A0>::type,
  3315. class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
  3316. using __enable_if_bullet3 = typename enable_if
  3317. <
  3318. is_member_function_pointer<_DecayFp>::value
  3319. && !is_base_of<_ClassT, _DecayA0>::value
  3320. && !__is_reference_wrapper<_DecayA0>::value
  3321. >::type;
  3322. template <class _Fp, class _A0,
  3323. class _DecayFp = typename decay<_Fp>::type,
  3324. class _DecayA0 = typename decay<_A0>::type,
  3325. class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
  3326. using __enable_if_bullet4 = typename enable_if
  3327. <
  3328. is_member_object_pointer<_DecayFp>::value
  3329. && is_base_of<_ClassT, _DecayA0>::value
  3330. >::type;
  3331. template <class _Fp, class _A0,
  3332. class _DecayFp = typename decay<_Fp>::type,
  3333. class _DecayA0 = typename decay<_A0>::type>
  3334. using __enable_if_bullet5 = typename enable_if
  3335. <
  3336. is_member_object_pointer<_DecayFp>::value
  3337. && __is_reference_wrapper<_DecayA0>::value
  3338. >::type;
  3339. template <class _Fp, class _A0,
  3340. class _DecayFp = typename decay<_Fp>::type,
  3341. class _DecayA0 = typename decay<_A0>::type,
  3342. class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
  3343. using __enable_if_bullet6 = typename enable_if
  3344. <
  3345. is_member_object_pointer<_DecayFp>::value
  3346. && !is_base_of<_ClassT, _DecayA0>::value
  3347. && !__is_reference_wrapper<_DecayA0>::value
  3348. >::type;
  3349. // __invoke forward declarations
  3350. // fall back - none of the bullets
  3351. #define _LIBCPP_INVOKE_RETURN(...) \
  3352. noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \
  3353. { return __VA_ARGS__; }
  3354. template <class ..._Args>
  3355. auto __invoke(__any, _Args&& ...__args) -> __nat;
  3356. template <class ..._Args>
  3357. auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat;
  3358. // bullets 1, 2 and 3
  3359. template <class _Fp, class _A0, class ..._Args,
  3360. class = __enable_if_bullet1<_Fp, _A0>>
  3361. inline _LIBCPP_INLINE_VISIBILITY
  3362. auto
  3363. __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
  3364. _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
  3365. template <class _Fp, class _A0, class ..._Args,
  3366. class = __enable_if_bullet1<_Fp, _A0>>
  3367. inline _LIBCPP_INLINE_VISIBILITY
  3368. _LIBCPP_CONSTEXPR auto
  3369. __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
  3370. _LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
  3371. template <class _Fp, class _A0, class ..._Args,
  3372. class = __enable_if_bullet2<_Fp, _A0>>
  3373. inline _LIBCPP_INLINE_VISIBILITY
  3374. auto
  3375. __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
  3376. _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
  3377. template <class _Fp, class _A0, class ..._Args,
  3378. class = __enable_if_bullet2<_Fp, _A0>>
  3379. inline _LIBCPP_INLINE_VISIBILITY
  3380. _LIBCPP_CONSTEXPR auto
  3381. __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
  3382. _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
  3383. template <class _Fp, class _A0, class ..._Args,
  3384. class = __enable_if_bullet3<_Fp, _A0>>
  3385. inline _LIBCPP_INLINE_VISIBILITY
  3386. auto
  3387. __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
  3388. _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
  3389. template <class _Fp, class _A0, class ..._Args,
  3390. class = __enable_if_bullet3<_Fp, _A0>>
  3391. inline _LIBCPP_INLINE_VISIBILITY
  3392. _LIBCPP_CONSTEXPR auto
  3393. __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
  3394. _LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
  3395. // bullets 4, 5 and 6
  3396. template <class _Fp, class _A0,
  3397. class = __enable_if_bullet4<_Fp, _A0>>
  3398. inline _LIBCPP_INLINE_VISIBILITY
  3399. auto
  3400. __invoke(_Fp&& __f, _A0&& __a0)
  3401. _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
  3402. template <class _Fp, class _A0,
  3403. class = __enable_if_bullet4<_Fp, _A0>>
  3404. inline _LIBCPP_INLINE_VISIBILITY
  3405. _LIBCPP_CONSTEXPR auto
  3406. __invoke_constexpr(_Fp&& __f, _A0&& __a0)
  3407. _LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
  3408. template <class _Fp, class _A0,
  3409. class = __enable_if_bullet5<_Fp, _A0>>
  3410. inline _LIBCPP_INLINE_VISIBILITY
  3411. auto
  3412. __invoke(_Fp&& __f, _A0&& __a0)
  3413. _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
  3414. template <class _Fp, class _A0,
  3415. class = __enable_if_bullet5<_Fp, _A0>>
  3416. inline _LIBCPP_INLINE_VISIBILITY
  3417. _LIBCPP_CONSTEXPR auto
  3418. __invoke_constexpr(_Fp&& __f, _A0&& __a0)
  3419. _LIBCPP_INVOKE_RETURN(__a0.get().*__f)
  3420. template <class _Fp, class _A0,
  3421. class = __enable_if_bullet6<_Fp, _A0>>
  3422. inline _LIBCPP_INLINE_VISIBILITY
  3423. auto
  3424. __invoke(_Fp&& __f, _A0&& __a0)
  3425. _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
  3426. template <class _Fp, class _A0,
  3427. class = __enable_if_bullet6<_Fp, _A0>>
  3428. inline _LIBCPP_INLINE_VISIBILITY
  3429. _LIBCPP_CONSTEXPR auto
  3430. __invoke_constexpr(_Fp&& __f, _A0&& __a0)
  3431. _LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
  3432. // bullet 7
  3433. template <class _Fp, class ..._Args>
  3434. inline _LIBCPP_INLINE_VISIBILITY
  3435. auto
  3436. __invoke(_Fp&& __f, _Args&& ...__args)
  3437. _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
  3438. template <class _Fp, class ..._Args>
  3439. inline _LIBCPP_INLINE_VISIBILITY
  3440. _LIBCPP_CONSTEXPR auto
  3441. __invoke_constexpr(_Fp&& __f, _Args&& ...__args)
  3442. _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
  3443. #undef _LIBCPP_INVOKE_RETURN
  3444. // __invokable
  3445. template <class _Ret, class _Fp, class ..._Args>
  3446. struct __invokable_r
  3447. : private __check_complete<_Fp>
  3448. {
  3449. using _Result = decltype(
  3450. _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
  3451. static const bool value =
  3452. conditional<
  3453. !is_same<_Result, __nat>::value,
  3454. typename conditional<
  3455. is_void<_Ret>::value,
  3456. true_type,
  3457. is_convertible<_Result, _Ret>
  3458. >::type,
  3459. false_type
  3460. >::type::value;
  3461. };
  3462. template <class _Fp, class ..._Args>
  3463. using __invokable = __invokable_r<void, _Fp, _Args...>;
  3464. template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args>
  3465. struct __nothrow_invokable_r_imp {
  3466. static const bool value = false;
  3467. };
  3468. template <class _Ret, class _Fp, class ..._Args>
  3469. struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
  3470. {
  3471. typedef __nothrow_invokable_r_imp _ThisT;
  3472. template <class _Tp>
  3473. static void __test_noexcept(_Tp) noexcept;
  3474. static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
  3475. _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)));
  3476. };
  3477. template <class _Ret, class _Fp, class ..._Args>
  3478. struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
  3479. {
  3480. static const bool value = noexcept(
  3481. _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
  3482. };
  3483. template <class _Ret, class _Fp, class ..._Args>
  3484. using __nothrow_invokable_r =
  3485. __nothrow_invokable_r_imp<
  3486. __invokable_r<_Ret, _Fp, _Args...>::value,
  3487. is_void<_Ret>::value,
  3488. _Ret, _Fp, _Args...
  3489. >;
  3490. template <class _Fp, class ..._Args>
  3491. struct __invoke_of
  3492. : public enable_if<
  3493. __invokable<_Fp, _Args...>::value,
  3494. typename __invokable_r<void, _Fp, _Args...>::_Result>
  3495. {
  3496. };
  3497. // result_of
  3498. template <class _Fp, class ..._Args>
  3499. class _LIBCPP_TYPE_VIS_ONLY result_of<_Fp(_Args...)>
  3500. : public __invoke_of<_Fp, _Args...>
  3501. {
  3502. };
  3503. #if _LIBCPP_STD_VER > 11
  3504. template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
  3505. #endif
  3506. #if _LIBCPP_STD_VER > 14
  3507. // is_callable
  3508. template <class _Fn, class _Ret = void>
  3509. struct _LIBCPP_TYPE_VIS_ONLY is_callable;
  3510. template <class _Fn, class ..._Args, class _Ret>
  3511. struct _LIBCPP_TYPE_VIS_ONLY is_callable<_Fn(_Args...), _Ret>
  3512. : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
  3513. template <class _Fn, class _Ret = void>
  3514. constexpr bool is_callable_v = is_callable<_Fn, _Ret>::value;
  3515. // is_nothrow_callable
  3516. template <class _Fn, class _Ret = void>
  3517. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_callable;
  3518. template <class _Fn, class ..._Args, class _Ret>
  3519. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_callable<_Fn(_Args...), _Ret>
  3520. : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value>
  3521. {};
  3522. template <class _Fn, class _Ret = void>
  3523. constexpr bool is_nothrow_callable_v = is_nothrow_callable<_Fn, _Ret>::value;
  3524. #endif // _LIBCPP_STD_VER > 14
  3525. #endif // !defined(_LIBCPP_CXX03_LANG)
  3526. template <class _Tp> struct __is_swappable;
  3527. template <class _Tp> struct __is_nothrow_swappable;
  3528. template <class _Tp>
  3529. inline _LIBCPP_INLINE_VISIBILITY
  3530. #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
  3531. typename enable_if
  3532. <
  3533. is_move_constructible<_Tp>::value &&
  3534. is_move_assignable<_Tp>::value
  3535. >::type
  3536. #else
  3537. void
  3538. #endif
  3539. swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
  3540. is_nothrow_move_assignable<_Tp>::value)
  3541. {
  3542. _Tp __t(_VSTD::move(__x));
  3543. __x = _VSTD::move(__y);
  3544. __y = _VSTD::move(__t);
  3545. }
  3546. template<class _Tp, size_t _Np>
  3547. inline _LIBCPP_INLINE_VISIBILITY
  3548. typename enable_if<
  3549. __is_swappable<_Tp>::value
  3550. >::type
  3551. swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
  3552. template <class _ForwardIterator1, class _ForwardIterator2>
  3553. inline _LIBCPP_INLINE_VISIBILITY
  3554. void
  3555. iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
  3556. // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
  3557. _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
  3558. *_VSTD::declval<_ForwardIterator2>())))
  3559. {
  3560. swap(*__a, *__b);
  3561. }
  3562. // __swappable
  3563. namespace __detail
  3564. {
  3565. // ALL generic swap overloads MUST already have a declaration available at this point.
  3566. template <class _Tp, class _Up = _Tp,
  3567. bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
  3568. struct __swappable_with
  3569. {
  3570. template <class _LHS, class _RHS>
  3571. static decltype(swap(_VSTD::declval<_LHS>(), _VSTD::declval<_RHS>()))
  3572. __test_swap(int);
  3573. template <class, class>
  3574. static __nat __test_swap(long);
  3575. // Extra parens are needed for the C++03 definition of decltype.
  3576. typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
  3577. typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
  3578. static const bool value = !is_same<__swap1, __nat>::value
  3579. && !is_same<__swap2, __nat>::value;
  3580. };
  3581. template <class _Tp, class _Up>
  3582. struct __swappable_with<_Tp, _Up, false> : false_type {};
  3583. template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
  3584. struct __nothrow_swappable_with {
  3585. static const bool value =
  3586. #ifndef _LIBCPP_HAS_NO_NOEXCEPT
  3587. noexcept(swap(_VSTD::declval<_Tp>(), _VSTD::declval<_Up>()))
  3588. && noexcept(swap(_VSTD::declval<_Up>(), _VSTD::declval<_Tp>()));
  3589. #else
  3590. false;
  3591. #endif
  3592. };
  3593. template <class _Tp, class _Up>
  3594. struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
  3595. } // __detail
  3596. template <class _Tp>
  3597. struct __is_swappable
  3598. : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value>
  3599. {
  3600. };
  3601. template <class _Tp>
  3602. struct __is_nothrow_swappable
  3603. : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value>
  3604. {
  3605. };
  3606. #if _LIBCPP_STD_VER > 14
  3607. template <class _Tp, class _Up>
  3608. struct _LIBCPP_TYPE_VIS_ONLY is_swappable_with
  3609. : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value>
  3610. {
  3611. };
  3612. template <class _Tp>
  3613. struct _LIBCPP_TYPE_VIS_ONLY is_swappable
  3614. : public conditional<
  3615. __is_referenceable<_Tp>::value,
  3616. is_swappable_with<
  3617. typename add_lvalue_reference<_Tp>::type,
  3618. typename add_lvalue_reference<_Tp>::type>,
  3619. false_type
  3620. >::type
  3621. {
  3622. };
  3623. template <class _Tp, class _Up>
  3624. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_swappable_with
  3625. : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value>
  3626. {
  3627. };
  3628. template <class _Tp>
  3629. struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_swappable
  3630. : public conditional<
  3631. __is_referenceable<_Tp>::value,
  3632. is_nothrow_swappable_with<
  3633. typename add_lvalue_reference<_Tp>::type,
  3634. typename add_lvalue_reference<_Tp>::type>,
  3635. false_type
  3636. >::type
  3637. {
  3638. };
  3639. template <class _Tp, class _Up>
  3640. constexpr bool is_swappable_with_v = is_swappable_with<_Tp, _Up>::value;
  3641. template <class _Tp>
  3642. constexpr bool is_swappable_v = is_swappable<_Tp>::value;
  3643. template <class _Tp, class _Up>
  3644. constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with<_Tp, _Up>::value;
  3645. template <class _Tp>
  3646. constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value;
  3647. #endif // _LIBCPP_STD_VER > 14
  3648. #ifdef _LIBCPP_UNDERLYING_TYPE
  3649. template <class _Tp>
  3650. struct underlying_type
  3651. {
  3652. typedef _LIBCPP_UNDERLYING_TYPE(_Tp) type;
  3653. };
  3654. #if _LIBCPP_STD_VER > 11
  3655. template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
  3656. #endif
  3657. #else // _LIBCPP_UNDERLYING_TYPE
  3658. template <class _Tp, bool _Support = false>
  3659. struct underlying_type
  3660. {
  3661. static_assert(_Support, "The underyling_type trait requires compiler "
  3662. "support. Either no such support exists or "
  3663. "libc++ does not know how to use it.");
  3664. };
  3665. #endif // _LIBCPP_UNDERLYING_TYPE
  3666. template <class _Tp, bool = is_enum<_Tp>::value>
  3667. struct __sfinae_underlying_type
  3668. {
  3669. typedef typename underlying_type<_Tp>::type type;
  3670. typedef decltype(((type)1) + 0) __promoted_type;
  3671. };
  3672. template <class _Tp>
  3673. struct __sfinae_underlying_type<_Tp, false> {};
  3674. inline _LIBCPP_INLINE_VISIBILITY
  3675. int __convert_to_integral(int __val) { return __val; }
  3676. inline _LIBCPP_INLINE_VISIBILITY
  3677. unsigned __convert_to_integral(unsigned __val) { return __val; }
  3678. inline _LIBCPP_INLINE_VISIBILITY
  3679. long __convert_to_integral(long __val) { return __val; }
  3680. inline _LIBCPP_INLINE_VISIBILITY
  3681. unsigned long __convert_to_integral(unsigned long __val) { return __val; }
  3682. inline _LIBCPP_INLINE_VISIBILITY
  3683. long long __convert_to_integral(long long __val) { return __val; }
  3684. inline _LIBCPP_INLINE_VISIBILITY
  3685. unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
  3686. #ifndef _LIBCPP_HAS_NO_INT128
  3687. inline _LIBCPP_INLINE_VISIBILITY
  3688. __int128_t __convert_to_integral(__int128_t __val) { return __val; }
  3689. inline _LIBCPP_INLINE_VISIBILITY
  3690. __uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
  3691. #endif
  3692. template <class _Tp>
  3693. inline _LIBCPP_INLINE_VISIBILITY
  3694. typename __sfinae_underlying_type<_Tp>::__promoted_type
  3695. __convert_to_integral(_Tp __val) { return __val; }
  3696. #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
  3697. template <class _Tp>
  3698. struct __has_operator_addressof_member_imp
  3699. {
  3700. template <class _Up>
  3701. static auto __test(int)
  3702. -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type;
  3703. template <class>
  3704. static auto __test(long) -> false_type;
  3705. static const bool value = decltype(__test<_Tp>(0))::value;
  3706. };
  3707. template <class _Tp>
  3708. struct __has_operator_addressof_free_imp
  3709. {
  3710. template <class _Up>
  3711. static auto __test(int)
  3712. -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type;
  3713. template <class>
  3714. static auto __test(long) -> false_type;
  3715. static const bool value = decltype(__test<_Tp>(0))::value;
  3716. };
  3717. template <class _Tp>
  3718. struct __has_operator_addressof
  3719. : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value
  3720. || __has_operator_addressof_free_imp<_Tp>::value>
  3721. {};
  3722. #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
  3723. #if _LIBCPP_STD_VER > 14
  3724. template <class...> using void_t = void;
  3725. # ifndef _LIBCPP_HAS_NO_VARIADICS
  3726. template <class... _Args>
  3727. struct conjunction : __and_<_Args...> {};
  3728. template<class... _Args> constexpr bool conjunction_v = conjunction<_Args...>::value;
  3729. template <class... _Args>
  3730. struct disjunction : __or_<_Args...> {};
  3731. template<class... _Args> constexpr bool disjunction_v = disjunction<_Args...>::value;
  3732. template <class _Tp>
  3733. struct negation : __not_<_Tp> {};
  3734. template<class _Tp> constexpr bool negation_v = negation<_Tp>::value;
  3735. # endif // _LIBCPP_HAS_NO_VARIADICS
  3736. #endif // _LIBCPP_STD_VER > 14
  3737. // These traits are used in __tree and __hash_table
  3738. #ifndef _LIBCPP_CXX03_LANG
  3739. struct __extract_key_fail_tag {};
  3740. struct __extract_key_self_tag {};
  3741. struct __extract_key_first_tag {};
  3742. template <class _ValTy, class _Key,
  3743. class _RawValTy = typename __unconstref<_ValTy>::type>
  3744. struct __can_extract_key
  3745. : conditional<is_same<_RawValTy, _Key>::value, __extract_key_self_tag,
  3746. __extract_key_fail_tag>::type {};
  3747. template <class _Pair, class _Key, class _First, class _Second>
  3748. struct __can_extract_key<_Pair, _Key, pair<_First, _Second>>
  3749. : conditional<is_same<typename remove_const<_First>::type, _Key>::value,
  3750. __extract_key_first_tag, __extract_key_fail_tag>::type {};
  3751. // __can_extract_map_key uses true_type/false_type instead of the tags.
  3752. // It returns true if _Key != _ContainerValueTy (the container is a map not a set)
  3753. // and _ValTy == _Key.
  3754. template <class _ValTy, class _Key, class _ContainerValueTy,
  3755. class _RawValTy = typename __unconstref<_ValTy>::type>
  3756. struct __can_extract_map_key
  3757. : integral_constant<bool, is_same<_RawValTy, _Key>::value> {};
  3758. // This specialization returns __extract_key_fail_tag for non-map containers
  3759. // because _Key == _ContainerValueTy
  3760. template <class _ValTy, class _Key, class _RawValTy>
  3761. struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
  3762. : false_type {};
  3763. #endif
  3764. _LIBCPP_END_NAMESPACE_STD
  3765. #endif // _LIBCPP_TYPE_TRAITS