algorithm 101 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985
  1. // -*- C++ -*-
  2. //===----------------------------------------------------------------------===//
  3. //
  4. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5. // See https://llvm.org/LICENSE.txt for license information.
  6. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _LIBCPP_ALGORITHM
  10. #define _LIBCPP_ALGORITHM
  11. /*
  12. algorithm synopsis
  13. #include <initializer_list>
  14. namespace std
  15. {
  16. namespace ranges {
  17. // [algorithms.results], algorithm result types
  18. template <class I, class F>
  19. struct in_fun_result; // since C++20
  20. template <class I1, class I2>
  21. struct in_in_result; // since C++20
  22. template <class I, class O>
  23. struct in_out_result; // since C++20
  24. template <class I1, class I2, class O>
  25. struct in_in_out_result; // since C++20
  26. template <class I, class O1, class O2>
  27. struct in_out_out_result; // since C++20
  28. template <class I1, class I2>
  29. struct min_max_result; // since C++20
  30. template <class I>
  31. struct in_found_result; // since C++20
  32. template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
  33. indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> // since C++20
  34. constexpr I min_element(I first, S last, Comp comp = {}, Proj proj = {});
  35. template<forward_range R, class Proj = identity,
  36. indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> // since C++20
  37. constexpr borrowed_iterator_t<R> min_element(R&& r, Comp comp = {}, Proj proj = {});
  38. template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
  39. indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
  40. constexpr I ranges::max_element(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
  41. template<forward_range R, class Proj = identity,
  42. indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
  43. constexpr borrowed_iterator_t<R> ranges::max_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
  44. template<class I1, class I2>
  45. using mismatch_result = in_in_result<I1, I2>;
  46. template <input_iterator I1, sentinel_for<_I1> S1, input_iterator I2, sentinel_for<_I2> S2,
  47. class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
  48. requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
  49. constexpr mismatch_result<_I1, _I2> // since C++20
  50. mismatch()(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {})
  51. template <input_range R1, input_range R2,
  52. class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
  53. requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
  54. constexpr mismatch_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
  55. mismatch(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20
  56. requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
  57. constexpr I find(I first, S last, const T& value, Proj proj = {}); // since C++20
  58. template<input_range R, class T, class Proj = identity>
  59. requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
  60. constexpr borrowed_iterator_t<R>
  61. find(R&& r, const T& value, Proj proj = {}); // since C++20
  62. template<input_iterator I, sentinel_for<I> S, class Proj = identity,
  63. indirect_unary_predicate<projected<I, Proj>> Pred>
  64. constexpr I find_if(I first, S last, Pred pred, Proj proj = {}); // since C++20
  65. template<input_range R, class Proj = identity,
  66. indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
  67. constexpr borrowed_iterator_t<R>
  68. find_if(R&& r, Pred pred, Proj proj = {}); // since C++20
  69. template<input_iterator I, sentinel_for<I> S, class Proj = identity,
  70. indirect_unary_predicate<projected<I, Proj>> Pred>
  71. constexpr I find_if_not(I first, S last, Pred pred, Proj proj = {}); // since C++20
  72. template<input_range R, class Proj = identity,
  73. indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
  74. constexpr borrowed_iterator_t<R>
  75. find_if_not(R&& r, Pred pred, Proj proj = {}); // since C++20
  76. template<class T, class Proj = identity,
  77. indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
  78. constexpr const T& min(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
  79. template<copyable T, class Proj = identity,
  80. indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
  81. constexpr T min(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20
  82. template<input_range R, class Proj = identity,
  83. indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
  84. requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
  85. constexpr range_value_t<R>
  86. min(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
  87. template<class T, class Proj = identity,
  88. indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
  89. constexpr const T& max(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
  90. template<copyable T, class Proj = identity,
  91. indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
  92. constexpr T max(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20
  93. template<input_range R, class Proj = identity,
  94. indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
  95. requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
  96. constexpr range_value_t<R>
  97. max(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
  98. template<class I, class O>
  99. using unary_transform_result = in_out_result<I, O>; // since C++20
  100. template<class I1, class I2, class O>
  101. using binary_transform_result = in_in_out_result<I1, I2, O>; // since C++20
  102. template<input_iterator I, sentinel_for<I> S, weakly_incrementable O,
  103. copy_constructible F, class Proj = identity>
  104. requires indirectly_writable<O, indirect_result_t<F&, projected<I, Proj>>>
  105. constexpr ranges::unary_transform_result<I, O>
  106. transform(I first1, S last1, O result, F op, Proj proj = {}); // since C++20
  107. template<input_range R, weakly_incrementable O, copy_constructible F,
  108. class Proj = identity>
  109. requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R>, Proj>>>
  110. constexpr ranges::unary_transform_result<borrowed_iterator_t<R>, O>
  111. transform(R&& r, O result, F op, Proj proj = {}); // since C++20
  112. template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
  113. weakly_incrementable O, copy_constructible F, class Proj1 = identity,
  114. class Proj2 = identity>
  115. requires indirectly_writable<O, indirect_result_t<F&, projected<I1, Proj1>,
  116. projected<I2, Proj2>>>
  117. constexpr ranges::binary_transform_result<I1, I2, O>
  118. transform(I1 first1, S1 last1, I2 first2, S2 last2, O result,
  119. F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  120. template<input_range R1, input_range R2, weakly_incrementable O,
  121. copy_constructible F, class Proj1 = identity, class Proj2 = identity>
  122. requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R1>, Proj1>,
  123. projected<iterator_t<R2>, Proj2>>>
  124. constexpr ranges::binary_transform_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
  125. transform(R1&& r1, R2&& r2, O result,
  126. F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  127. template<input_iterator I, sentinel_for<I> S, class T, class Proj = identity>
  128. requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
  129. constexpr iter_difference_t<I>
  130. count(I first, S last, const T& value, Proj proj = {}); // since C++20
  131. template<input_range R, class T, class Proj = identity>
  132. requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
  133. constexpr range_difference_t<R>
  134. count(R&& r, const T& value, Proj proj = {}); // since C++20
  135. template<input_iterator I, sentinel_for<I> S, class Proj = identity,
  136. indirect_unary_predicate<projected<I, Proj>> Pred>
  137. constexpr iter_difference_t<I>
  138. count_if(I first, S last, Pred pred, Proj proj = {}); // since C++20
  139. template<input_range R, class Proj = identity,
  140. indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
  141. constexpr range_difference_t<R>
  142. count_if(R&& r, Pred pred, Proj proj = {}); // since C++20
  143. template<class T>
  144. using minmax_result = min_max_result<T>;
  145. template<class T, class Proj = identity,
  146. indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
  147. constexpr ranges::minmax_result<const T&>
  148. minmax(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
  149. template<copyable T, class Proj = identity,
  150. indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
  151. constexpr ranges::minmax_result<T>
  152. minmax(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20
  153. template<input_range R, class Proj = identity,
  154. indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
  155. requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
  156. constexpr ranges::minmax_result<range_value_t<R>>
  157. minmax(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
  158. template<class I>
  159. using minmax_element_result = min_max_result<I>;
  160. template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
  161. indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
  162. constexpr ranges::minmax_element_result<I>
  163. minmax_element(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
  164. template<forward_range R, class Proj = identity,
  165. indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
  166. constexpr ranges::minmax_element_result<borrowed_iterator_t<R>>
  167. minmax_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
  168. template<class I, class O>
  169. using copy_result = in_out_result<I, O>; // since C++20
  170. template<class I, class O>
  171. using copy_n_result = in_out_result<I, O>; // since C++20
  172. template<class I, class O>
  173. using copy_if_result = in_out_result<I, O>; // since C++20
  174. template<class I1, class I2>
  175. using copy_backward_result = in_out_result<I1, I2>; // since C++20
  176. template<input_iterator I, sentinel_for<I> S, weakly_incrementable O>
  177. requires indirectly_copyable<I, O>
  178. constexpr ranges::copy_result<I, O> ranges::copy(I first, S last, O result); // since C++20
  179. template<input_range R, weakly_incrementable O>
  180. requires indirectly_copyable<iterator_t<R>, O>
  181. constexpr ranges::copy_result<borrowed_iterator_t<R>, O> ranges::copy(R&& r, O result); // since C++20
  182. template<input_iterator I, weakly_incrementable O>
  183. requires indirectly_copyable<I, O>
  184. constexpr ranges::copy_n_result<I, O>
  185. ranges::copy_n(I first, iter_difference_t<I> n, O result); // since C++20
  186. template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Proj = identity,
  187. indirect_unary_predicate<projected<I, Proj>> Pred>
  188. requires indirectly_copyable<I, O>
  189. constexpr ranges::copy_if_result<I, O>
  190. ranges::copy_if(I first, S last, O result, Pred pred, Proj proj = {}); // since C++20
  191. template<input_range R, weakly_incrementable O, class Proj = identity,
  192. indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
  193. requires indirectly_copyable<iterator_t<R>, O>
  194. constexpr ranges::copy_if_result<borrowed_iterator_t<R>, O>
  195. ranges::copy_if(R&& r, O result, Pred pred, Proj proj = {}); // since C++20
  196. template<bidirectional_iterator I1, sentinel_for<I1> S1, bidirectional_iterator I2>
  197. requires indirectly_copyable<I1, I2>
  198. constexpr ranges::copy_backward_result<I1, I2>
  199. ranges::copy_backward(I1 first, S1 last, I2 result); // since C++20
  200. template<bidirectional_range R, bidirectional_iterator I>
  201. requires indirectly_copyable<iterator_t<R>, I>
  202. constexpr ranges::copy_backward_result<borrowed_iterator_t<R>, I>
  203. ranges::copy_backward(R&& r, I result); // since C++20
  204. template<class I, class F>
  205. using for_each_result = in_fun_result<I, F>; // since C++20
  206. template<input_iterator I, sentinel_for<I> S, class Proj = identity,
  207. indirectly_unary_invocable<projected<I, Proj>> Fun>
  208. constexpr ranges::for_each_result<I, Fun>
  209. ranges::for_each(I first, S last, Fun f, Proj proj = {}); // since C++20
  210. template<input_range R, class Proj = identity,
  211. indirectly_unary_invocable<projected<iterator_t<R>, Proj>> Fun>
  212. constexpr ranges::for_each_result<borrowed_iterator_t<R>, Fun>
  213. ranges::for_each(R&& r, Fun f, Proj proj = {}); // since C++20
  214. template<input_iterator I, class Proj = identity,
  215. indirectly_unary_invocable<projected<I, Proj>> Fun>
  216. constexpr ranges::for_each_n_result<I, Fun>
  217. ranges::for_each_n(I first, iter_difference_t<I> n, Fun f, Proj proj = {}); // since C++20
  218. template<input_iterator I, sentinel_for<I> S, class Proj = identity,
  219. indirect_unary_predicate<projected<I, Proj>> Pred>
  220. constexpr bool ranges::is_partitioned(I first, S last, Pred pred, Proj proj = {}); // since C++20
  221. template<input_range R, class Proj = identity,
  222. indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
  223. constexpr bool ranges::is_partitioned(R&& r, Pred pred, Proj proj = {}); // since C++20
  224. template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
  225. class Proj = identity>
  226. requires sortable<I, Comp, Proj>
  227. constexpr I
  228. ranges::push_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
  229. template<random_access_range R, class Comp = ranges::less, class Proj = identity>
  230. requires sortable<iterator_t<R>, Comp, Proj>
  231. constexpr borrowed_iterator_t<R>
  232. ranges::push_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
  233. template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
  234. class Proj = identity>
  235. requires sortable<I, Comp, Proj>
  236. constexpr I
  237. ranges::pop_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
  238. template<random_access_range R, class Comp = ranges::less, class Proj = identity>
  239. requires sortable<iterator_t<R>, Comp, Proj>
  240. constexpr borrowed_iterator_t<R>
  241. ranges::pop_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
  242. template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
  243. class Proj = identity>
  244. requires sortable<I, Comp, Proj>
  245. constexpr I
  246. ranges::make_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
  247. template<random_access_range R, class Comp = ranges::less, class Proj = identity>
  248. requires sortable<iterator_t<R>, Comp, Proj>
  249. constexpr borrowed_iterator_t<R>
  250. ranges::make_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
  251. template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
  252. class Proj = identity>
  253. requires sortable<I, Comp, Proj>
  254. constexpr I
  255. ranges::sort_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
  256. template<random_access_range R, class Comp = ranges::less, class Proj = identity>
  257. requires sortable<iterator_t<R>, Comp, Proj>
  258. constexpr borrowed_iterator_t<R>
  259. ranges::sort_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
  260. template<random_access_iterator I, sentinel_for<I> S, class Proj = identity,
  261. indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
  262. constexpr bool is_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
  263. template<random_access_range R, class Proj = identity,
  264. indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
  265. constexpr bool is_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
  266. template<random_access_iterator I, sentinel_for<I> S, class Proj = identity,
  267. indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
  268. constexpr I is_heap_until(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
  269. template<random_access_range R, class Proj = identity,
  270. indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
  271. constexpr borrowed_iterator_t<R>
  272. is_heap_until(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
  273. template<bidirectional_iterator I, sentinel_for<I> S>
  274. requires permutable<I>
  275. constexpr I ranges::reverse(I first, S last); // since C++20
  276. template<bidirectional_range R>
  277. requires permutable<iterator_t<R>>
  278. constexpr borrowed_iterator_t<R> ranges::reverse(R&& r); // since C++20
  279. template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
  280. class Proj = identity>
  281. requires sortable<I, Comp, Proj>
  282. constexpr I
  283. ranges::sort(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
  284. template<random_access_range R, class Comp = ranges::less, class Proj = identity>
  285. requires sortable<iterator_t<R>, Comp, Proj>
  286. constexpr borrowed_iterator_t<R>
  287. ranges::sort(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
  288. template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
  289. class Proj = identity>
  290. requires sortable<I, Comp, Proj>
  291. I ranges::stable_sort(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
  292. template<random_access_range R, class Comp = ranges::less, class Proj = identity>
  293. requires sortable<iterator_t<R>, Comp, Proj>
  294. borrowed_iterator_t<R>
  295. ranges::stable_sort(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
  296. template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
  297. class Proj = identity>
  298. requires sortable<I, Comp, Proj>
  299. constexpr I
  300. ranges::partial_sort(I first, I middle, S last, Comp comp = {}, Proj proj = {}); // since C++20
  301. template<random_access_range R, class Comp = ranges::less, class Proj = identity>
  302. requires sortable<iterator_t<R>, Comp, Proj>
  303. constexpr borrowed_iterator_t<R>
  304. ranges::partial_sort(R&& r, iterator_t<R> middle, Comp comp = {}, Proj proj = {}); // since C++20
  305. template<class T, output_iterator<const T&> O, sentinel_for<O> S>
  306. constexpr O ranges::fill(O first, S last, const T& value); // since C++20
  307. template<class T, output_range<const T&> R>
  308. constexpr borrowed_iterator_t<R> ranges::fill(R&& r, const T& value); // since C++20
  309. template<class T, output_iterator<const T&> O>
  310. constexpr O ranges::fill_n(O first, iter_difference_t<O> n, const T& value); // since C++20
  311. template<input_or_output_iterator O, sentinel_for<O> S, copy_constructible F>
  312. requires invocable<F&> && indirectly_writable<O, invoke_result_t<F&>>
  313. constexpr O generate(O first, S last, F gen); // since C++20
  314. template<class ExecutionPolicy, class ForwardIterator, class Generator>
  315. void generate(ExecutionPolicy&& exec,
  316. ForwardIterator first, ForwardIterator last,
  317. Generator gen); // since C++17
  318. template<class R, copy_constructible F>
  319. requires invocable<F&> && output_range<R, invoke_result_t<F&>>
  320. constexpr borrowed_iterator_t<R> generate(R&& r, F gen); // since C++20
  321. template<input_or_output_iterator O, copy_constructible F>
  322. requires invocable<F&> && indirectly_writable<O, invoke_result_t<F&>>
  323. constexpr O generate_n(O first, iter_difference_t<O> n, F gen); // since C++20
  324. template<class ExecutionPolicy, class ForwardIterator, class Size, class Generator>
  325. ForwardIterator generate_n(ExecutionPolicy&& exec,
  326. ForwardIterator first, Size n, Generator gen); // since C++17
  327. template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
  328. class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
  329. requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
  330. constexpr bool ranges::equal(I1 first1, S1 last1, I2 first2, S2 last2,
  331. Pred pred = {},
  332. Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  333. template<input_range R1, input_range R2, class Pred = ranges::equal_to,
  334. class Proj1 = identity, class Proj2 = identity>
  335. requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
  336. constexpr bool ranges::equal(R1&& r1, R2&& r2, Pred pred = {},
  337. Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  338. template<input_iterator I, sentinel_for<I> S, class Proj = identity,
  339. indirect_unary_predicate<projected<I, Proj>> Pred>
  340. constexpr bool ranges::all_of(I first, S last, Pred pred, Proj proj = {}); // since C++20
  341. template<input_range R, class Proj = identity,
  342. indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
  343. constexpr bool ranges::all_of(R&& r, Pred pred, Proj proj = {}); // since C++20
  344. template<input_iterator I, sentinel_for<I> S, class Proj = identity,
  345. indirect_unary_predicate<projected<I, Proj>> Pred>
  346. constexpr bool ranges::any_of(I first, S last, Pred pred, Proj proj = {}); // since C++20
  347. template<input_range R, class Proj = identity,
  348. indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
  349. constexpr bool ranges::any_of(R&& r, Pred pred, Proj proj = {}); // since C++20
  350. template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
  351. class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
  352. requires (forward_iterator<I1> || sized_sentinel_for<S1, I1>) &&
  353. (forward_iterator<I2> || sized_sentinel_for<S2, I2>) &&
  354. indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
  355. constexpr bool ranges::ends_with(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {},
  356. Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++23
  357. template<input_range R1, input_range R2, class Pred = ranges::equal_to, class Proj1 = identity,
  358. class Proj2 = identity>
  359. requires (forward_range<R1> || sized_range<R1>) &&
  360. (forward_range<R2> || sized_range<R2>) &&
  361. indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
  362. constexpr bool ranges::ends_with(R1&& r1, R2&& r2, Pred pred = {},
  363. Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++23
  364. template<input_iterator I, sentinel_for<I> S, class Proj = identity,
  365. indirect_unary_predicate<projected<I, Proj>> Pred>
  366. constexpr bool ranges::none_of(I first, S last, Pred pred, Proj proj = {}); // since C++20
  367. template<input_range R, class Proj = identity,
  368. indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
  369. constexpr bool ranges::none_of(R&& r, Pred pred, Proj proj = {}); // since C++20
  370. template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
  371. class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
  372. requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
  373. constexpr bool ranges::starts_with(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {},
  374. Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++23
  375. template<input_range R1, input_range R2, class Pred = ranges::equal_to, class Proj1 = identity,
  376. class Proj2 = identity>
  377. requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
  378. constexpr bool ranges::starts_with(R1&& r1, R2&& r2, Pred pred = {},
  379. Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++23
  380. template<input_iterator I1, sentinel_for<I1> S1,
  381. random_access_iterator I2, sentinel_for<I2> S2,
  382. class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
  383. requires indirectly_copyable<I1, I2> && sortable<I2, Comp, Proj2> &&
  384. indirect_strict_weak_order<Comp, projected<I1, Proj1>, projected<I2, Proj2>>
  385. constexpr partial_sort_copy_result<I1, I2>
  386. partial_sort_copy(I1 first, S1 last, I2 result_first, S2 result_last,
  387. Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  388. template<input_range R1, random_access_range R2, class Comp = ranges::less,
  389. class Proj1 = identity, class Proj2 = identity>
  390. requires indirectly_copyable<iterator_t<R1>, iterator_t<R2>> &&
  391. sortable<iterator_t<R2>, Comp, Proj2> &&
  392. indirect_strict_weak_order<Comp, projected<iterator_t<R1>, Proj1>,
  393. projected<iterator_t<R2>, Proj2>>
  394. constexpr partial_sort_copy_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
  395. partial_sort_copy(R1&& r, R2&& result_r, Comp comp = {},
  396. Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  397. template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
  398. indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
  399. constexpr bool ranges::is_sorted(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
  400. template<forward_range R, class Proj = identity,
  401. indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
  402. constexpr bool ranges::is_sorted(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
  403. template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
  404. indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
  405. constexpr I ranges::is_sorted_until(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
  406. template<forward_range R, class Proj = identity,
  407. indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
  408. constexpr borrowed_iterator_t<R>
  409. ranges::is_sorted_until(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
  410. template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
  411. class Proj = identity>
  412. requires sortable<I, Comp, Proj>
  413. constexpr I
  414. ranges::nth_element(I first, I nth, S last, Comp comp = {}, Proj proj = {}); // since C++20
  415. template<random_access_range R, class Comp = ranges::less, class Proj = identity>
  416. requires sortable<iterator_t<R>, Comp, Proj>
  417. constexpr borrowed_iterator_t<R>
  418. ranges::nth_element(R&& r, iterator_t<R> nth, Comp comp = {}, Proj proj = {}); // since C++20
  419. template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
  420. indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less> // since C++20
  421. constexpr I upper_bound(I first, S last, const T& value, Comp comp = {}, Proj proj = {});
  422. template<forward_range R, class T, class Proj = identity,
  423. indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
  424. ranges::less>
  425. constexpr borrowed_iterator_t<R>
  426. upper_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
  427. template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
  428. indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
  429. constexpr I lower_bound(I first, S last, const T& value, Comp comp = {},
  430. Proj proj = {}); // since C++20
  431. template<forward_range R, class T, class Proj = identity,
  432. indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
  433. ranges::less>
  434. constexpr borrowed_iterator_t<R>
  435. lower_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
  436. template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
  437. indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
  438. constexpr bool binary_search(I first, S last, const T& value, Comp comp = {},
  439. Proj proj = {}); // since C++20
  440. template<forward_range R, class T, class Proj = identity,
  441. indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
  442. ranges::less>
  443. constexpr bool binary_search(R&& r, const T& value, Comp comp = {},
  444. Proj proj = {}); // since C++20
  445. template<permutable I, sentinel_for<I> S, class Proj = identity,
  446. indirect_unary_predicate<projected<I, Proj>> Pred>
  447. constexpr subrange<I>
  448. partition(I first, S last, Pred pred, Proj proj = {}); // since C++20
  449. template<forward_range R, class Proj = identity,
  450. indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
  451. requires permutable<iterator_t<R>>
  452. constexpr borrowed_subrange_t<R>
  453. partition(R&& r, Pred pred, Proj proj = {}); // since C++20
  454. template<bidirectional_iterator I, sentinel_for<I> S, class Proj = identity,
  455. indirect_unary_predicate<projected<I, Proj>> Pred>
  456. requires permutable<I>
  457. subrange<I> stable_partition(I first, S last, Pred pred, Proj proj = {}); // since C++20
  458. template<bidirectional_range R, class Proj = identity,
  459. indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
  460. requires permutable<iterator_t<R>>
  461. borrowed_subrange_t<R> stable_partition(R&& r, Pred pred, Proj proj = {}); // since C++20
  462. template<input_iterator I1, sentinel_for<I1> S1, forward_iterator I2, sentinel_for<I2> S2,
  463. class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
  464. requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
  465. constexpr I1 ranges::find_first_of(I1 first1, S1 last1, I2 first2, S2 last2,
  466. Pred pred = {},
  467. Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  468. template<input_range R1, forward_range R2,
  469. class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
  470. requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
  471. constexpr borrowed_iterator_t<R1>
  472. ranges::find_first_of(R1&& r1, R2&& r2,
  473. Pred pred = {},
  474. Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  475. template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
  476. indirect_binary_predicate<projected<I, Proj>,
  477. projected<I, Proj>> Pred = ranges::equal_to>
  478. constexpr I ranges::adjacent_find(I first, S last, Pred pred = {}, Proj proj = {}); // since C++20
  479. template<forward_range R, class Proj = identity,
  480. indirect_binary_predicate<projected<iterator_t<R>, Proj>,
  481. projected<iterator_t<R>, Proj>> Pred = ranges::equal_to>
  482. constexpr borrowed_iterator_t<R> ranges::adjacent_find(R&& r, Pred pred = {}, Proj proj = {}); // since C++20
  483. template<input_iterator I, sentinel_for<I> S, class T1, class T2, class Proj = identity>
  484. requires indirectly_writable<I, const T2&> &&
  485. indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T1*>
  486. constexpr I
  487. ranges::replace(I first, S last, const T1& old_value, const T2& new_value, Proj proj = {}); // since C++20
  488. template<input_range R, class T1, class T2, class Proj = identity>
  489. requires indirectly_writable<iterator_t<R>, const T2&> &&
  490. indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T1*>
  491. constexpr borrowed_iterator_t<R>
  492. ranges::replace(R&& r, const T1& old_value, const T2& new_value, Proj proj = {}); // since C++20
  493. template<input_iterator I, sentinel_for<I> S, class T, class Proj = identity,
  494. indirect_unary_predicate<projected<I, Proj>> Pred>
  495. requires indirectly_writable<I, const T&>
  496. constexpr I ranges::replace_if(I first, S last, Pred pred, const T& new_value, Proj proj = {}); // since C++20
  497. template<input_range R, class T, class Proj = identity,
  498. indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
  499. requires indirectly_writable<iterator_t<R>, const T&>
  500. constexpr borrowed_iterator_t<R>
  501. ranges::replace_if(R&& r, Pred pred, const T& new_value, Proj proj = {}); // since C++20
  502. template<class T, class Proj = identity,
  503. indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
  504. constexpr const T&
  505. ranges::clamp(const T& v, const T& lo, const T& hi, Comp comp = {}, Proj proj = {}); // since C++20
  506. template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
  507. class Proj1 = identity, class Proj2 = identity,
  508. indirect_strict_weak_order<projected<I1, Proj1>,
  509. projected<I2, Proj2>> Comp = ranges::less>
  510. constexpr bool
  511. ranges::lexicographical_compare(I1 first1, S1 last1, I2 first2, S2 last2,
  512. Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  513. template<input_range R1, input_range R2, class Proj1 = identity,
  514. class Proj2 = identity,
  515. indirect_strict_weak_order<projected<iterator_t<R1>, Proj1>,
  516. projected<iterator_t<R2>, Proj2>> Comp = ranges::less>
  517. constexpr bool
  518. ranges::lexicographical_compare(R1&& r1, R2&& r2, Comp comp = {},
  519. Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  520. template<bidirectional_iterator I1, sentinel_for<I1> S1, bidirectional_iterator I2>
  521. requires indirectly_movable<I1, I2>
  522. constexpr ranges::move_backward_result<I1, I2>
  523. ranges::move_backward(I1 first, S1 last, I2 result); // since C++20
  524. template<bidirectional_range R, bidirectional_iterator I>
  525. requires indirectly_movable<iterator_t<R>, I>
  526. constexpr ranges::move_backward_result<borrowed_iterator_t<R>, I>
  527. ranges::move_backward(R&& r, I result); // since C++20
  528. template<input_iterator I, sentinel_for<I> S, weakly_incrementable O>
  529. requires indirectly_movable<I, O>
  530. constexpr ranges::move_result<I, O>
  531. ranges::move(I first, S last, O result); // since C++20
  532. template<input_range R, weakly_incrementable O>
  533. requires indirectly_movable<iterator_t<R>, O>
  534. constexpr ranges::move_result<borrowed_iterator_t<R>, O>
  535. ranges::move(R&& r, O result); // since C++20
  536. template<class I, class O1, class O2>
  537. using partition_copy_result = in_out_out_result<I, O1, O2>; // since C++20
  538. template<input_iterator I, sentinel_for<I> S,
  539. weakly_incrementable O1, weakly_incrementable O2,
  540. class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
  541. requires indirectly_copyable<I, O1> && indirectly_copyable<I, O2>
  542. constexpr partition_copy_result<I, O1, O2>
  543. partition_copy(I first, S last, O1 out_true, O2 out_false, Pred pred,
  544. Proj proj = {}); // since C++20
  545. template<input_range R, weakly_incrementable O1, weakly_incrementable O2,
  546. class Proj = identity,
  547. indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
  548. requires indirectly_copyable<iterator_t<R>, O1> &&
  549. indirectly_copyable<iterator_t<R>, O2>
  550. constexpr partition_copy_result<borrowed_iterator_t<R>, O1, O2>
  551. partition_copy(R&& r, O1 out_true, O2 out_false, Pred pred, Proj proj = {}); // since C++20
  552. template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
  553. indirect_unary_predicate<projected<I, Proj>> Pred>
  554. constexpr I partition_point(I first, S last, Pred pred, Proj proj = {}); // since C++20
  555. template<forward_range R, class Proj = identity,
  556. indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
  557. constexpr borrowed_iterator_t<R>
  558. partition_point(R&& r, Pred pred, Proj proj = {}); // since C++20
  559. template<class I1, class I2, class O>
  560. using merge_result = in_in_out_result<I1, I2, O>; // since C++20
  561. template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
  562. weakly_incrementable O, class Comp = ranges::less, class Proj1 = identity,
  563. class Proj2 = identity>
  564. requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
  565. constexpr merge_result<I1, I2, O>
  566. merge(I1 first1, S1 last1, I2 first2, S2 last2, O result,
  567. Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  568. template<input_range R1, input_range R2, weakly_incrementable O, class Comp = ranges::less,
  569. class Proj1 = identity, class Proj2 = identity>
  570. requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
  571. constexpr merge_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
  572. merge(R1&& r1, R2&& r2, O result,
  573. Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  574. template<permutable I, sentinel_for<I> S, class T, class Proj = identity>
  575. requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
  576. constexpr subrange<I> ranges::remove(I first, S last, const T& value, Proj proj = {}); // since C++20
  577. template<forward_range R, class T, class Proj = identity>
  578. requires permutable<iterator_t<R>> &&
  579. indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
  580. constexpr borrowed_subrange_t<R>
  581. ranges::remove(R&& r, const T& value, Proj proj = {}); // since C++20
  582. template<permutable I, sentinel_for<I> S, class Proj = identity,
  583. indirect_unary_predicate<projected<I, Proj>> Pred>
  584. constexpr subrange<I> ranges::remove_if(I first, S last, Pred pred, Proj proj = {}); // since C++20
  585. template<forward_range R, class Proj = identity,
  586. indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
  587. requires permutable<iterator_t<R>>
  588. constexpr borrowed_subrange_t<R>
  589. ranges::remove_if(R&& r, Pred pred, Proj proj = {}); // since C++20
  590. template<class I, class O>
  591. using set_difference_result = in_out_result<I, O>; // since C++20
  592. template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
  593. weakly_incrementable O, class Comp = ranges::less,
  594. class Proj1 = identity, class Proj2 = identity>
  595. requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
  596. constexpr set_difference_result<I1, O>
  597. set_difference(I1 first1, S1 last1, I2 first2, S2 last2, O result,
  598. Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  599. template<input_range R1, input_range R2, weakly_incrementable O,
  600. class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
  601. requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
  602. constexpr set_difference_result<borrowed_iterator_t<R1>, O>
  603. set_difference(R1&& r1, R2&& r2, O result,
  604. Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  605. template<class I1, class I2, class O>
  606. using set_intersection_result = in_in_out_result<I1, I2, O>; // since C++20
  607. template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
  608. weakly_incrementable O, class Comp = ranges::less,
  609. class Proj1 = identity, class Proj2 = identity>
  610. requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
  611. constexpr set_intersection_result<I1, I2, O>
  612. set_intersection(I1 first1, S1 last1, I2 first2, S2 last2, O result,
  613. Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  614. template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
  615. weakly_incrementable O, class Comp = ranges::less,
  616. class Proj1 = identity, class Proj2 = identity>
  617. requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
  618. constexpr set_intersection_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
  619. set_intersection(R1&& r1, R2&& r2, O result,
  620. Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  621. template <class _InIter, class _OutIter>
  622. using reverse_copy_result = in_out_result<_InIter, _OutIter>; // since C++20
  623. template<bidirectional_iterator I, sentinel_for<I> S, weakly_incrementable O>
  624. requires indirectly_copyable<I, O>
  625. constexpr ranges::reverse_copy_result<I, O>
  626. ranges::reverse_copy(I first, S last, O result); // since C++20
  627. template<bidirectional_range R, weakly_incrementable O>
  628. requires indirectly_copyable<iterator_t<R>, O>
  629. constexpr ranges::reverse_copy_result<borrowed_iterator_t<R>, O>
  630. ranges::reverse_copy(R&& r, O result); // since C++20
  631. template<permutable I, sentinel_for<I> S>
  632. constexpr subrange<I> rotate(I first, I middle, S last); // since C++20
  633. template<forward_range R>
  634. requires permutable<iterator_t<R>>
  635. constexpr borrowed_subrange_t<R> rotate(R&& r, iterator_t<R> middle); // since C++20
  636. template <class _InIter, class _OutIter>
  637. using rotate_copy_result = in_out_result<_InIter, _OutIter>; // since C++20
  638. template<forward_iterator I, sentinel_for<I> S, weakly_incrementable O>
  639. requires indirectly_copyable<I, O>
  640. constexpr ranges::rotate_copy_result<I, O>
  641. ranges::rotate_copy(I first, I middle, S last, O result); // since C++20
  642. template<forward_range R, weakly_incrementable O>
  643. requires indirectly_copyable<iterator_t<R>, O>
  644. constexpr ranges::rotate_copy_result<borrowed_iterator_t<R>, O>
  645. ranges::rotate_copy(R&& r, iterator_t<R> middle, O result); // since C++20
  646. template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Gen>
  647. requires (forward_iterator<I> || random_access_iterator<O>) &&
  648. indirectly_copyable<I, O> &&
  649. uniform_random_bit_generator<remove_reference_t<Gen>>
  650. O sample(I first, S last, O out, iter_difference_t<I> n, Gen&& g); // since C++20
  651. template<input_range R, weakly_incrementable O, class Gen>
  652. requires (forward_range<R> || random_access_iterator<O>) &&
  653. indirectly_copyable<iterator_t<R>, O> &&
  654. uniform_random_bit_generator<remove_reference_t<Gen>>
  655. O sample(R&& r, O out, range_difference_t<R> n, Gen&& g); // since C++20
  656. template<random_access_iterator I, sentinel_for<I> S, class Gen>
  657. requires permutable<I> &&
  658. uniform_random_bit_generator<remove_reference_t<Gen>>
  659. I shuffle(I first, S last, Gen&& g); // since C++20
  660. template<random_access_range R, class Gen>
  661. requires permutable<iterator_t<R>> &&
  662. uniform_random_bit_generator<remove_reference_t<Gen>>
  663. borrowed_iterator_t<R> shuffle(R&& r, Gen&& g); // since C++20
  664. template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2,
  665. sentinel_for<I2> S2, class Proj1 = identity, class Proj2 = identity,
  666. indirect_equivalence_relation<projected<I1, Proj1>,
  667. projected<I2, Proj2>> Pred = ranges::equal_to>
  668. constexpr bool ranges::is_permutation(I1 first1, S1 last1, I2 first2, S2 last2,
  669. Pred pred = {},
  670. Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  671. template<forward_range R1, forward_range R2,
  672. class Proj1 = identity, class Proj2 = identity,
  673. indirect_equivalence_relation<projected<iterator_t<R1>, Proj1>,
  674. projected<iterator_t<R2>, Proj2>> Pred = ranges::equal_to>
  675. constexpr bool ranges::is_permutation(R1&& r1, R2&& r2, Pred pred = {},
  676. Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  677. template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2,
  678. sentinel_for<I2> S2, class Pred = ranges::equal_to,
  679. class Proj1 = identity, class Proj2 = identity>
  680. requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
  681. constexpr subrange<I1>
  682. ranges::search(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {},
  683. Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  684. template<forward_range R1, forward_range R2, class Pred = ranges::equal_to,
  685. class Proj1 = identity, class Proj2 = identity>
  686. requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
  687. constexpr borrowed_subrange_t<R1>
  688. ranges::search(R1&& r1, R2&& r2, Pred pred = {},
  689. Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  690. template<forward_iterator I, sentinel_for<I> S, class T,
  691. class Pred = ranges::equal_to, class Proj = identity>
  692. requires indirectly_comparable<I, const T*, Pred, Proj>
  693. constexpr subrange<I>
  694. ranges::search_n(I first, S last, iter_difference_t<I> count,
  695. const T& value, Pred pred = {}, Proj proj = {}); // since C++20
  696. template<forward_range R, class T, class Pred = ranges::equal_to,
  697. class Proj = identity>
  698. requires indirectly_comparable<iterator_t<R>, const T*, Pred, Proj>
  699. constexpr borrowed_subrange_t<R>
  700. ranges::search_n(R&& r, range_difference_t<R> count,
  701. const T& value, Pred pred = {}, Proj proj = {}); // since C++20
  702. template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2, sentinel_for<I2> S2,
  703. class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
  704. requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
  705. constexpr subrange<I1>
  706. ranges::find_end(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {},
  707. Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  708. template<forward_range R1, forward_range R2,
  709. class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
  710. requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
  711. constexpr borrowed_subrange_t<R1>
  712. ranges::find_end(R1&& r1, R2&& r2, Pred pred = {},
  713. Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  714. template<class I1, class I2, class O>
  715. using set_symmetric_difference_result = in_in_out_result<I1, I2, O>; // since C++20
  716. template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
  717. weakly_incrementable O, class Comp = ranges::less,
  718. class Proj1 = identity, class Proj2 = identity>
  719. requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
  720. constexpr set_symmetric_difference_result<I1, I2, O>
  721. set_symmetric_difference(I1 first1, S1 last1, I2 first2, S2 last2, O result,
  722. Comp comp = {}, Proj1 proj1 = {},
  723. Proj2 proj2 = {}); // since C++20
  724. template<input_range R1, input_range R2, weakly_incrementable O,
  725. class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
  726. requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
  727. constexpr set_symmetric_difference_result<borrowed_iterator_t<R1>,
  728. borrowed_iterator_t<R2>, O>
  729. set_symmetric_difference(R1&& r1, R2&& r2, O result, Comp comp = {},
  730. Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  731. template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
  732. indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
  733. constexpr subrange<I>
  734. equal_range(I first, S last, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
  735. template<forward_range R, class T, class Proj = identity,
  736. indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp =
  737. ranges::less>
  738. constexpr borrowed_subrange_t<R>
  739. equal_range(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20
  740. template<class I1, class I2, class O>
  741. using set_union_result = in_in_out_result<I1, I2, O>; // since C++20
  742. template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
  743. weakly_incrementable O, class Comp = ranges::less,
  744. class Proj1 = identity, class Proj2 = identity>
  745. requires mergeable<I1, I2, O, Comp, Proj1, Proj2>
  746. constexpr set_union_result<I1, I2, O>
  747. set_union(I1 first1, S1 last1, I2 first2, S2 last2, O result, Comp comp = {},
  748. Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  749. template<input_range R1, input_range R2, weakly_incrementable O,
  750. class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity>
  751. requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2>
  752. constexpr set_union_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
  753. set_union(R1&& r1, R2&& r2, O result, Comp comp = {},
  754. Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  755. template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
  756. class Proj1 = identity, class Proj2 = identity,
  757. indirect_strict_weak_order<projected<I1, Proj1>, projected<I2, Proj2>> Comp =
  758. ranges::less>
  759. constexpr bool includes(I1 first1, S1 last1, I2 first2, S2 last2, Comp comp = {},
  760. Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  761. template<input_range R1, input_range R2, class Proj1 = identity,
  762. class Proj2 = identity,
  763. indirect_strict_weak_order<projected<iterator_t<R1>, Proj1>,
  764. projected<iterator_t<R2>, Proj2>> Comp = ranges::less>
  765. constexpr bool includes(R1&& r1, R2&& r2, Comp comp = {},
  766. Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  767. template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less,
  768. class Proj = identity>
  769. requires sortable<I, Comp, Proj>
  770. I inplace_merge(I first, I middle, S last, Comp comp = {}, Proj proj = {}); // since C++20
  771. template<bidirectional_range R, class Comp = ranges::less, class Proj = identity>
  772. requires sortable<iterator_t<R>, Comp, Proj>
  773. borrowed_iterator_t<R>
  774. inplace_merge(R&& r, iterator_t<R> middle, Comp comp = {},
  775. Proj proj = {}); // since C++20
  776. template<permutable I, sentinel_for<I> S, class Proj = identity,
  777. indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to>
  778. constexpr subrange<I> unique(I first, S last, C comp = {}, Proj proj = {}); // since C++20
  779. template<forward_range R, class Proj = identity,
  780. indirect_equivalence_relation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
  781. requires permutable<iterator_t<R>>
  782. constexpr borrowed_subrange_t<R>
  783. unique(R&& r, C comp = {}, Proj proj = {}); // since C++20
  784. template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Proj = identity,
  785. indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to>
  786. requires indirectly_copyable<I, O> &&
  787. (forward_iterator<I> ||
  788. (input_iterator<O> && same_as<iter_value_t<I>, iter_value_t<O>>) ||
  789. indirectly_copyable_storable<I, O>)
  790. constexpr unique_copy_result<I, O>
  791. unique_copy(I first, S last, O result, C comp = {}, Proj proj = {}); // since C++20
  792. template<input_range R, weakly_incrementable O, class Proj = identity,
  793. indirect_equivalence_relation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
  794. requires indirectly_copyable<iterator_t<R>, O> &&
  795. (forward_iterator<iterator_t<R>> ||
  796. (input_iterator<O> && same_as<range_value_t<R>, iter_value_t<O>>) ||
  797. indirectly_copyable_storable<iterator_t<R>, O>)
  798. constexpr unique_copy_result<borrowed_iterator_t<R>, O>
  799. unique_copy(R&& r, O result, C comp = {}, Proj proj = {}); // since C++20
  800. template<class I, class O>
  801. using remove_copy_result = in_out_result<I, O>; // since C++20
  802. template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class T,
  803. class Proj = identity>
  804. indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
  805. constexpr remove_copy_result<I, O>
  806. remove_copy(I first, S last, O result, const T& value, Proj proj = {}); // since C++20
  807. template<input_range R, weakly_incrementable O, class T, class Proj = identity>
  808. requires indirectly_copyable<iterator_t<R>, O> &&
  809. indirect_binary_predicate<ranges::equal_to,
  810. projected<iterator_t<R>, Proj>, const T*>
  811. constexpr remove_copy_result<borrowed_iterator_t<R>, O>
  812. remove_copy(R&& r, O result, const T& value, Proj proj = {}); // since C++20
  813. template<class I, class O>
  814. using remove_copy_if_result = in_out_result<I, O>; // since C++20
  815. template<input_iterator I, sentinel_for<I> S, weakly_incrementable O,
  816. class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
  817. requires indirectly_copyable<I, O>
  818. constexpr remove_copy_if_result<I, O>
  819. remove_copy_if(I first, S last, O result, Pred pred, Proj proj = {}); // since C++20
  820. template<input_range R, weakly_incrementable O, class Proj = identity,
  821. indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
  822. requires indirectly_copyable<iterator_t<R>, O>
  823. constexpr remove_copy_if_result<borrowed_iterator_t<R>, O>
  824. remove_copy_if(R&& r, O result, Pred pred, Proj proj = {}); // since C++20
  825. template<class I, class O>
  826. using replace_copy_result = in_out_result<I, O>; // since C++20
  827. template<input_iterator I, sentinel_for<I> S, class T1, class T2,
  828. output_iterator<const T2&> O, class Proj = identity>
  829. requires indirectly_copyable<I, O> &&
  830. indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T1*>
  831. constexpr replace_copy_result<I, O>
  832. replace_copy(I first, S last, O result, const T1& old_value, const T2& new_value,
  833. Proj proj = {}); // since C++20
  834. template<input_range R, class T1, class T2, output_iterator<const T2&> O,
  835. class Proj = identity>
  836. requires indirectly_copyable<iterator_t<R>, O> &&
  837. indirect_binary_predicate<ranges::equal_to,
  838. projected<iterator_t<R>, Proj>, const T1*>
  839. constexpr replace_copy_result<borrowed_iterator_t<R>, O>
  840. replace_copy(R&& r, O result, const T1& old_value, const T2& new_value,
  841. Proj proj = {}); // since C++20
  842. template<class I, class O>
  843. using replace_copy_if_result = in_out_result<I, O>; // since C++20
  844. template<input_iterator I, sentinel_for<I> S, class T, output_iterator<const T&> O,
  845. class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
  846. requires indirectly_copyable<I, O>
  847. constexpr replace_copy_if_result<I, O>
  848. replace_copy_if(I first, S last, O result, Pred pred, const T& new_value,
  849. Proj proj = {}); // since C++20
  850. template<input_range R, class T, output_iterator<const T&> O, class Proj = identity,
  851. indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
  852. requires indirectly_copyable<iterator_t<R>, O>
  853. constexpr replace_copy_if_result<borrowed_iterator_t<R>, O>
  854. replace_copy_if(R&& r, O result, Pred pred, const T& new_value,
  855. Proj proj = {}); // since C++20
  856. template<class I>
  857. using prev_permutation_result = in_found_result<I>; // since C++20
  858. template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less,
  859. class Proj = identity>
  860. requires sortable<I, Comp, Proj>
  861. constexpr ranges::prev_permutation_result<I>
  862. ranges::prev_permutation(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
  863. template<bidirectional_range R, class Comp = ranges::less,
  864. class Proj = identity>
  865. requires sortable<iterator_t<R>, Comp, Proj>
  866. constexpr ranges::prev_permutation_result<borrowed_iterator_t<R>>
  867. ranges::prev_permutation(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
  868. template<class I>
  869. using next_permutation_result = in_found_result<I>; // since C++20
  870. template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less,
  871. class Proj = identity>
  872. requires sortable<I, Comp, Proj>
  873. constexpr ranges::next_permutation_result<I>
  874. ranges::next_permutation(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
  875. template<bidirectional_range R, class Comp = ranges::less,
  876. class Proj = identity>
  877. requires sortable<iterator_t<R>, Comp, Proj>
  878. constexpr ranges::next_permutation_result<borrowed_iterator_t<R>>
  879. ranges::next_permutation(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
  880. }
  881. template <class InputIterator, class Predicate>
  882. constexpr bool // constexpr in C++20
  883. all_of(InputIterator first, InputIterator last, Predicate pred);
  884. template <class InputIterator, class Predicate>
  885. constexpr bool // constexpr in C++20
  886. any_of(InputIterator first, InputIterator last, Predicate pred);
  887. template <class InputIterator, class Predicate>
  888. constexpr bool // constexpr in C++20
  889. none_of(InputIterator first, InputIterator last, Predicate pred);
  890. template <class InputIterator, class Function>
  891. constexpr Function // constexpr in C++20
  892. for_each(InputIterator first, InputIterator last, Function f);
  893. template<class InputIterator, class Size, class Function>
  894. constexpr InputIterator // constexpr in C++20
  895. for_each_n(InputIterator first, Size n, Function f); // C++17
  896. template <class InputIterator, class T>
  897. constexpr InputIterator // constexpr in C++20
  898. find(InputIterator first, InputIterator last, const T& value);
  899. template <class InputIterator, class Predicate>
  900. constexpr InputIterator // constexpr in C++20
  901. find_if(InputIterator first, InputIterator last, Predicate pred);
  902. template<class InputIterator, class Predicate>
  903. constexpr InputIterator // constexpr in C++20
  904. find_if_not(InputIterator first, InputIterator last, Predicate pred);
  905. template <class ForwardIterator1, class ForwardIterator2>
  906. constexpr ForwardIterator1 // constexpr in C++20
  907. find_end(ForwardIterator1 first1, ForwardIterator1 last1,
  908. ForwardIterator2 first2, ForwardIterator2 last2);
  909. template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
  910. constexpr ForwardIterator1 // constexpr in C++20
  911. find_end(ForwardIterator1 first1, ForwardIterator1 last1,
  912. ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
  913. template <class ForwardIterator1, class ForwardIterator2>
  914. constexpr ForwardIterator1 // constexpr in C++20
  915. find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
  916. ForwardIterator2 first2, ForwardIterator2 last2);
  917. template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
  918. constexpr ForwardIterator1 // constexpr in C++20
  919. find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
  920. ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
  921. template <class ForwardIterator>
  922. constexpr ForwardIterator // constexpr in C++20
  923. adjacent_find(ForwardIterator first, ForwardIterator last);
  924. template <class ForwardIterator, class BinaryPredicate>
  925. constexpr ForwardIterator // constexpr in C++20
  926. adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
  927. template <class InputIterator, class T>
  928. constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
  929. count(InputIterator first, InputIterator last, const T& value);
  930. template <class InputIterator, class Predicate>
  931. constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
  932. count_if(InputIterator first, InputIterator last, Predicate pred);
  933. template <class InputIterator1, class InputIterator2>
  934. constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
  935. mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
  936. template <class InputIterator1, class InputIterator2>
  937. constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
  938. mismatch(InputIterator1 first1, InputIterator1 last1,
  939. InputIterator2 first2, InputIterator2 last2); // **C++14**
  940. template <class InputIterator1, class InputIterator2, class BinaryPredicate>
  941. constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
  942. mismatch(InputIterator1 first1, InputIterator1 last1,
  943. InputIterator2 first2, BinaryPredicate pred);
  944. template <class InputIterator1, class InputIterator2, class BinaryPredicate>
  945. constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
  946. mismatch(InputIterator1 first1, InputIterator1 last1,
  947. InputIterator2 first2, InputIterator2 last2,
  948. BinaryPredicate pred); // **C++14**
  949. template <class InputIterator1, class InputIterator2>
  950. constexpr bool // constexpr in C++20
  951. equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
  952. template <class InputIterator1, class InputIterator2>
  953. constexpr bool // constexpr in C++20
  954. equal(InputIterator1 first1, InputIterator1 last1,
  955. InputIterator2 first2, InputIterator2 last2); // **C++14**
  956. template <class InputIterator1, class InputIterator2, class BinaryPredicate>
  957. constexpr bool // constexpr in C++20
  958. equal(InputIterator1 first1, InputIterator1 last1,
  959. InputIterator2 first2, BinaryPredicate pred);
  960. template <class InputIterator1, class InputIterator2, class BinaryPredicate>
  961. constexpr bool // constexpr in C++20
  962. equal(InputIterator1 first1, InputIterator1 last1,
  963. InputIterator2 first2, InputIterator2 last2,
  964. BinaryPredicate pred); // **C++14**
  965. template<class ForwardIterator1, class ForwardIterator2>
  966. constexpr bool // constexpr in C++20
  967. is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
  968. ForwardIterator2 first2);
  969. template<class ForwardIterator1, class ForwardIterator2>
  970. constexpr bool // constexpr in C++20
  971. is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
  972. ForwardIterator2 first2, ForwardIterator2 last2); // **C++14**
  973. template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
  974. constexpr bool // constexpr in C++20
  975. is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
  976. ForwardIterator2 first2, BinaryPredicate pred);
  977. template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
  978. constexpr bool // constexpr in C++20
  979. is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
  980. ForwardIterator2 first2, ForwardIterator2 last2,
  981. BinaryPredicate pred); // **C++14**
  982. template <class ForwardIterator1, class ForwardIterator2>
  983. constexpr ForwardIterator1 // constexpr in C++20
  984. search(ForwardIterator1 first1, ForwardIterator1 last1,
  985. ForwardIterator2 first2, ForwardIterator2 last2);
  986. template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
  987. constexpr ForwardIterator1 // constexpr in C++20
  988. search(ForwardIterator1 first1, ForwardIterator1 last1,
  989. ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
  990. template <class ForwardIterator, class Size, class T>
  991. constexpr ForwardIterator // constexpr in C++20
  992. search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value);
  993. template <class ForwardIterator, class Size, class T, class BinaryPredicate>
  994. constexpr ForwardIterator // constexpr in C++20
  995. search_n(ForwardIterator first, ForwardIterator last,
  996. Size count, const T& value, BinaryPredicate pred);
  997. template <class InputIterator, class OutputIterator>
  998. constexpr OutputIterator // constexpr in C++20
  999. copy(InputIterator first, InputIterator last, OutputIterator result);
  1000. template<class InputIterator, class OutputIterator, class Predicate>
  1001. constexpr OutputIterator // constexpr in C++20
  1002. copy_if(InputIterator first, InputIterator last,
  1003. OutputIterator result, Predicate pred);
  1004. template<class InputIterator, class Size, class OutputIterator>
  1005. constexpr OutputIterator // constexpr in C++20
  1006. copy_n(InputIterator first, Size n, OutputIterator result);
  1007. template <class BidirectionalIterator1, class BidirectionalIterator2>
  1008. constexpr BidirectionalIterator2 // constexpr in C++20
  1009. copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
  1010. BidirectionalIterator2 result);
  1011. // [alg.move], move
  1012. template<class InputIterator, class OutputIterator>
  1013. constexpr OutputIterator move(InputIterator first, InputIterator last,
  1014. OutputIterator result);
  1015. template<class BidirectionalIterator1, class BidirectionalIterator2>
  1016. constexpr BidirectionalIterator2
  1017. move_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
  1018. BidirectionalIterator2 result);
  1019. template <class ForwardIterator1, class ForwardIterator2>
  1020. constexpr ForwardIterator2 // constexpr in C++20
  1021. swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
  1022. namespace ranges {
  1023. template<class I1, class I2>
  1024. using swap_ranges_result = in_in_result<I1, I2>;
  1025. template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2>
  1026. requires indirectly_swappable<I1, I2>
  1027. constexpr ranges::swap_ranges_result<I1, I2>
  1028. swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2);
  1029. template<input_range R1, input_range R2>
  1030. requires indirectly_swappable<iterator_t<R1>, iterator_t<R2>>
  1031. constexpr ranges::swap_ranges_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
  1032. swap_ranges(R1&& r1, R2&& r2);
  1033. }
  1034. template <class ForwardIterator1, class ForwardIterator2>
  1035. constexpr void // constexpr in C++20
  1036. iter_swap(ForwardIterator1 a, ForwardIterator2 b);
  1037. template <class InputIterator, class OutputIterator, class UnaryOperation>
  1038. constexpr OutputIterator // constexpr in C++20
  1039. transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op);
  1040. template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
  1041. constexpr OutputIterator // constexpr in C++20
  1042. transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
  1043. OutputIterator result, BinaryOperation binary_op);
  1044. template <class ForwardIterator, class T>
  1045. constexpr void // constexpr in C++20
  1046. replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);
  1047. template <class ForwardIterator, class Predicate, class T>
  1048. constexpr void // constexpr in C++20
  1049. replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value);
  1050. template <class InputIterator, class OutputIterator, class T>
  1051. constexpr OutputIterator // constexpr in C++20
  1052. replace_copy(InputIterator first, InputIterator last, OutputIterator result,
  1053. const T& old_value, const T& new_value);
  1054. template <class InputIterator, class OutputIterator, class Predicate, class T>
  1055. constexpr OutputIterator // constexpr in C++20
  1056. replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value);
  1057. template <class ForwardIterator, class T>
  1058. constexpr void // constexpr in C++20
  1059. fill(ForwardIterator first, ForwardIterator last, const T& value);
  1060. template <class OutputIterator, class Size, class T>
  1061. constexpr OutputIterator // constexpr in C++20
  1062. fill_n(OutputIterator first, Size n, const T& value);
  1063. template <class ForwardIterator, class Generator>
  1064. constexpr void // constexpr in C++20
  1065. generate(ForwardIterator first, ForwardIterator last, Generator gen);
  1066. template <class OutputIterator, class Size, class Generator>
  1067. constexpr OutputIterator // constexpr in C++20
  1068. generate_n(OutputIterator first, Size n, Generator gen);
  1069. template <class ForwardIterator, class T>
  1070. constexpr ForwardIterator // constexpr in C++20
  1071. remove(ForwardIterator first, ForwardIterator last, const T& value);
  1072. template <class ForwardIterator, class Predicate>
  1073. constexpr ForwardIterator // constexpr in C++20
  1074. remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);
  1075. template <class InputIterator, class OutputIterator, class T>
  1076. constexpr OutputIterator // constexpr in C++20
  1077. remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);
  1078. template <class InputIterator, class OutputIterator, class Predicate>
  1079. constexpr OutputIterator // constexpr in C++20
  1080. remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
  1081. template <class ForwardIterator>
  1082. constexpr ForwardIterator // constexpr in C++20
  1083. unique(ForwardIterator first, ForwardIterator last);
  1084. template <class ForwardIterator, class BinaryPredicate>
  1085. constexpr ForwardIterator // constexpr in C++20
  1086. unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
  1087. template <class InputIterator, class OutputIterator>
  1088. constexpr OutputIterator // constexpr in C++20
  1089. unique_copy(InputIterator first, InputIterator last, OutputIterator result);
  1090. template <class InputIterator, class OutputIterator, class BinaryPredicate>
  1091. constexpr OutputIterator // constexpr in C++20
  1092. unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);
  1093. template <class BidirectionalIterator>
  1094. constexpr void // constexpr in C++20
  1095. reverse(BidirectionalIterator first, BidirectionalIterator last);
  1096. template <class BidirectionalIterator, class OutputIterator>
  1097. constexpr OutputIterator // constexpr in C++20
  1098. reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
  1099. template <class ForwardIterator>
  1100. constexpr ForwardIterator // constexpr in C++20
  1101. rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
  1102. template <class ForwardIterator, class OutputIterator>
  1103. constexpr OutputIterator // constexpr in C++20
  1104. rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);
  1105. template <class RandomAccessIterator>
  1106. void
  1107. random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17
  1108. template <class RandomAccessIterator, class RandomNumberGenerator>
  1109. void
  1110. random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
  1111. RandomNumberGenerator& rand); // deprecated in C++14, removed in C++17
  1112. template<class PopulationIterator, class SampleIterator,
  1113. class Distance, class UniformRandomBitGenerator>
  1114. SampleIterator sample(PopulationIterator first, PopulationIterator last,
  1115. SampleIterator out, Distance n,
  1116. UniformRandomBitGenerator&& g); // C++17
  1117. template<class RandomAccessIterator, class UniformRandomNumberGenerator>
  1118. void shuffle(RandomAccessIterator first, RandomAccessIterator last,
  1119. UniformRandomNumberGenerator&& g);
  1120. template<class ForwardIterator>
  1121. constexpr ForwardIterator
  1122. shift_left(ForwardIterator first, ForwardIterator last,
  1123. typename iterator_traits<ForwardIterator>::difference_type n); // C++20
  1124. template<class ForwardIterator>
  1125. constexpr ForwardIterator
  1126. shift_right(ForwardIterator first, ForwardIterator last,
  1127. typename iterator_traits<ForwardIterator>::difference_type n); // C++20
  1128. template <class InputIterator, class Predicate>
  1129. constexpr bool // constexpr in C++20
  1130. is_partitioned(InputIterator first, InputIterator last, Predicate pred);
  1131. template <class ForwardIterator, class Predicate>
  1132. constexpr ForwardIterator // constexpr in C++20
  1133. partition(ForwardIterator first, ForwardIterator last, Predicate pred);
  1134. template <class InputIterator, class OutputIterator1,
  1135. class OutputIterator2, class Predicate>
  1136. constexpr pair<OutputIterator1, OutputIterator2> // constexpr in C++20
  1137. partition_copy(InputIterator first, InputIterator last,
  1138. OutputIterator1 out_true, OutputIterator2 out_false,
  1139. Predicate pred);
  1140. template <class ForwardIterator, class Predicate>
  1141. ForwardIterator
  1142. stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
  1143. template<class ForwardIterator, class Predicate>
  1144. constexpr ForwardIterator // constexpr in C++20
  1145. partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
  1146. template <class ForwardIterator>
  1147. constexpr bool // constexpr in C++20
  1148. is_sorted(ForwardIterator first, ForwardIterator last);
  1149. template <class ForwardIterator, class Compare>
  1150. constexpr bool // constexpr in C++20
  1151. is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
  1152. template<class ForwardIterator>
  1153. constexpr ForwardIterator // constexpr in C++20
  1154. is_sorted_until(ForwardIterator first, ForwardIterator last);
  1155. template <class ForwardIterator, class Compare>
  1156. constexpr ForwardIterator // constexpr in C++20
  1157. is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
  1158. template <class RandomAccessIterator>
  1159. constexpr void // constexpr in C++20
  1160. sort(RandomAccessIterator first, RandomAccessIterator last);
  1161. template <class RandomAccessIterator, class Compare>
  1162. constexpr void // constexpr in C++20
  1163. sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
  1164. template <class RandomAccessIterator>
  1165. void
  1166. stable_sort(RandomAccessIterator first, RandomAccessIterator last);
  1167. template <class RandomAccessIterator, class Compare>
  1168. void
  1169. stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
  1170. template <class RandomAccessIterator>
  1171. constexpr void // constexpr in C++20
  1172. partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);
  1173. template <class RandomAccessIterator, class Compare>
  1174. constexpr void // constexpr in C++20
  1175. partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp);
  1176. template <class InputIterator, class RandomAccessIterator>
  1177. constexpr RandomAccessIterator // constexpr in C++20
  1178. partial_sort_copy(InputIterator first, InputIterator last,
  1179. RandomAccessIterator result_first, RandomAccessIterator result_last);
  1180. template <class InputIterator, class RandomAccessIterator, class Compare>
  1181. constexpr RandomAccessIterator // constexpr in C++20
  1182. partial_sort_copy(InputIterator first, InputIterator last,
  1183. RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp);
  1184. template <class RandomAccessIterator>
  1185. constexpr void // constexpr in C++20
  1186. nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);
  1187. template <class RandomAccessIterator, class Compare>
  1188. constexpr void // constexpr in C++20
  1189. nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);
  1190. template <class ForwardIterator, class T>
  1191. constexpr ForwardIterator // constexpr in C++20
  1192. lower_bound(ForwardIterator first, ForwardIterator last, const T& value);
  1193. template <class ForwardIterator, class T, class Compare>
  1194. constexpr ForwardIterator // constexpr in C++20
  1195. lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
  1196. template <class ForwardIterator, class T>
  1197. constexpr ForwardIterator // constexpr in C++20
  1198. upper_bound(ForwardIterator first, ForwardIterator last, const T& value);
  1199. template <class ForwardIterator, class T, class Compare>
  1200. constexpr ForwardIterator // constexpr in C++20
  1201. upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
  1202. template <class ForwardIterator, class T>
  1203. constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
  1204. equal_range(ForwardIterator first, ForwardIterator last, const T& value);
  1205. template <class ForwardIterator, class T, class Compare>
  1206. constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
  1207. equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
  1208. template <class ForwardIterator, class T>
  1209. constexpr bool // constexpr in C++20
  1210. binary_search(ForwardIterator first, ForwardIterator last, const T& value);
  1211. template <class ForwardIterator, class T, class Compare>
  1212. constexpr bool // constexpr in C++20
  1213. binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
  1214. template <class InputIterator1, class InputIterator2, class OutputIterator>
  1215. constexpr OutputIterator // constexpr in C++20
  1216. merge(InputIterator1 first1, InputIterator1 last1,
  1217. InputIterator2 first2, InputIterator2 last2, OutputIterator result);
  1218. template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
  1219. constexpr OutputIterator // constexpr in C++20
  1220. merge(InputIterator1 first1, InputIterator1 last1,
  1221. InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
  1222. template <class BidirectionalIterator>
  1223. void
  1224. inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last);
  1225. template <class BidirectionalIterator, class Compare>
  1226. void
  1227. inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);
  1228. template <class InputIterator1, class InputIterator2>
  1229. constexpr bool // constexpr in C++20
  1230. includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
  1231. template <class InputIterator1, class InputIterator2, class Compare>
  1232. constexpr bool // constexpr in C++20
  1233. includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
  1234. template <class InputIterator1, class InputIterator2, class OutputIterator>
  1235. constexpr OutputIterator // constexpr in C++20
  1236. set_union(InputIterator1 first1, InputIterator1 last1,
  1237. InputIterator2 first2, InputIterator2 last2, OutputIterator result);
  1238. template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
  1239. constexpr OutputIterator // constexpr in C++20
  1240. set_union(InputIterator1 first1, InputIterator1 last1,
  1241. InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
  1242. template <class InputIterator1, class InputIterator2, class OutputIterator>
  1243. constexpr OutputIterator // constexpr in C++20
  1244. set_intersection(InputIterator1 first1, InputIterator1 last1,
  1245. InputIterator2 first2, InputIterator2 last2, OutputIterator result);
  1246. template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
  1247. constexpr OutputIterator // constexpr in C++20
  1248. set_intersection(InputIterator1 first1, InputIterator1 last1,
  1249. InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
  1250. template <class InputIterator1, class InputIterator2, class OutputIterator>
  1251. constexpr OutputIterator // constexpr in C++20
  1252. set_difference(InputIterator1 first1, InputIterator1 last1,
  1253. InputIterator2 first2, InputIterator2 last2, OutputIterator result);
  1254. template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
  1255. constexpr OutputIterator // constexpr in C++20
  1256. set_difference(InputIterator1 first1, InputIterator1 last1,
  1257. InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
  1258. template <class InputIterator1, class InputIterator2, class OutputIterator>
  1259. constexpr OutputIterator // constexpr in C++20
  1260. set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
  1261. InputIterator2 first2, InputIterator2 last2, OutputIterator result);
  1262. template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
  1263. constexpr OutputIterator // constexpr in C++20
  1264. set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
  1265. InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
  1266. template <class RandomAccessIterator>
  1267. constexpr void // constexpr in C++20
  1268. push_heap(RandomAccessIterator first, RandomAccessIterator last);
  1269. template <class RandomAccessIterator, class Compare>
  1270. constexpr void // constexpr in C++20
  1271. push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
  1272. template <class RandomAccessIterator>
  1273. constexpr void // constexpr in C++20
  1274. pop_heap(RandomAccessIterator first, RandomAccessIterator last);
  1275. template <class RandomAccessIterator, class Compare>
  1276. constexpr void // constexpr in C++20
  1277. pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
  1278. template <class RandomAccessIterator>
  1279. constexpr void // constexpr in C++20
  1280. make_heap(RandomAccessIterator first, RandomAccessIterator last);
  1281. template <class RandomAccessIterator, class Compare>
  1282. constexpr void // constexpr in C++20
  1283. make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
  1284. template <class RandomAccessIterator>
  1285. constexpr void // constexpr in C++20
  1286. sort_heap(RandomAccessIterator first, RandomAccessIterator last);
  1287. template <class RandomAccessIterator, class Compare>
  1288. constexpr void // constexpr in C++20
  1289. sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
  1290. template <class RandomAccessIterator>
  1291. constexpr bool // constexpr in C++20
  1292. is_heap(RandomAccessIterator first, RandomAccessiterator last);
  1293. template <class RandomAccessIterator, class Compare>
  1294. constexpr bool // constexpr in C++20
  1295. is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
  1296. template <class RandomAccessIterator>
  1297. constexpr RandomAccessIterator // constexpr in C++20
  1298. is_heap_until(RandomAccessIterator first, RandomAccessiterator last);
  1299. template <class RandomAccessIterator, class Compare>
  1300. constexpr RandomAccessIterator // constexpr in C++20
  1301. is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
  1302. template <class ForwardIterator>
  1303. constexpr ForwardIterator // constexpr in C++14
  1304. min_element(ForwardIterator first, ForwardIterator last);
  1305. template <class ForwardIterator, class Compare>
  1306. constexpr ForwardIterator // constexpr in C++14
  1307. min_element(ForwardIterator first, ForwardIterator last, Compare comp);
  1308. template <class T>
  1309. constexpr const T& // constexpr in C++14
  1310. min(const T& a, const T& b);
  1311. template <class T, class Compare>
  1312. constexpr const T& // constexpr in C++14
  1313. min(const T& a, const T& b, Compare comp);
  1314. template<class T>
  1315. constexpr T // constexpr in C++14
  1316. min(initializer_list<T> t);
  1317. template<class T, class Compare>
  1318. constexpr T // constexpr in C++14
  1319. min(initializer_list<T> t, Compare comp);
  1320. template<class T>
  1321. constexpr const T& clamp(const T& v, const T& lo, const T& hi); // C++17
  1322. template<class T, class Compare>
  1323. constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17
  1324. template <class ForwardIterator>
  1325. constexpr ForwardIterator // constexpr in C++14
  1326. max_element(ForwardIterator first, ForwardIterator last);
  1327. template <class ForwardIterator, class Compare>
  1328. constexpr ForwardIterator // constexpr in C++14
  1329. max_element(ForwardIterator first, ForwardIterator last, Compare comp);
  1330. template <class T>
  1331. constexpr const T& // constexpr in C++14
  1332. max(const T& a, const T& b);
  1333. template <class T, class Compare>
  1334. constexpr const T& // constexpr in C++14
  1335. max(const T& a, const T& b, Compare comp);
  1336. template<class T>
  1337. constexpr T // constexpr in C++14
  1338. max(initializer_list<T> t);
  1339. template<class T, class Compare>
  1340. constexpr T // constexpr in C++14
  1341. max(initializer_list<T> t, Compare comp);
  1342. template<class ForwardIterator>
  1343. constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
  1344. minmax_element(ForwardIterator first, ForwardIterator last);
  1345. template<class ForwardIterator, class Compare>
  1346. constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
  1347. minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
  1348. template<class T>
  1349. constexpr pair<const T&, const T&> // constexpr in C++14
  1350. minmax(const T& a, const T& b);
  1351. template<class T, class Compare>
  1352. constexpr pair<const T&, const T&> // constexpr in C++14
  1353. minmax(const T& a, const T& b, Compare comp);
  1354. template<class T>
  1355. constexpr pair<T, T> // constexpr in C++14
  1356. minmax(initializer_list<T> t);
  1357. template<class T, class Compare>
  1358. constexpr pair<T, T> // constexpr in C++14
  1359. minmax(initializer_list<T> t, Compare comp);
  1360. template <class InputIterator1, class InputIterator2>
  1361. constexpr bool // constexpr in C++20
  1362. lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
  1363. template <class InputIterator1, class InputIterator2, class Compare>
  1364. constexpr bool // constexpr in C++20
  1365. lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
  1366. InputIterator2 first2, InputIterator2 last2, Compare comp);
  1367. template<class InputIterator1, class InputIterator2, class Cmp>
  1368. constexpr auto
  1369. lexicographical_compare_three_way(InputIterator1 first1, InputIterator1 last1,
  1370. InputIterator2 first2, InputIterator2 last2,
  1371. Cmp comp)
  1372. -> decltype(comp(*b1, *b2)); // since C++20
  1373. template<class InputIterator1, class InputIterator2>
  1374. constexpr auto
  1375. lexicographical_compare_three_way(InputIterator1 first1, InputIterator1 last1,
  1376. InputIterator2 first2, InputIterator2 last2); // since C++20
  1377. template <class BidirectionalIterator>
  1378. constexpr bool // constexpr in C++20
  1379. next_permutation(BidirectionalIterator first, BidirectionalIterator last);
  1380. template <class BidirectionalIterator, class Compare>
  1381. constexpr bool // constexpr in C++20
  1382. next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
  1383. template <class BidirectionalIterator>
  1384. constexpr bool // constexpr in C++20
  1385. prev_permutation(BidirectionalIterator first, BidirectionalIterator last);
  1386. template <class BidirectionalIterator, class Compare>
  1387. constexpr bool // constexpr in C++20
  1388. prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
  1389. } // std
  1390. */
  1391. #include <__assert> // all public C++ headers provide the assertion handler
  1392. #include <__config>
  1393. #include <cstddef>
  1394. #include <version>
  1395. #include <__algorithm/adjacent_find.h>
  1396. #include <__algorithm/all_of.h>
  1397. #include <__algorithm/any_of.h>
  1398. #include <__algorithm/binary_search.h>
  1399. #include <__algorithm/clamp.h>
  1400. #include <__algorithm/comp.h>
  1401. #include <__algorithm/comp_ref_type.h>
  1402. #include <__algorithm/copy.h>
  1403. #include <__algorithm/copy_backward.h>
  1404. #include <__algorithm/copy_if.h>
  1405. #include <__algorithm/copy_n.h>
  1406. #include <__algorithm/count.h>
  1407. #include <__algorithm/count_if.h>
  1408. #include <__algorithm/equal.h>
  1409. #include <__algorithm/equal_range.h>
  1410. #include <__algorithm/fill.h>
  1411. #include <__algorithm/fill_n.h>
  1412. #include <__algorithm/find.h>
  1413. #include <__algorithm/find_end.h>
  1414. #include <__algorithm/find_first_of.h>
  1415. #include <__algorithm/find_if.h>
  1416. #include <__algorithm/find_if_not.h>
  1417. #include <__algorithm/for_each.h>
  1418. #include <__algorithm/for_each_n.h>
  1419. #include <__algorithm/generate.h>
  1420. #include <__algorithm/generate_n.h>
  1421. #include <__algorithm/half_positive.h>
  1422. #include <__algorithm/in_found_result.h>
  1423. #include <__algorithm/in_fun_result.h>
  1424. #include <__algorithm/in_in_out_result.h>
  1425. #include <__algorithm/in_in_result.h>
  1426. #include <__algorithm/in_out_out_result.h>
  1427. #include <__algorithm/in_out_result.h>
  1428. #include <__algorithm/includes.h>
  1429. #include <__algorithm/inplace_merge.h>
  1430. #include <__algorithm/is_heap.h>
  1431. #include <__algorithm/is_heap_until.h>
  1432. #include <__algorithm/is_partitioned.h>
  1433. #include <__algorithm/is_permutation.h>
  1434. #include <__algorithm/is_sorted.h>
  1435. #include <__algorithm/is_sorted_until.h>
  1436. #include <__algorithm/iter_swap.h>
  1437. #include <__algorithm/lexicographical_compare.h>
  1438. #include <__algorithm/lexicographical_compare_three_way.h>
  1439. #include <__algorithm/lower_bound.h>
  1440. #include <__algorithm/make_heap.h>
  1441. #include <__algorithm/max.h>
  1442. #include <__algorithm/max_element.h>
  1443. #include <__algorithm/merge.h>
  1444. #include <__algorithm/min.h>
  1445. #include <__algorithm/min_element.h>
  1446. #include <__algorithm/min_max_result.h>
  1447. #include <__algorithm/minmax.h>
  1448. #include <__algorithm/minmax_element.h>
  1449. #include <__algorithm/mismatch.h>
  1450. #include <__algorithm/move.h>
  1451. #include <__algorithm/move_backward.h>
  1452. #include <__algorithm/next_permutation.h>
  1453. #include <__algorithm/none_of.h>
  1454. #include <__algorithm/nth_element.h>
  1455. #include <__algorithm/partial_sort.h>
  1456. #include <__algorithm/partial_sort_copy.h>
  1457. #include <__algorithm/partition.h>
  1458. #include <__algorithm/partition_copy.h>
  1459. #include <__algorithm/partition_point.h>
  1460. #include <__algorithm/pop_heap.h>
  1461. #include <__algorithm/prev_permutation.h>
  1462. #include <__algorithm/pstl_any_all_none_of.h>
  1463. #include <__algorithm/pstl_copy.h>
  1464. #include <__algorithm/pstl_count.h>
  1465. #include <__algorithm/pstl_fill.h>
  1466. #include <__algorithm/pstl_find.h>
  1467. #include <__algorithm/pstl_for_each.h>
  1468. #include <__algorithm/pstl_generate.h>
  1469. #include <__algorithm/pstl_is_partitioned.h>
  1470. #include <__algorithm/pstl_merge.h>
  1471. #include <__algorithm/pstl_replace.h>
  1472. #include <__algorithm/pstl_sort.h>
  1473. #include <__algorithm/pstl_stable_sort.h>
  1474. #include <__algorithm/pstl_transform.h>
  1475. #include <__algorithm/push_heap.h>
  1476. #include <__algorithm/ranges_adjacent_find.h>
  1477. #include <__algorithm/ranges_all_of.h>
  1478. #include <__algorithm/ranges_any_of.h>
  1479. #include <__algorithm/ranges_binary_search.h>
  1480. #include <__algorithm/ranges_clamp.h>
  1481. #include <__algorithm/ranges_copy.h>
  1482. #include <__algorithm/ranges_copy_backward.h>
  1483. #include <__algorithm/ranges_copy_if.h>
  1484. #include <__algorithm/ranges_copy_n.h>
  1485. #include <__algorithm/ranges_count.h>
  1486. #include <__algorithm/ranges_count_if.h>
  1487. #include <__algorithm/ranges_ends_with.h>
  1488. #include <__algorithm/ranges_equal.h>
  1489. #include <__algorithm/ranges_equal_range.h>
  1490. #include <__algorithm/ranges_fill.h>
  1491. #include <__algorithm/ranges_fill_n.h>
  1492. #include <__algorithm/ranges_find.h>
  1493. #include <__algorithm/ranges_find_end.h>
  1494. #include <__algorithm/ranges_find_first_of.h>
  1495. #include <__algorithm/ranges_find_if.h>
  1496. #include <__algorithm/ranges_find_if_not.h>
  1497. #include <__algorithm/ranges_for_each.h>
  1498. #include <__algorithm/ranges_for_each_n.h>
  1499. #include <__algorithm/ranges_generate.h>
  1500. #include <__algorithm/ranges_generate_n.h>
  1501. #include <__algorithm/ranges_includes.h>
  1502. #include <__algorithm/ranges_inplace_merge.h>
  1503. #include <__algorithm/ranges_is_heap.h>
  1504. #include <__algorithm/ranges_is_heap_until.h>
  1505. #include <__algorithm/ranges_is_partitioned.h>
  1506. #include <__algorithm/ranges_is_permutation.h>
  1507. #include <__algorithm/ranges_is_sorted.h>
  1508. #include <__algorithm/ranges_is_sorted_until.h>
  1509. #include <__algorithm/ranges_lexicographical_compare.h>
  1510. #include <__algorithm/ranges_lower_bound.h>
  1511. #include <__algorithm/ranges_make_heap.h>
  1512. #include <__algorithm/ranges_max.h>
  1513. #include <__algorithm/ranges_max_element.h>
  1514. #include <__algorithm/ranges_merge.h>
  1515. #include <__algorithm/ranges_min.h>
  1516. #include <__algorithm/ranges_min_element.h>
  1517. #include <__algorithm/ranges_minmax.h>
  1518. #include <__algorithm/ranges_minmax_element.h>
  1519. #include <__algorithm/ranges_mismatch.h>
  1520. #include <__algorithm/ranges_move.h>
  1521. #include <__algorithm/ranges_move_backward.h>
  1522. #include <__algorithm/ranges_next_permutation.h>
  1523. #include <__algorithm/ranges_none_of.h>
  1524. #include <__algorithm/ranges_nth_element.h>
  1525. #include <__algorithm/ranges_partial_sort.h>
  1526. #include <__algorithm/ranges_partial_sort_copy.h>
  1527. #include <__algorithm/ranges_partition.h>
  1528. #include <__algorithm/ranges_partition_copy.h>
  1529. #include <__algorithm/ranges_partition_point.h>
  1530. #include <__algorithm/ranges_pop_heap.h>
  1531. #include <__algorithm/ranges_prev_permutation.h>
  1532. #include <__algorithm/ranges_push_heap.h>
  1533. #include <__algorithm/ranges_remove.h>
  1534. #include <__algorithm/ranges_remove_copy.h>
  1535. #include <__algorithm/ranges_remove_copy_if.h>
  1536. #include <__algorithm/ranges_remove_if.h>
  1537. #include <__algorithm/ranges_replace.h>
  1538. #include <__algorithm/ranges_replace_copy.h>
  1539. #include <__algorithm/ranges_replace_copy_if.h>
  1540. #include <__algorithm/ranges_replace_if.h>
  1541. #include <__algorithm/ranges_reverse.h>
  1542. #include <__algorithm/ranges_reverse_copy.h>
  1543. #include <__algorithm/ranges_rotate.h>
  1544. #include <__algorithm/ranges_rotate_copy.h>
  1545. #include <__algorithm/ranges_sample.h>
  1546. #include <__algorithm/ranges_search.h>
  1547. #include <__algorithm/ranges_search_n.h>
  1548. #include <__algorithm/ranges_set_difference.h>
  1549. #include <__algorithm/ranges_set_intersection.h>
  1550. #include <__algorithm/ranges_set_symmetric_difference.h>
  1551. #include <__algorithm/ranges_set_union.h>
  1552. #include <__algorithm/ranges_shuffle.h>
  1553. #include <__algorithm/ranges_sort.h>
  1554. #include <__algorithm/ranges_sort_heap.h>
  1555. #include <__algorithm/ranges_stable_partition.h>
  1556. #include <__algorithm/ranges_stable_sort.h>
  1557. #include <__algorithm/ranges_starts_with.h>
  1558. #include <__algorithm/ranges_swap_ranges.h>
  1559. #include <__algorithm/ranges_transform.h>
  1560. #include <__algorithm/ranges_unique.h>
  1561. #include <__algorithm/ranges_unique_copy.h>
  1562. #include <__algorithm/ranges_upper_bound.h>
  1563. #include <__algorithm/remove.h>
  1564. #include <__algorithm/remove_copy.h>
  1565. #include <__algorithm/remove_copy_if.h>
  1566. #include <__algorithm/remove_if.h>
  1567. #include <__algorithm/replace.h>
  1568. #include <__algorithm/replace_copy.h>
  1569. #include <__algorithm/replace_copy_if.h>
  1570. #include <__algorithm/replace_if.h>
  1571. #include <__algorithm/reverse.h>
  1572. #include <__algorithm/reverse_copy.h>
  1573. #include <__algorithm/rotate.h>
  1574. #include <__algorithm/rotate_copy.h>
  1575. #include <__algorithm/sample.h>
  1576. #include <__algorithm/search.h>
  1577. #include <__algorithm/search_n.h>
  1578. #include <__algorithm/set_difference.h>
  1579. #include <__algorithm/set_intersection.h>
  1580. #include <__algorithm/set_symmetric_difference.h>
  1581. #include <__algorithm/set_union.h>
  1582. #include <__algorithm/shift_left.h>
  1583. #include <__algorithm/shift_right.h>
  1584. #include <__algorithm/shuffle.h>
  1585. #include <__algorithm/sift_down.h>
  1586. #include <__algorithm/sort.h>
  1587. #include <__algorithm/sort_old.h>
  1588. #include <__algorithm/sort_heap.h>
  1589. #include <__algorithm/stable_partition.h>
  1590. #include <__algorithm/stable_sort.h>
  1591. #include <__algorithm/swap_ranges.h>
  1592. #include <__algorithm/transform.h>
  1593. #include <__algorithm/unique.h>
  1594. #include <__algorithm/unique_copy.h>
  1595. #include <__algorithm/unwrap_iter.h>
  1596. #include <__algorithm/upper_bound.h>
  1597. // standard-mandated includes
  1598. // [algorithm.syn]
  1599. #include <initializer_list>
  1600. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  1601. # pragma GCC system_header
  1602. #endif
  1603. #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
  1604. # include <atomic>
  1605. # include <bit>
  1606. # include <concepts>
  1607. # include <cstdlib>
  1608. # include <cstring>
  1609. # include <iterator>
  1610. # include <memory>
  1611. # include <stdexcept>
  1612. # include <type_traits>
  1613. # include <utility>
  1614. #endif
  1615. #endif // _LIBCPP_ALGORITHM