algorithm 104 KB

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