algorithm 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047
  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. template <class I, class F>
  18. struct in_fun_result; // since C++20
  19. template <class I1, class I2>
  20. struct in_in_result; // since C++20
  21. template <class I1, class I2, class O>
  22. struct in_in_out_result; // since C++20
  23. template <class I, class O1, class O2>
  24. struct in_out_out_result; // since C++20
  25. template <class I1, class I2>
  26. struct min_max_result; // since C++20
  27. template <class I>
  28. struct in_found_result; // since C++20
  29. template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
  30. indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> // since C++20
  31. constexpr I min_element(I first, S last, Comp comp = {}, Proj proj = {});
  32. template<forward_range R, class Proj = identity,
  33. indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> // since C++20
  34. constexpr borrowed_iterator_t<R> min_element(R&& r, Comp comp = {}, Proj proj = {});
  35. template <input_iterator I1, sentinel_for<_I1> S1, input_iterator I2, sentinel_for<_I2> S2,
  36. class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
  37. requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
  38. constexpr mismatch_result<_I1, _I2>
  39. mismatch()(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20
  40. template <input_range R1, input_range R2,
  41. class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
  42. requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
  43. constexpr mismatch_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
  44. mismatch(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20
  45. requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
  46. constexpr I find(I first, S last, const T& value, Proj proj = {}); // since C++20
  47. template<input_range R, class T, class Proj = identity>
  48. requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
  49. constexpr borrowed_iterator_t<R>
  50. find(R&& r, const T& value, Proj proj = {}); // since C++20
  51. template<input_iterator I, sentinel_for<I> S, class Proj = identity,
  52. indirect_unary_predicate<projected<I, Proj>> Pred>
  53. constexpr I find_if(I first, S last, Pred pred, Proj proj = {}); // since C++20
  54. template<input_range R, class Proj = identity,
  55. indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
  56. constexpr borrowed_iterator_t<R>
  57. find_if(R&& r, Pred pred, Proj proj = {}); // since C++20
  58. template<input_iterator I, sentinel_for<I> S, class Proj = identity,
  59. indirect_unary_predicate<projected<I, Proj>> Pred>
  60. constexpr I find_if_not(I first, S last, Pred pred, Proj proj = {}); // since C++20
  61. template<input_range R, class Proj = identity,
  62. indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
  63. constexpr borrowed_iterator_t<R>
  64. find_if_not(R&& r, Pred pred, Proj proj = {}); // since C++20
  65. template<class T, class Proj = identity,
  66. indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
  67. constexpr const T& min(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
  68. template<copyable T, class Proj = identity,
  69. indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
  70. constexpr T min(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20
  71. template<input_range R, class Proj = identity,
  72. indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
  73. requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
  74. constexpr range_value_t<R>
  75. min(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
  76. template<class T, class Proj = identity,
  77. indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
  78. constexpr const T& max(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
  79. template<copyable T, class Proj = identity,
  80. indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
  81. constexpr T max(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20
  82. template<input_range R, class Proj = identity,
  83. indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
  84. requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
  85. constexpr range_value_t<R>
  86. max(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
  87. template<class I, class O>
  88. using unary_transform_result = in_out_result<I, O>; // since C++20
  89. template<class I1, class I2, class O>
  90. using binary_transform_result = in_in_out_result<I1, I2, O>; // since C++20
  91. template<input_iterator I, sentinel_for<I> S, weakly_incrementable O,
  92. copy_constructible F, class Proj = identity>
  93. requires indirectly_writable<O, indirect_result_t<F&, projected<I, Proj>>>
  94. constexpr ranges::unary_transform_result<I, O>
  95. transform(I first1, S last1, O result, F op, Proj proj = {}); // since C++20
  96. template<input_range R, weakly_incrementable O, copy_constructible F,
  97. class Proj = identity>
  98. requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R>, Proj>>>
  99. constexpr ranges::unary_transform_result<borrowed_iterator_t<R>, O>
  100. transform(R&& r, O result, F op, Proj proj = {}); // since C++20
  101. template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2,
  102. weakly_incrementable O, copy_constructible F, class Proj1 = identity,
  103. class Proj2 = identity>
  104. requires indirectly_writable<O, indirect_result_t<F&, projected<I1, Proj1>,
  105. projected<I2, Proj2>>>
  106. constexpr ranges::binary_transform_result<I1, I2, O>
  107. transform(I1 first1, S1 last1, I2 first2, S2 last2, O result,
  108. F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  109. template<input_range R1, input_range R2, weakly_incrementable O,
  110. copy_constructible F, class Proj1 = identity, class Proj2 = identity>
  111. requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R1>, Proj1>,
  112. projected<iterator_t<R2>, Proj2>>>
  113. constexpr ranges::binary_transform_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O>
  114. transform(R1&& r1, R2&& r2, O result,
  115. F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
  116. template<input_iterator I, sentinel_for<I> S, class T, class Proj = identity>
  117. requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
  118. constexpr iter_difference_t<I>
  119. count(I first, S last, const T& value, Proj proj = {}); // since C++20
  120. template<input_range R, class T, class Proj = identity>
  121. requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
  122. constexpr range_difference_t<R>
  123. count(R&& r, const T& value, Proj proj = {}); // since C++20
  124. template<input_iterator I, sentinel_for<I> S, class Proj = identity,
  125. indirect_unary_predicate<projected<I, Proj>> Pred>
  126. constexpr iter_difference_t<I>
  127. count_if(I first, S last, Pred pred, Proj proj = {}); // since C++20
  128. template<input_range R, class Proj = identity,
  129. indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
  130. constexpr range_difference_t<R>
  131. count_if(R&& r, Pred pred, Proj proj = {}); // since C++20
  132. template<class T, class Proj = identity,
  133. indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
  134. constexpr ranges::minmax_result<const T&>
  135. minmax(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
  136. template<copyable T, class Proj = identity,
  137. indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
  138. constexpr ranges::minmax_result<T>
  139. minmax(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20
  140. template<input_range R, class Proj = identity,
  141. indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
  142. requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*>
  143. constexpr ranges::minmax_result<range_value_t<R>>
  144. minmax(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
  145. template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
  146. indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
  147. constexpr ranges::minmax_element_result<I>
  148. minmax_element(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
  149. template<forward_range R, class Proj = identity,
  150. indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
  151. constexpr ranges::minmax_element_result<borrowed_iterator_t<R>>
  152. minmax_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
  153. template<class I, class O>
  154. using copy_result = in_out_result<I, O>; // since C++20
  155. template<class I, class O>
  156. using copy_n_result = in_out_result<I, O>; // since C++20
  157. template<class I, class O>
  158. using copy_if_result = in_out_result<I, O>; // since C++20
  159. template<class I1, class I2>
  160. using copy_backward_result = in_out_result<I1, I2>; // since C++20
  161. template<input_iterator I, sentinel_for<I> S, weakly_incrementable O>
  162. requires indirectly_copyable<I, O>
  163. constexpr ranges::copy_result<I, O> ranges::copy(I first, S last, O result); // since C++20
  164. template<input_range R, weakly_incrementable O>
  165. requires indirectly_copyable<iterator_t<R>, O>
  166. constexpr ranges::copy_result<borrowed_iterator_t<R>, O> ranges::copy(R&& r, O result); // since C++20
  167. template<input_iterator I, weakly_incrementable O>
  168. requires indirectly_copyable<I, O>
  169. constexpr ranges::copy_n_result<I, O>
  170. ranges::copy_n(I first, iter_difference_t<I> n, O result); // since C++20
  171. template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Proj = identity,
  172. indirect_unary_predicate<projected<I, Proj>> Pred>
  173. requires indirectly_copyable<I, O>
  174. constexpr ranges::copy_if_result<I, O>
  175. ranges::copy_if(I first, S last, O result, Pred pred, Proj proj = {}); // since C++20
  176. template<input_range R, weakly_incrementable O, class Proj = identity,
  177. indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
  178. requires indirectly_copyable<iterator_t<R>, O>
  179. constexpr ranges::copy_if_result<borrowed_iterator_t<R>, O>
  180. ranges::copy_if(R&& r, O result, Pred pred, Proj proj = {}); // since C++20
  181. template<bidirectional_iterator I1, sentinel_for<I1> S1, bidirectional_iterator I2>
  182. requires indirectly_copyable<I1, I2>
  183. constexpr ranges::copy_backward_result<I1, I2>
  184. ranges::copy_backward(I1 first, S1 last, I2 result); // since C++20
  185. template<bidirectional_range R, bidirectional_iterator I>
  186. requires indirectly_copyable<iterator_t<R>, I>
  187. constexpr ranges::copy_backward_result<borrowed_iterator_t<R>, I>
  188. ranges::copy_backward(R&& r, I result); // since C++20
  189. template<class I, class F>
  190. using for_each_result = in_fun_result<I, F>; // since C++20
  191. template<input_iterator I, sentinel_for<I> S, class Proj = identity,
  192. indirectly_unary_invocable<projected<I, Proj>> Fun>
  193. constexpr ranges::for_each_result<I, Fun>
  194. ranges::for_each(I first, S last, Fun f, Proj proj = {}); // since C++20
  195. template<input_range R, class Proj = identity,
  196. indirectly_unary_invocable<projected<iterator_t<R>, Proj>> Fun>
  197. constexpr ranges::for_each_result<borrowed_iterator_t<R>, Fun>
  198. ranges::for_each(R&& r, Fun f, Proj proj = {}); // since C++20
  199. template<input_iterator I, class Proj = identity,
  200. indirectly_unary_invocable<projected<I, Proj>> Fun>
  201. constexpr ranges::for_each_n_result<I, Fun>
  202. ranges::for_each_n(I first, iter_difference_t<I> n, Fun f, Proj proj = {}); // since C++20
  203. template<input_iterator I, sentinel_for<I> S, class Proj = identity,
  204. indirect_unary_predicate<projected<I, Proj>> Pred>
  205. constexpr bool ranges::is_partitioned(I first, S last, Pred pred, Proj proj = {}); // since C++20
  206. template<input_range R, class Proj = identity,
  207. indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
  208. constexpr bool ranges::is_partitioned(R&& r, Pred pred, Proj proj = {}); // since C++20
  209. }
  210. constexpr bool // constexpr in C++20
  211. all_of(InputIterator first, InputIterator last, Predicate pred);
  212. template <class InputIterator, class Predicate>
  213. constexpr bool // constexpr in C++20
  214. any_of(InputIterator first, InputIterator last, Predicate pred);
  215. template <class InputIterator, class Predicate>
  216. constexpr bool // constexpr in C++20
  217. none_of(InputIterator first, InputIterator last, Predicate pred);
  218. template <class InputIterator, class Function>
  219. constexpr Function // constexpr in C++20
  220. for_each(InputIterator first, InputIterator last, Function f);
  221. template<class InputIterator, class Size, class Function>
  222. constexpr InputIterator // constexpr in C++20
  223. for_each_n(InputIterator first, Size n, Function f); // C++17
  224. template <class InputIterator, class T>
  225. constexpr InputIterator // constexpr in C++20
  226. find(InputIterator first, InputIterator last, const T& value);
  227. template <class InputIterator, class Predicate>
  228. constexpr InputIterator // constexpr in C++20
  229. find_if(InputIterator first, InputIterator last, Predicate pred);
  230. template<class InputIterator, class Predicate>
  231. constexpr InputIterator // constexpr in C++20
  232. find_if_not(InputIterator first, InputIterator last, Predicate pred);
  233. template <class ForwardIterator1, class ForwardIterator2>
  234. constexpr ForwardIterator1 // constexpr in C++20
  235. find_end(ForwardIterator1 first1, ForwardIterator1 last1,
  236. ForwardIterator2 first2, ForwardIterator2 last2);
  237. template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
  238. constexpr ForwardIterator1 // constexpr in C++20
  239. find_end(ForwardIterator1 first1, ForwardIterator1 last1,
  240. ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
  241. template <class ForwardIterator1, class ForwardIterator2>
  242. constexpr ForwardIterator1 // constexpr in C++20
  243. find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
  244. ForwardIterator2 first2, ForwardIterator2 last2);
  245. template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
  246. constexpr ForwardIterator1 // constexpr in C++20
  247. find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
  248. ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
  249. template <class ForwardIterator>
  250. constexpr ForwardIterator // constexpr in C++20
  251. adjacent_find(ForwardIterator first, ForwardIterator last);
  252. template <class ForwardIterator, class BinaryPredicate>
  253. constexpr ForwardIterator // constexpr in C++20
  254. adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
  255. template <class InputIterator, class T>
  256. constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
  257. count(InputIterator first, InputIterator last, const T& value);
  258. template <class InputIterator, class Predicate>
  259. constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++20
  260. count_if(InputIterator first, InputIterator last, Predicate pred);
  261. template <class InputIterator1, class InputIterator2>
  262. constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
  263. mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
  264. template <class InputIterator1, class InputIterator2>
  265. constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
  266. mismatch(InputIterator1 first1, InputIterator1 last1,
  267. InputIterator2 first2, InputIterator2 last2); // **C++14**
  268. template <class InputIterator1, class InputIterator2, class BinaryPredicate>
  269. constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
  270. mismatch(InputIterator1 first1, InputIterator1 last1,
  271. InputIterator2 first2, BinaryPredicate pred);
  272. template <class InputIterator1, class InputIterator2, class BinaryPredicate>
  273. constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20
  274. mismatch(InputIterator1 first1, InputIterator1 last1,
  275. InputIterator2 first2, InputIterator2 last2,
  276. BinaryPredicate pred); // **C++14**
  277. template <class InputIterator1, class InputIterator2>
  278. constexpr bool // constexpr in C++20
  279. equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
  280. template <class InputIterator1, class InputIterator2>
  281. constexpr bool // constexpr in C++20
  282. equal(InputIterator1 first1, InputIterator1 last1,
  283. InputIterator2 first2, InputIterator2 last2); // **C++14**
  284. template <class InputIterator1, class InputIterator2, class BinaryPredicate>
  285. constexpr bool // constexpr in C++20
  286. equal(InputIterator1 first1, InputIterator1 last1,
  287. InputIterator2 first2, BinaryPredicate pred);
  288. template <class InputIterator1, class InputIterator2, class BinaryPredicate>
  289. constexpr bool // constexpr in C++20
  290. equal(InputIterator1 first1, InputIterator1 last1,
  291. InputIterator2 first2, InputIterator2 last2,
  292. BinaryPredicate pred); // **C++14**
  293. template<class ForwardIterator1, class ForwardIterator2>
  294. constexpr bool // constexpr in C++20
  295. is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
  296. ForwardIterator2 first2);
  297. template<class ForwardIterator1, class ForwardIterator2>
  298. constexpr bool // constexpr in C++20
  299. is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
  300. ForwardIterator2 first2, ForwardIterator2 last2); // **C++14**
  301. template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
  302. constexpr bool // constexpr in C++20
  303. is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
  304. ForwardIterator2 first2, BinaryPredicate pred);
  305. template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
  306. constexpr bool // constexpr in C++20
  307. is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
  308. ForwardIterator2 first2, ForwardIterator2 last2,
  309. BinaryPredicate pred); // **C++14**
  310. template <class ForwardIterator1, class ForwardIterator2>
  311. constexpr ForwardIterator1 // constexpr in C++20
  312. search(ForwardIterator1 first1, ForwardIterator1 last1,
  313. ForwardIterator2 first2, ForwardIterator2 last2);
  314. template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
  315. constexpr ForwardIterator1 // constexpr in C++20
  316. search(ForwardIterator1 first1, ForwardIterator1 last1,
  317. ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
  318. template <class ForwardIterator, class Size, class T>
  319. constexpr ForwardIterator // constexpr in C++20
  320. search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value);
  321. template <class ForwardIterator, class Size, class T, class BinaryPredicate>
  322. constexpr ForwardIterator // constexpr in C++20
  323. search_n(ForwardIterator first, ForwardIterator last,
  324. Size count, const T& value, BinaryPredicate pred);
  325. template <class InputIterator, class OutputIterator>
  326. constexpr OutputIterator // constexpr in C++20
  327. copy(InputIterator first, InputIterator last, OutputIterator result);
  328. template<class InputIterator, class OutputIterator, class Predicate>
  329. constexpr OutputIterator // constexpr in C++20
  330. copy_if(InputIterator first, InputIterator last,
  331. OutputIterator result, Predicate pred);
  332. template<class InputIterator, class Size, class OutputIterator>
  333. constexpr OutputIterator // constexpr in C++20
  334. copy_n(InputIterator first, Size n, OutputIterator result);
  335. template <class BidirectionalIterator1, class BidirectionalIterator2>
  336. constexpr BidirectionalIterator2 // constexpr in C++20
  337. copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
  338. BidirectionalIterator2 result);
  339. template <class ForwardIterator1, class ForwardIterator2>
  340. constexpr ForwardIterator2 // constexpr in C++20
  341. swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
  342. template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2>
  343. requires indirectly_swappable<I1, I2>
  344. constexpr ranges::swap_ranges_result<I1, I2>
  345. ranges::swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2);
  346. template<input_range R1, input_range R2>
  347. requires indirectly_swappable<iterator_t<R1>, iterator_t<R2>>
  348. constexpr ranges::swap_ranges_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>>
  349. ranges::swap_ranges(R1&& r1, R2&& r2);
  350. template <class ForwardIterator1, class ForwardIterator2>
  351. constexpr void // constexpr in C++20
  352. iter_swap(ForwardIterator1 a, ForwardIterator2 b);
  353. template <class InputIterator, class OutputIterator, class UnaryOperation>
  354. constexpr OutputIterator // constexpr in C++20
  355. transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op);
  356. template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
  357. constexpr OutputIterator // constexpr in C++20
  358. transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
  359. OutputIterator result, BinaryOperation binary_op);
  360. template <class ForwardIterator, class T>
  361. constexpr void // constexpr in C++20
  362. replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);
  363. template <class ForwardIterator, class Predicate, class T>
  364. constexpr void // constexpr in C++20
  365. replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value);
  366. template <class InputIterator, class OutputIterator, class T>
  367. constexpr OutputIterator // constexpr in C++20
  368. replace_copy(InputIterator first, InputIterator last, OutputIterator result,
  369. const T& old_value, const T& new_value);
  370. template <class InputIterator, class OutputIterator, class Predicate, class T>
  371. constexpr OutputIterator // constexpr in C++20
  372. replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value);
  373. template <class ForwardIterator, class T>
  374. constexpr void // constexpr in C++20
  375. fill(ForwardIterator first, ForwardIterator last, const T& value);
  376. template <class OutputIterator, class Size, class T>
  377. constexpr OutputIterator // constexpr in C++20
  378. fill_n(OutputIterator first, Size n, const T& value);
  379. template <class ForwardIterator, class Generator>
  380. constexpr void // constexpr in C++20
  381. generate(ForwardIterator first, ForwardIterator last, Generator gen);
  382. template <class OutputIterator, class Size, class Generator>
  383. constexpr OutputIterator // constexpr in C++20
  384. generate_n(OutputIterator first, Size n, Generator gen);
  385. template <class ForwardIterator, class T>
  386. constexpr ForwardIterator // constexpr in C++20
  387. remove(ForwardIterator first, ForwardIterator last, const T& value);
  388. template <class ForwardIterator, class Predicate>
  389. constexpr ForwardIterator // constexpr in C++20
  390. remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);
  391. template <class InputIterator, class OutputIterator, class T>
  392. constexpr OutputIterator // constexpr in C++20
  393. remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);
  394. template <class InputIterator, class OutputIterator, class Predicate>
  395. constexpr OutputIterator // constexpr in C++20
  396. remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
  397. template <class ForwardIterator>
  398. constexpr ForwardIterator // constexpr in C++20
  399. unique(ForwardIterator first, ForwardIterator last);
  400. template <class ForwardIterator, class BinaryPredicate>
  401. constexpr ForwardIterator // constexpr in C++20
  402. unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
  403. template <class InputIterator, class OutputIterator>
  404. constexpr OutputIterator // constexpr in C++20
  405. unique_copy(InputIterator first, InputIterator last, OutputIterator result);
  406. template <class InputIterator, class OutputIterator, class BinaryPredicate>
  407. constexpr OutputIterator // constexpr in C++20
  408. unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);
  409. template <class BidirectionalIterator>
  410. constexpr void // constexpr in C++20
  411. reverse(BidirectionalIterator first, BidirectionalIterator last);
  412. template <class BidirectionalIterator, class OutputIterator>
  413. constexpr OutputIterator // constexpr in C++20
  414. reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
  415. template <class ForwardIterator>
  416. constexpr ForwardIterator // constexpr in C++20
  417. rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
  418. template <class ForwardIterator, class OutputIterator>
  419. constexpr OutputIterator // constexpr in C++20
  420. rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);
  421. template <class RandomAccessIterator>
  422. void
  423. random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17
  424. template <class RandomAccessIterator, class RandomNumberGenerator>
  425. void
  426. random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
  427. RandomNumberGenerator& rand); // deprecated in C++14, removed in C++17
  428. template<class PopulationIterator, class SampleIterator,
  429. class Distance, class UniformRandomBitGenerator>
  430. SampleIterator sample(PopulationIterator first, PopulationIterator last,
  431. SampleIterator out, Distance n,
  432. UniformRandomBitGenerator&& g); // C++17
  433. template<class RandomAccessIterator, class UniformRandomNumberGenerator>
  434. void shuffle(RandomAccessIterator first, RandomAccessIterator last,
  435. UniformRandomNumberGenerator&& g);
  436. template<class ForwardIterator>
  437. constexpr ForwardIterator
  438. shift_left(ForwardIterator first, ForwardIterator last,
  439. typename iterator_traits<ForwardIterator>::difference_type n); // C++20
  440. template<class ForwardIterator>
  441. constexpr ForwardIterator
  442. shift_right(ForwardIterator first, ForwardIterator last,
  443. typename iterator_traits<ForwardIterator>::difference_type n); // C++20
  444. template <class InputIterator, class Predicate>
  445. constexpr bool // constexpr in C++20
  446. is_partitioned(InputIterator first, InputIterator last, Predicate pred);
  447. template <class ForwardIterator, class Predicate>
  448. constexpr ForwardIterator // constexpr in C++20
  449. partition(ForwardIterator first, ForwardIterator last, Predicate pred);
  450. template <class InputIterator, class OutputIterator1,
  451. class OutputIterator2, class Predicate>
  452. constexpr pair<OutputIterator1, OutputIterator2> // constexpr in C++20
  453. partition_copy(InputIterator first, InputIterator last,
  454. OutputIterator1 out_true, OutputIterator2 out_false,
  455. Predicate pred);
  456. template <class ForwardIterator, class Predicate>
  457. ForwardIterator
  458. stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
  459. template<class ForwardIterator, class Predicate>
  460. constexpr ForwardIterator // constexpr in C++20
  461. partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
  462. template <class ForwardIterator>
  463. constexpr bool // constexpr in C++20
  464. is_sorted(ForwardIterator first, ForwardIterator last);
  465. template <class ForwardIterator, class Compare>
  466. constexpr bool // constexpr in C++20
  467. is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
  468. template<class ForwardIterator>
  469. constexpr ForwardIterator // constexpr in C++20
  470. is_sorted_until(ForwardIterator first, ForwardIterator last);
  471. template <class ForwardIterator, class Compare>
  472. constexpr ForwardIterator // constexpr in C++20
  473. is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
  474. template <class RandomAccessIterator>
  475. constexpr void // constexpr in C++20
  476. sort(RandomAccessIterator first, RandomAccessIterator last);
  477. template <class RandomAccessIterator, class Compare>
  478. constexpr void // constexpr in C++20
  479. sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
  480. template <class RandomAccessIterator>
  481. void
  482. stable_sort(RandomAccessIterator first, RandomAccessIterator last);
  483. template <class RandomAccessIterator, class Compare>
  484. void
  485. stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
  486. template <class RandomAccessIterator>
  487. constexpr void // constexpr in C++20
  488. partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);
  489. template <class RandomAccessIterator, class Compare>
  490. constexpr void // constexpr in C++20
  491. partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp);
  492. template <class InputIterator, class RandomAccessIterator>
  493. constexpr RandomAccessIterator // constexpr in C++20
  494. partial_sort_copy(InputIterator first, InputIterator last,
  495. RandomAccessIterator result_first, RandomAccessIterator result_last);
  496. template <class InputIterator, class RandomAccessIterator, class Compare>
  497. constexpr RandomAccessIterator // constexpr in C++20
  498. partial_sort_copy(InputIterator first, InputIterator last,
  499. RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp);
  500. template <class RandomAccessIterator>
  501. constexpr void // constexpr in C++20
  502. nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);
  503. template <class RandomAccessIterator, class Compare>
  504. constexpr void // constexpr in C++20
  505. nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);
  506. template <class ForwardIterator, class T>
  507. constexpr ForwardIterator // constexpr in C++20
  508. lower_bound(ForwardIterator first, ForwardIterator last, const T& value);
  509. template <class ForwardIterator, class T, class Compare>
  510. constexpr ForwardIterator // constexpr in C++20
  511. lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
  512. template <class ForwardIterator, class T>
  513. constexpr ForwardIterator // constexpr in C++20
  514. upper_bound(ForwardIterator first, ForwardIterator last, const T& value);
  515. template <class ForwardIterator, class T, class Compare>
  516. constexpr ForwardIterator // constexpr in C++20
  517. upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
  518. template <class ForwardIterator, class T>
  519. constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
  520. equal_range(ForwardIterator first, ForwardIterator last, const T& value);
  521. template <class ForwardIterator, class T, class Compare>
  522. constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++20
  523. equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
  524. template <class ForwardIterator, class T>
  525. constexpr bool // constexpr in C++20
  526. binary_search(ForwardIterator first, ForwardIterator last, const T& value);
  527. template <class ForwardIterator, class T, class Compare>
  528. constexpr bool // constexpr in C++20
  529. binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
  530. template <class InputIterator1, class InputIterator2, class OutputIterator>
  531. constexpr OutputIterator // constexpr in C++20
  532. merge(InputIterator1 first1, InputIterator1 last1,
  533. InputIterator2 first2, InputIterator2 last2, OutputIterator result);
  534. template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
  535. constexpr OutputIterator // constexpr in C++20
  536. merge(InputIterator1 first1, InputIterator1 last1,
  537. InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
  538. template <class BidirectionalIterator>
  539. void
  540. inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last);
  541. template <class BidirectionalIterator, class Compare>
  542. void
  543. inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);
  544. template <class InputIterator1, class InputIterator2>
  545. constexpr bool // constexpr in C++20
  546. includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
  547. template <class InputIterator1, class InputIterator2, class Compare>
  548. constexpr bool // constexpr in C++20
  549. includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
  550. template <class InputIterator1, class InputIterator2, class OutputIterator>
  551. constexpr OutputIterator // constexpr in C++20
  552. set_union(InputIterator1 first1, InputIterator1 last1,
  553. InputIterator2 first2, InputIterator2 last2, OutputIterator result);
  554. template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
  555. constexpr OutputIterator // constexpr in C++20
  556. set_union(InputIterator1 first1, InputIterator1 last1,
  557. InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
  558. template <class InputIterator1, class InputIterator2, class OutputIterator>
  559. constexpr OutputIterator // constexpr in C++20
  560. set_intersection(InputIterator1 first1, InputIterator1 last1,
  561. InputIterator2 first2, InputIterator2 last2, OutputIterator result);
  562. template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
  563. constexpr OutputIterator // constexpr in C++20
  564. set_intersection(InputIterator1 first1, InputIterator1 last1,
  565. InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
  566. template <class InputIterator1, class InputIterator2, class OutputIterator>
  567. constexpr OutputIterator // constexpr in C++20
  568. set_difference(InputIterator1 first1, InputIterator1 last1,
  569. InputIterator2 first2, InputIterator2 last2, OutputIterator result);
  570. template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
  571. constexpr OutputIterator // constexpr in C++20
  572. set_difference(InputIterator1 first1, InputIterator1 last1,
  573. InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
  574. template <class InputIterator1, class InputIterator2, class OutputIterator>
  575. constexpr OutputIterator // constexpr in C++20
  576. set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
  577. InputIterator2 first2, InputIterator2 last2, OutputIterator result);
  578. template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
  579. constexpr OutputIterator // constexpr in C++20
  580. set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
  581. InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
  582. template <class RandomAccessIterator>
  583. constexpr void // constexpr in C++20
  584. push_heap(RandomAccessIterator first, RandomAccessIterator last);
  585. template <class RandomAccessIterator, class Compare>
  586. constexpr void // constexpr in C++20
  587. push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
  588. template <class RandomAccessIterator>
  589. constexpr void // constexpr in C++20
  590. pop_heap(RandomAccessIterator first, RandomAccessIterator last);
  591. template <class RandomAccessIterator, class Compare>
  592. constexpr void // constexpr in C++20
  593. pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
  594. template <class RandomAccessIterator>
  595. constexpr void // constexpr in C++20
  596. make_heap(RandomAccessIterator first, RandomAccessIterator last);
  597. template <class RandomAccessIterator, class Compare>
  598. constexpr void // constexpr in C++20
  599. make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
  600. template <class RandomAccessIterator>
  601. constexpr void // constexpr in C++20
  602. sort_heap(RandomAccessIterator first, RandomAccessIterator last);
  603. template <class RandomAccessIterator, class Compare>
  604. constexpr void // constexpr in C++20
  605. sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
  606. template <class RandomAccessIterator>
  607. constexpr bool // constexpr in C++20
  608. is_heap(RandomAccessIterator first, RandomAccessiterator last);
  609. template <class RandomAccessIterator, class Compare>
  610. constexpr bool // constexpr in C++20
  611. is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
  612. template <class RandomAccessIterator>
  613. constexpr RandomAccessIterator // constexpr in C++20
  614. is_heap_until(RandomAccessIterator first, RandomAccessiterator last);
  615. template <class RandomAccessIterator, class Compare>
  616. constexpr RandomAccessIterator // constexpr in C++20
  617. is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
  618. template <class ForwardIterator>
  619. constexpr ForwardIterator // constexpr in C++14
  620. min_element(ForwardIterator first, ForwardIterator last);
  621. template <class ForwardIterator, class Compare>
  622. constexpr ForwardIterator // constexpr in C++14
  623. min_element(ForwardIterator first, ForwardIterator last, Compare comp);
  624. template <class T>
  625. constexpr const T& // constexpr in C++14
  626. min(const T& a, const T& b);
  627. template <class T, class Compare>
  628. constexpr const T& // constexpr in C++14
  629. min(const T& a, const T& b, Compare comp);
  630. template<class T>
  631. constexpr T // constexpr in C++14
  632. min(initializer_list<T> t);
  633. template<class T, class Compare>
  634. constexpr T // constexpr in C++14
  635. min(initializer_list<T> t, Compare comp);
  636. template<class T>
  637. constexpr const T& clamp(const T& v, const T& lo, const T& hi); // C++17
  638. template<class T, class Compare>
  639. constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17
  640. template <class ForwardIterator>
  641. constexpr ForwardIterator // constexpr in C++14
  642. max_element(ForwardIterator first, ForwardIterator last);
  643. template <class ForwardIterator, class Compare>
  644. constexpr ForwardIterator // constexpr in C++14
  645. max_element(ForwardIterator first, ForwardIterator last, Compare comp);
  646. template <class T>
  647. constexpr const T& // constexpr in C++14
  648. max(const T& a, const T& b);
  649. template <class T, class Compare>
  650. constexpr const T& // constexpr in C++14
  651. max(const T& a, const T& b, Compare comp);
  652. template<class T>
  653. constexpr T // constexpr in C++14
  654. max(initializer_list<T> t);
  655. template<class T, class Compare>
  656. constexpr T // constexpr in C++14
  657. max(initializer_list<T> t, Compare comp);
  658. template<class ForwardIterator>
  659. constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
  660. minmax_element(ForwardIterator first, ForwardIterator last);
  661. template<class ForwardIterator, class Compare>
  662. constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++14
  663. minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
  664. template<class T>
  665. constexpr pair<const T&, const T&> // constexpr in C++14
  666. minmax(const T& a, const T& b);
  667. template<class T, class Compare>
  668. constexpr pair<const T&, const T&> // constexpr in C++14
  669. minmax(const T& a, const T& b, Compare comp);
  670. template<class T>
  671. constexpr pair<T, T> // constexpr in C++14
  672. minmax(initializer_list<T> t);
  673. template<class T, class Compare>
  674. constexpr pair<T, T> // constexpr in C++14
  675. minmax(initializer_list<T> t, Compare comp);
  676. template <class InputIterator1, class InputIterator2>
  677. constexpr bool // constexpr in C++20
  678. lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
  679. template <class InputIterator1, class InputIterator2, class Compare>
  680. constexpr bool // constexpr in C++20
  681. lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
  682. InputIterator2 first2, InputIterator2 last2, Compare comp);
  683. template <class BidirectionalIterator>
  684. constexpr bool // constexpr in C++20
  685. next_permutation(BidirectionalIterator first, BidirectionalIterator last);
  686. template <class BidirectionalIterator, class Compare>
  687. constexpr bool // constexpr in C++20
  688. next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
  689. template <class BidirectionalIterator>
  690. constexpr bool // constexpr in C++20
  691. prev_permutation(BidirectionalIterator first, BidirectionalIterator last);
  692. template <class BidirectionalIterator, class Compare>
  693. constexpr bool // constexpr in C++20
  694. prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
  695. } // std
  696. */
  697. #include <__assert> // all public C++ headers provide the assertion handler
  698. #include <__bits>
  699. #include <__config>
  700. #include <__debug>
  701. #include <cstddef>
  702. #include <cstring>
  703. #include <initializer_list>
  704. #include <iterator>
  705. #include <memory>
  706. #include <type_traits>
  707. #include <version>
  708. #include <__algorithm/adjacent_find.h>
  709. #include <__algorithm/all_of.h>
  710. #include <__algorithm/any_of.h>
  711. #include <__algorithm/binary_search.h>
  712. #include <__algorithm/clamp.h>
  713. #include <__algorithm/comp.h>
  714. #include <__algorithm/comp_ref_type.h>
  715. #include <__algorithm/copy.h>
  716. #include <__algorithm/copy_backward.h>
  717. #include <__algorithm/copy_if.h>
  718. #include <__algorithm/copy_n.h>
  719. #include <__algorithm/count.h>
  720. #include <__algorithm/count_if.h>
  721. #include <__algorithm/equal.h>
  722. #include <__algorithm/equal_range.h>
  723. #include <__algorithm/fill.h>
  724. #include <__algorithm/fill_n.h>
  725. #include <__algorithm/find.h>
  726. #include <__algorithm/find_end.h>
  727. #include <__algorithm/find_first_of.h>
  728. #include <__algorithm/find_if.h>
  729. #include <__algorithm/find_if_not.h>
  730. #include <__algorithm/for_each.h>
  731. #include <__algorithm/for_each_n.h>
  732. #include <__algorithm/generate.h>
  733. #include <__algorithm/generate_n.h>
  734. #include <__algorithm/half_positive.h>
  735. #include <__algorithm/in_found_result.h>
  736. #include <__algorithm/in_fun_result.h>
  737. #include <__algorithm/in_in_out_result.h>
  738. #include <__algorithm/in_in_result.h>
  739. #include <__algorithm/in_out_out_result.h>
  740. #include <__algorithm/in_out_result.h>
  741. #include <__algorithm/includes.h>
  742. #include <__algorithm/inplace_merge.h>
  743. #include <__algorithm/is_heap.h>
  744. #include <__algorithm/is_heap_until.h>
  745. #include <__algorithm/is_partitioned.h>
  746. #include <__algorithm/is_permutation.h>
  747. #include <__algorithm/is_sorted.h>
  748. #include <__algorithm/is_sorted_until.h>
  749. #include <__algorithm/iter_swap.h>
  750. #include <__algorithm/lexicographical_compare.h>
  751. #include <__algorithm/lower_bound.h>
  752. #include <__algorithm/make_heap.h>
  753. #include <__algorithm/max.h>
  754. #include <__algorithm/max_element.h>
  755. #include <__algorithm/merge.h>
  756. #include <__algorithm/min.h>
  757. #include <__algorithm/min_element.h>
  758. #include <__algorithm/min_max_result.h>
  759. #include <__algorithm/minmax.h>
  760. #include <__algorithm/minmax_element.h>
  761. #include <__algorithm/mismatch.h>
  762. #include <__algorithm/move.h>
  763. #include <__algorithm/move_backward.h>
  764. #include <__algorithm/next_permutation.h>
  765. #include <__algorithm/none_of.h>
  766. #include <__algorithm/nth_element.h>
  767. #include <__algorithm/partial_sort.h>
  768. #include <__algorithm/partial_sort_copy.h>
  769. #include <__algorithm/partition.h>
  770. #include <__algorithm/partition_copy.h>
  771. #include <__algorithm/partition_point.h>
  772. #include <__algorithm/pop_heap.h>
  773. #include <__algorithm/prev_permutation.h>
  774. #include <__algorithm/push_heap.h>
  775. #include <__algorithm/ranges_copy.h>
  776. #include <__algorithm/ranges_copy_backward.h>
  777. #include <__algorithm/ranges_copy_if.h>
  778. #include <__algorithm/ranges_copy_n.h>
  779. #include <__algorithm/ranges_count.h>
  780. #include <__algorithm/ranges_count_if.h>
  781. #include <__algorithm/ranges_find.h>
  782. #include <__algorithm/ranges_find_if.h>
  783. #include <__algorithm/ranges_find_if_not.h>
  784. #include <__algorithm/ranges_for_each.h>
  785. #include <__algorithm/ranges_for_each_n.h>
  786. #include <__algorithm/ranges_is_partitioned.h>
  787. #include <__algorithm/ranges_max.h>
  788. #include <__algorithm/ranges_max_element.h>
  789. #include <__algorithm/ranges_min.h>
  790. #include <__algorithm/ranges_min_element.h>
  791. #include <__algorithm/ranges_minmax.h>
  792. #include <__algorithm/ranges_minmax_element.h>
  793. #include <__algorithm/ranges_mismatch.h>
  794. #include <__algorithm/ranges_swap_ranges.h>
  795. #include <__algorithm/ranges_transform.h>
  796. #include <__algorithm/remove.h>
  797. #include <__algorithm/remove_copy.h>
  798. #include <__algorithm/remove_copy_if.h>
  799. #include <__algorithm/remove_if.h>
  800. #include <__algorithm/replace.h>
  801. #include <__algorithm/replace_copy.h>
  802. #include <__algorithm/replace_copy_if.h>
  803. #include <__algorithm/replace_if.h>
  804. #include <__algorithm/reverse.h>
  805. #include <__algorithm/reverse_copy.h>
  806. #include <__algorithm/rotate.h>
  807. #include <__algorithm/rotate_copy.h>
  808. #include <__algorithm/sample.h>
  809. #include <__algorithm/search.h>
  810. #include <__algorithm/search_n.h>
  811. #include <__algorithm/set_difference.h>
  812. #include <__algorithm/set_intersection.h>
  813. #include <__algorithm/set_symmetric_difference.h>
  814. #include <__algorithm/set_union.h>
  815. #include <__algorithm/shift_left.h>
  816. #include <__algorithm/shift_right.h>
  817. #include <__algorithm/shuffle.h>
  818. #include <__algorithm/sift_down.h>
  819. #include <__algorithm/sort.h>
  820. #include <__algorithm/sort_heap.h>
  821. #include <__algorithm/stable_partition.h>
  822. #include <__algorithm/stable_sort.h>
  823. #include <__algorithm/swap_ranges.h>
  824. #include <__algorithm/transform.h>
  825. #include <__algorithm/unique.h>
  826. #include <__algorithm/unique_copy.h>
  827. #include <__algorithm/unwrap_iter.h>
  828. #include <__algorithm/upper_bound.h>
  829. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  830. # pragma GCC system_header
  831. #endif
  832. #if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
  833. //# include <__pstl_algorithm>
  834. #endif
  835. #endif // _LIBCPP_ALGORITHM