aboutsummaryrefslogtreecommitdiff
path: root/libcxx/include/__algorithm
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/include/__algorithm')
-rw-r--r--libcxx/include/__algorithm/adjacent_find.h2
-rw-r--r--libcxx/include/__algorithm/binary_search.h2
-rw-r--r--libcxx/include/__algorithm/clamp.h2
-rw-r--r--libcxx/include/__algorithm/copy.h2
-rw-r--r--libcxx/include/__algorithm/copy_backward.h2
-rw-r--r--libcxx/include/__algorithm/copy_if.h4
-rw-r--r--libcxx/include/__algorithm/copy_n.h4
-rw-r--r--libcxx/include/__algorithm/equal.h2
-rw-r--r--libcxx/include/__algorithm/equal_range.h2
-rw-r--r--libcxx/include/__algorithm/fill.h2
-rw-r--r--libcxx/include/__algorithm/find_end.h2
-rw-r--r--libcxx/include/__algorithm/find_first_of.h2
-rw-r--r--libcxx/include/__algorithm/in_in_result.h45
-rw-r--r--libcxx/include/__algorithm/in_out_result.h52
-rw-r--r--libcxx/include/__algorithm/includes.h2
-rw-r--r--libcxx/include/__algorithm/inplace_merge.h4
-rw-r--r--libcxx/include/__algorithm/is_heap.h2
-rw-r--r--libcxx/include/__algorithm/is_heap_until.h2
-rw-r--r--libcxx/include/__algorithm/is_sorted_until.h2
-rw-r--r--libcxx/include/__algorithm/lexicographical_compare.h2
-rw-r--r--libcxx/include/__algorithm/lower_bound.h2
-rw-r--r--libcxx/include/__algorithm/make_heap.h4
-rw-r--r--libcxx/include/__algorithm/max.h2
-rw-r--r--libcxx/include/__algorithm/max_element.h2
-rw-r--r--libcxx/include/__algorithm/merge.h2
-rw-r--r--libcxx/include/__algorithm/min.h2
-rw-r--r--libcxx/include/__algorithm/min_element.h2
-rw-r--r--libcxx/include/__algorithm/minmax.h3
-rw-r--r--libcxx/include/__algorithm/minmax_element.h2
-rw-r--r--libcxx/include/__algorithm/mismatch.h2
-rw-r--r--libcxx/include/__algorithm/move.h4
-rw-r--r--libcxx/include/__algorithm/move_backward.h4
-rw-r--r--libcxx/include/__algorithm/next_permutation.h2
-rw-r--r--libcxx/include/__algorithm/nth_element.h2
-rw-r--r--libcxx/include/__algorithm/partial_sort.h10
-rw-r--r--libcxx/include/__algorithm/partial_sort_copy.h5
-rw-r--r--libcxx/include/__algorithm/partition.h1
-rw-r--r--libcxx/include/__algorithm/partition_point.h2
-rw-r--r--libcxx/include/__algorithm/pop_heap.h4
-rw-r--r--libcxx/include/__algorithm/prev_permutation.h2
-rw-r--r--libcxx/include/__algorithm/push_heap.h2
-rw-r--r--libcxx/include/__algorithm/remove.h2
-rw-r--r--libcxx/include/__algorithm/remove_if.h2
-rw-r--r--libcxx/include/__algorithm/reverse.h2
-rw-r--r--libcxx/include/__algorithm/rotate_copy.h4
-rw-r--r--libcxx/include/__algorithm/search_n.h2
-rw-r--r--libcxx/include/__algorithm/set_difference.h2
-rw-r--r--libcxx/include/__algorithm/set_intersection.h2
-rw-r--r--libcxx/include/__algorithm/set_symmetric_difference.h2
-rw-r--r--libcxx/include/__algorithm/set_union.h2
-rw-r--r--libcxx/include/__algorithm/shift_left.h4
-rw-r--r--libcxx/include/__algorithm/shift_right.h5
-rw-r--r--libcxx/include/__algorithm/sift_down.h5
-rw-r--r--libcxx/include/__algorithm/sort.h2
-rw-r--r--libcxx/include/__algorithm/sort_heap.h2
-rw-r--r--libcxx/include/__algorithm/stable_partition.h2
-rw-r--r--libcxx/include/__algorithm/stable_sort.h4
-rw-r--r--libcxx/include/__algorithm/unique.h4
-rw-r--r--libcxx/include/__algorithm/unique_copy.h2
-rw-r--r--libcxx/include/__algorithm/unwrap_iter.h2
-rw-r--r--libcxx/include/__algorithm/upper_bound.h2
61 files changed, 171 insertions, 83 deletions
diff --git a/libcxx/include/__algorithm/adjacent_find.h b/libcxx/include/__algorithm/adjacent_find.h
index 621ef5f20f82..29ad83f96810 100644
--- a/libcxx/include/__algorithm/adjacent_find.h
+++ b/libcxx/include/__algorithm/adjacent_find.h
@@ -10,8 +10,8 @@
#ifndef _LIBCPP___ALGORITHM_ADJACENT_FIND_H
#define _LIBCPP___ALGORITHM_ADJACENT_FIND_H
-#include <__config>
#include <__algorithm/comp.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/binary_search.h b/libcxx/include/__algorithm/binary_search.h
index 8fc55b9becb1..2558dd0b27b9 100644
--- a/libcxx/include/__algorithm/binary_search.h
+++ b/libcxx/include/__algorithm/binary_search.h
@@ -9,10 +9,10 @@
#ifndef _LIBCPP___ALGORITHM_BINARY_SEARCH_H
#define _LIBCPP___ALGORITHM_BINARY_SEARCH_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/lower_bound.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/clamp.h b/libcxx/include/__algorithm/clamp.h
index db28735e97a3..a51c1015be3f 100644
--- a/libcxx/include/__algorithm/clamp.h
+++ b/libcxx/include/__algorithm/clamp.h
@@ -9,9 +9,9 @@
#ifndef _LIBCPP___ALGORITHM_CLAMP_H
#define _LIBCPP___ALGORITHM_CLAMP_H
+#include <__algorithm/comp.h>
#include <__config>
#include <__debug>
-#include <__algorithm/comp.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
diff --git a/libcxx/include/__algorithm/copy.h b/libcxx/include/__algorithm/copy.h
index e7e8b9e51a3e..65f0e0b0ef7d 100644
--- a/libcxx/include/__algorithm/copy.h
+++ b/libcxx/include/__algorithm/copy.h
@@ -9,8 +9,8 @@
#ifndef _LIBCPP___ALGORITHM_COPY_H
#define _LIBCPP___ALGORITHM_COPY_H
-#include <__config>
#include <__algorithm/unwrap_iter.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#include <cstring>
#include <type_traits>
diff --git a/libcxx/include/__algorithm/copy_backward.h b/libcxx/include/__algorithm/copy_backward.h
index 4a2f8c0c49cd..ac733290abe4 100644
--- a/libcxx/include/__algorithm/copy_backward.h
+++ b/libcxx/include/__algorithm/copy_backward.h
@@ -9,8 +9,8 @@
#ifndef _LIBCPP___ALGORITHM_COPY_BACKWARD_H
#define _LIBCPP___ALGORITHM_COPY_BACKWARD_H
-#include <__config>
#include <__algorithm/unwrap_iter.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#include <cstring>
#include <type_traits>
diff --git a/libcxx/include/__algorithm/copy_if.h b/libcxx/include/__algorithm/copy_if.h
index 230826f63af4..d32514d999b5 100644
--- a/libcxx/include/__algorithm/copy_if.h
+++ b/libcxx/include/__algorithm/copy_if.h
@@ -10,10 +10,6 @@
#define _LIBCPP___ALGORITHM_COPY_IF_H
#include <__config>
-#include <__algorithm/unwrap_iter.h>
-#include <__iterator/iterator_traits.h>
-#include <cstring>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
diff --git a/libcxx/include/__algorithm/copy_n.h b/libcxx/include/__algorithm/copy_n.h
index 38a84a4105a4..cdcc0d50dbf1 100644
--- a/libcxx/include/__algorithm/copy_n.h
+++ b/libcxx/include/__algorithm/copy_n.h
@@ -9,11 +9,9 @@
#ifndef _LIBCPP___ALGORITHM_COPY_N_H
#define _LIBCPP___ALGORITHM_COPY_N_H
-#include <__config>
#include <__algorithm/copy.h>
-#include <__algorithm/unwrap_iter.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
-#include <cstring>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/equal.h b/libcxx/include/__algorithm/equal.h
index 0fe1a21fe526..4c9ad05ad6b8 100644
--- a/libcxx/include/__algorithm/equal.h
+++ b/libcxx/include/__algorithm/equal.h
@@ -10,8 +10,8 @@
#ifndef _LIBCPP___ALGORITHM_EQUAL_H
#define _LIBCPP___ALGORITHM_EQUAL_H
-#include <__config>
#include <__algorithm/comp.h>
+#include <__config>
#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>
diff --git a/libcxx/include/__algorithm/equal_range.h b/libcxx/include/__algorithm/equal_range.h
index 679456e27b43..e13f0bdd9695 100644
--- a/libcxx/include/__algorithm/equal_range.h
+++ b/libcxx/include/__algorithm/equal_range.h
@@ -9,12 +9,12 @@
#ifndef _LIBCPP___ALGORITHM_EQUAL_RANGE_H
#define _LIBCPP___ALGORITHM_EQUAL_RANGE_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/half_positive.h>
#include <__algorithm/lower_bound.h>
#include <__algorithm/upper_bound.h>
+#include <__config>
#include <iterator>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/fill.h b/libcxx/include/__algorithm/fill.h
index 1fad1de993bf..0cb36b02c831 100644
--- a/libcxx/include/__algorithm/fill.h
+++ b/libcxx/include/__algorithm/fill.h
@@ -9,8 +9,8 @@
#ifndef _LIBCPP___ALGORITHM_FILL_H
#define _LIBCPP___ALGORITHM_FILL_H
-#include <__config>
#include <__algorithm/fill_n.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#include <type_traits>
diff --git a/libcxx/include/__algorithm/find_end.h b/libcxx/include/__algorithm/find_end.h
index 5d971c57a4e0..dd0f7d7ac03d 100644
--- a/libcxx/include/__algorithm/find_end.h
+++ b/libcxx/include/__algorithm/find_end.h
@@ -10,8 +10,8 @@
#ifndef _LIBCPP___ALGORITHM_FIND_END_OF_H
#define _LIBCPP___ALGORITHM_FIND_END_OF_H
-#include <__config>
#include <__algorithm/comp.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/find_first_of.h b/libcxx/include/__algorithm/find_first_of.h
index 79a00acb9ee6..69354f61769f 100644
--- a/libcxx/include/__algorithm/find_first_of.h
+++ b/libcxx/include/__algorithm/find_first_of.h
@@ -10,8 +10,8 @@
#ifndef _LIBCPP___ALGORITHM_FIND_FIRST_OF_H
#define _LIBCPP___ALGORITHM_FIND_FIRST_OF_H
-#include <__config>
#include <__algorithm/comp.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/in_in_result.h b/libcxx/include/__algorithm/in_in_result.h
new file mode 100644
index 000000000000..fbe53ae4f57e
--- /dev/null
+++ b/libcxx/include/__algorithm/in_in_result.h
@@ -0,0 +1,45 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_IN_IN_RESULT_H
+#define _LIBCPP___ALGORITHM_IN_IN_RESULT_H
+
+#include <__concepts/convertible_to.h>
+#include <__config>
+#include <__utility/move.h>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifndef _LIBCPP_HAS_NO_RANGES
+
+namespace ranges {
+template <class _I1, class _I2>
+struct in_in_result {
+ [[no_unique_address]] _I1 in1;
+ [[no_unique_address]] _I2 in2;
+
+ template <class _II1, class _II2>
+ requires convertible_to<const _I1&, _II1> && convertible_to<const _I2&, _II2>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ operator in_in_result<_II1, _II2>() const & {
+ return {in1, in2};
+ }
+
+ template <class _II1, class _II2>
+ requires convertible_to<_I1, _II1> && convertible_to<_I2, _II2>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ operator in_in_result<_II1, _II2>() && { return {_VSTD::move(in1), _VSTD::move(in2)}; }
+};
+} // namespace ranges
+
+#endif // _LIBCPP_HAS_NO_RANGES
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ALGORITHM_IN_IN_RESULT_H
diff --git a/libcxx/include/__algorithm/in_out_result.h b/libcxx/include/__algorithm/in_out_result.h
new file mode 100644
index 000000000000..9d971157200f
--- /dev/null
+++ b/libcxx/include/__algorithm/in_out_result.h
@@ -0,0 +1,52 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_IN_OUT_RESULT_H
+#define _LIBCPP___ALGORITHM_IN_OUT_RESULT_H
+
+#include <__concepts/convertible_to.h>
+#include <__config>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+namespace ranges {
+
+template<class _InputIterator, class _OutputIterator>
+struct in_out_result {
+ [[no_unique_address]] _InputIterator in;
+ [[no_unique_address]] _OutputIterator out;
+
+ template <class _InputIterator2, class _OutputIterator2>
+ requires convertible_to<const _InputIterator&, _InputIterator2> && convertible_to<const _OutputIterator&,
+ _OutputIterator2>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr operator in_out_result<_InputIterator2, _OutputIterator2>() const & {
+ return {in, out};
+ }
+
+ template <class _InputIterator2, class _OutputIterator2>
+ requires convertible_to<_InputIterator, _InputIterator2> && convertible_to<_OutputIterator, _OutputIterator2>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr operator in_out_result<_InputIterator2, _OutputIterator2>() && {
+ return {_VSTD::move(in), _VSTD::move(out)};
+ }
+};
+
+} // namespace ranges
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ALGORITHM_IN_OUT_RESULT_H
diff --git a/libcxx/include/__algorithm/includes.h b/libcxx/include/__algorithm/includes.h
index 9cc54d938dcf..9d0bc694c0d3 100644
--- a/libcxx/include/__algorithm/includes.h
+++ b/libcxx/include/__algorithm/includes.h
@@ -9,9 +9,9 @@
#ifndef _LIBCPP___ALGORITHM_INCLUDES_H
#define _LIBCPP___ALGORITHM_INCLUDES_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/inplace_merge.h b/libcxx/include/__algorithm/inplace_merge.h
index c74633a74cf3..e6f1efc011b1 100644
--- a/libcxx/include/__algorithm/inplace_merge.h
+++ b/libcxx/include/__algorithm/inplace_merge.h
@@ -9,14 +9,14 @@
#ifndef _LIBCPP___ALGORITHM_INPLACE_MERGE_H
#define _LIBCPP___ALGORITHM_INPLACE_MERGE_H
-#include <__config>
-#include <__algorithm/comp_ref_type.h>
#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
#include <__algorithm/lower_bound.h>
#include <__algorithm/min.h>
#include <__algorithm/move.h>
#include <__algorithm/rotate.h>
#include <__algorithm/upper_bound.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#include <__utility/swap.h>
#include <memory>
diff --git a/libcxx/include/__algorithm/is_heap.h b/libcxx/include/__algorithm/is_heap.h
index 22c27a66d129..925ba8bfb8bd 100644
--- a/libcxx/include/__algorithm/is_heap.h
+++ b/libcxx/include/__algorithm/is_heap.h
@@ -9,10 +9,10 @@
#ifndef _LIBCPP___ALGORITHM_IS_HEAP_H
#define _LIBCPP___ALGORITHM_IS_HEAP_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/is_heap_until.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/is_heap_until.h b/libcxx/include/__algorithm/is_heap_until.h
index dd8a62f07fd3..aa23b6d039d3 100644
--- a/libcxx/include/__algorithm/is_heap_until.h
+++ b/libcxx/include/__algorithm/is_heap_until.h
@@ -9,9 +9,9 @@
#ifndef _LIBCPP___ALGORITHM_IS_HEAP_UNTIL_H
#define _LIBCPP___ALGORITHM_IS_HEAP_UNTIL_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/is_sorted_until.h b/libcxx/include/__algorithm/is_sorted_until.h
index 9a7f275c5400..57cad47761d9 100644
--- a/libcxx/include/__algorithm/is_sorted_until.h
+++ b/libcxx/include/__algorithm/is_sorted_until.h
@@ -9,9 +9,9 @@
#ifndef _LIBCPP___ALGORITHM_IS_SORTED_UNTIL_H
#define _LIBCPP___ALGORITHM_IS_SORTED_UNTIL_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/lexicographical_compare.h b/libcxx/include/__algorithm/lexicographical_compare.h
index a110a58c01c1..55a1da620125 100644
--- a/libcxx/include/__algorithm/lexicographical_compare.h
+++ b/libcxx/include/__algorithm/lexicographical_compare.h
@@ -9,9 +9,9 @@
#ifndef _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H
#define _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/lower_bound.h b/libcxx/include/__algorithm/lower_bound.h
index ddaecb045b3e..663a0b16228e 100644
--- a/libcxx/include/__algorithm/lower_bound.h
+++ b/libcxx/include/__algorithm/lower_bound.h
@@ -9,9 +9,9 @@
#ifndef _LIBCPP___ALGORITHM_LOWER_BOUND_H
#define _LIBCPP___ALGORITHM_LOWER_BOUND_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/half_positive.h>
+#include <__config>
#include <iterator>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/make_heap.h b/libcxx/include/__algorithm/make_heap.h
index b3defd4de072..f489addaf5cc 100644
--- a/libcxx/include/__algorithm/make_heap.h
+++ b/libcxx/include/__algorithm/make_heap.h
@@ -9,10 +9,10 @@
#ifndef _LIBCPP___ALGORITHM_MAKE_HEAP_H
#define _LIBCPP___ALGORITHM_MAKE_HEAP_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/sift_down.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -32,7 +32,7 @@ __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar
// start from the first parent, there is no need to consider children
for (difference_type __start = (__n - 2) / 2; __start >= 0; --__start)
{
- _VSTD::__sift_down<_Compare>(__first, __last, __comp, __n, __first + __start);
+ _VSTD::__sift_down<_Compare>(__first, __comp, __n, __first + __start);
}
}
}
diff --git a/libcxx/include/__algorithm/max.h b/libcxx/include/__algorithm/max.h
index 79cbd2be86b6..0bbc971e0a9c 100644
--- a/libcxx/include/__algorithm/max.h
+++ b/libcxx/include/__algorithm/max.h
@@ -9,10 +9,10 @@
#ifndef _LIBCPP___ALGORITHM_MAX_H
#define _LIBCPP___ALGORITHM_MAX_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/max_element.h>
+#include <__config>
#include <initializer_list>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/max_element.h b/libcxx/include/__algorithm/max_element.h
index f932ca7049fa..db2937260582 100644
--- a/libcxx/include/__algorithm/max_element.h
+++ b/libcxx/include/__algorithm/max_element.h
@@ -9,9 +9,9 @@
#ifndef _LIBCPP___ALGORITHM_MAX_ELEMENT_H
#define _LIBCPP___ALGORITHM_MAX_ELEMENT_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/merge.h b/libcxx/include/__algorithm/merge.h
index 480380db6caa..91826493771a 100644
--- a/libcxx/include/__algorithm/merge.h
+++ b/libcxx/include/__algorithm/merge.h
@@ -9,10 +9,10 @@
#ifndef _LIBCPP___ALGORITHM_MERGE_H
#define _LIBCPP___ALGORITHM_MERGE_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/copy.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/min.h b/libcxx/include/__algorithm/min.h
index 5cacb2f28e7e..ed2d3b87828a 100644
--- a/libcxx/include/__algorithm/min.h
+++ b/libcxx/include/__algorithm/min.h
@@ -9,10 +9,10 @@
#ifndef _LIBCPP___ALGORITHM_MIN_H
#define _LIBCPP___ALGORITHM_MIN_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/min_element.h>
+#include <__config>
#include <initializer_list>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/min_element.h b/libcxx/include/__algorithm/min_element.h
index 3aebebca91ab..407c7f93336d 100644
--- a/libcxx/include/__algorithm/min_element.h
+++ b/libcxx/include/__algorithm/min_element.h
@@ -9,9 +9,9 @@
#ifndef _LIBCPP___ALGORITHM_MIN_ELEMENT_H
#define _LIBCPP___ALGORITHM_MIN_ELEMENT_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/minmax.h b/libcxx/include/__algorithm/minmax.h
index a96a5b252c09..0bf88a70b8aa 100644
--- a/libcxx/include/__algorithm/minmax.h
+++ b/libcxx/include/__algorithm/minmax.h
@@ -9,12 +9,11 @@
#ifndef _LIBCPP___ALGORITHM_MINMAX_H
#define _LIBCPP___ALGORITHM_MINMAX_H
-#include <__config>
#include <__algorithm/comp.h>
+#include <__config>
#include <initializer_list>
#include <utility>
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
diff --git a/libcxx/include/__algorithm/minmax_element.h b/libcxx/include/__algorithm/minmax_element.h
index d21ff6f8dc5a..5d768603843b 100644
--- a/libcxx/include/__algorithm/minmax_element.h
+++ b/libcxx/include/__algorithm/minmax_element.h
@@ -9,8 +9,8 @@
#ifndef _LIBCPP___ALGORITHM_MINMAX_ELEMENT_H
#define _LIBCPP___ALGORITHM_MINMAX_ELEMENT_H
-#include <__config>
#include <__algorithm/comp.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#include <utility>
diff --git a/libcxx/include/__algorithm/mismatch.h b/libcxx/include/__algorithm/mismatch.h
index 7a01a985934a..230ade03df19 100644
--- a/libcxx/include/__algorithm/mismatch.h
+++ b/libcxx/include/__algorithm/mismatch.h
@@ -10,8 +10,8 @@
#ifndef _LIBCPP___ALGORITHM_MISMATCH_H
#define _LIBCPP___ALGORITHM_MISMATCH_H
-#include <__config>
#include <__algorithm/comp.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#include <utility>
diff --git a/libcxx/include/__algorithm/move.h b/libcxx/include/__algorithm/move.h
index 7430bf087438..fa118f471669 100644
--- a/libcxx/include/__algorithm/move.h
+++ b/libcxx/include/__algorithm/move.h
@@ -9,12 +9,12 @@
#ifndef _LIBCPP___ALGORITHM_MOVE_H
#define _LIBCPP___ALGORITHM_MOVE_H
-#include <__config>
#include <__algorithm/unwrap_iter.h>
+#include <__config>
#include <__utility/move.h>
#include <cstring>
-#include <utility>
#include <type_traits>
+#include <utility>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
diff --git a/libcxx/include/__algorithm/move_backward.h b/libcxx/include/__algorithm/move_backward.h
index ee72d39764ca..a4e3828b6069 100644
--- a/libcxx/include/__algorithm/move_backward.h
+++ b/libcxx/include/__algorithm/move_backward.h
@@ -9,11 +9,11 @@
#ifndef _LIBCPP___ALGORITHM_MOVE_BACKWARD_H
#define _LIBCPP___ALGORITHM_MOVE_BACKWARD_H
-#include <__config>
#include <__algorithm/unwrap_iter.h>
+#include <__config>
#include <cstring>
-#include <utility>
#include <type_traits>
+#include <utility>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
diff --git a/libcxx/include/__algorithm/next_permutation.h b/libcxx/include/__algorithm/next_permutation.h
index 1d71354eb375..eb81cceb7bbc 100644
--- a/libcxx/include/__algorithm/next_permutation.h
+++ b/libcxx/include/__algorithm/next_permutation.h
@@ -9,10 +9,10 @@
#ifndef _LIBCPP___ALGORITHM_NEXT_PERMUTATION_H
#define _LIBCPP___ALGORITHM_NEXT_PERMUTATION_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/reverse.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#include <__utility/swap.h>
diff --git a/libcxx/include/__algorithm/nth_element.h b/libcxx/include/__algorithm/nth_element.h
index 63feba1ea616..3afbd6c61846 100644
--- a/libcxx/include/__algorithm/nth_element.h
+++ b/libcxx/include/__algorithm/nth_element.h
@@ -9,10 +9,10 @@
#ifndef _LIBCPP___ALGORITHM_NTH_ELEMENT_H
#define _LIBCPP___ALGORITHM_NTH_ELEMENT_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/sort.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#include <__utility/swap.h>
diff --git a/libcxx/include/__algorithm/partial_sort.h b/libcxx/include/__algorithm/partial_sort.h
index 622624ec4f42..a92a7e56610a 100644
--- a/libcxx/include/__algorithm/partial_sort.h
+++ b/libcxx/include/__algorithm/partial_sort.h
@@ -9,12 +9,12 @@
#ifndef _LIBCPP___ALGORITHM_PARTIAL_SORT_H
#define _LIBCPP___ALGORITHM_PARTIAL_SORT_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/make_heap.h>
#include <__algorithm/sift_down.h>
#include <__algorithm/sort_heap.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#include <__utility/swap.h>
@@ -31,8 +31,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Compare, class _RandomAccessIterator>
_LIBCPP_CONSTEXPR_AFTER_CXX17 void
__partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
- _Compare __comp)
+ _Compare __comp)
{
+ if (__first == __middle)
+ return;
_VSTD::__make_heap<_Compare>(__first, __middle, __comp);
typename iterator_traits<_RandomAccessIterator>::difference_type __len = __middle - __first;
for (_RandomAccessIterator __i = __middle; __i != __last; ++__i)
@@ -40,7 +42,7 @@ __partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _R
if (__comp(*__i, *__first))
{
swap(*__i, *__first);
- _VSTD::__sift_down<_Compare>(__first, __middle, __comp, __len, __first);
+ _VSTD::__sift_down<_Compare>(__first, __comp, __len, __first);
}
}
_VSTD::__sort_heap<_Compare>(__first, __middle, __comp);
@@ -64,7 +66,7 @@ void
partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)
{
_VSTD::partial_sort(__first, __middle, __last,
- __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+ __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__algorithm/partial_sort_copy.h b/libcxx/include/__algorithm/partial_sort_copy.h
index 4c0c9f5ad04a..67a62bae1f5a 100644
--- a/libcxx/include/__algorithm/partial_sort_copy.h
+++ b/libcxx/include/__algorithm/partial_sort_copy.h
@@ -9,14 +9,13 @@
#ifndef _LIBCPP___ALGORITHM_PARTIAL_SORT_COPY_H
#define _LIBCPP___ALGORITHM_PARTIAL_SORT_COPY_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/make_heap.h>
#include <__algorithm/sift_down.h>
#include <__algorithm/sort_heap.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
-#include <type_traits> // swap
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -40,7 +39,7 @@ __partial_sort_copy(_InputIterator __first, _InputIterator __last,
if (__comp(*__first, *__result_first))
{
*__result_first = *__first;
- _VSTD::__sift_down<_Compare>(__result_first, __r, __comp, __len, __result_first);
+ _VSTD::__sift_down<_Compare>(__result_first, __comp, __len, __result_first);
}
_VSTD::__sort_heap<_Compare>(__result_first, __r, __comp);
}
diff --git a/libcxx/include/__algorithm/partition.h b/libcxx/include/__algorithm/partition.h
index 2614520ccbcf..131c5d3735d5 100644
--- a/libcxx/include/__algorithm/partition.h
+++ b/libcxx/include/__algorithm/partition.h
@@ -12,7 +12,6 @@
#include <__config>
#include <__iterator/iterator_traits.h>
#include <__utility/swap.h>
-#include <utility> // pair
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
diff --git a/libcxx/include/__algorithm/partition_point.h b/libcxx/include/__algorithm/partition_point.h
index 33aaf33d938c..18e6e6f6812f 100644
--- a/libcxx/include/__algorithm/partition_point.h
+++ b/libcxx/include/__algorithm/partition_point.h
@@ -9,8 +9,8 @@
#ifndef _LIBCPP___ALGORITHM_PARTITION_POINT_H
#define _LIBCPP___ALGORITHM_PARTITION_POINT_H
-#include <__config>
#include <__algorithm/half_positive.h>
+#include <__config>
#include <iterator>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/pop_heap.h b/libcxx/include/__algorithm/pop_heap.h
index e8c801a5c81f..c1cc8016ac91 100644
--- a/libcxx/include/__algorithm/pop_heap.h
+++ b/libcxx/include/__algorithm/pop_heap.h
@@ -9,10 +9,10 @@
#ifndef _LIBCPP___ALGORITHM_POP_HEAP_H
#define _LIBCPP___ALGORITHM_POP_HEAP_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/sift_down.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#include <__utility/swap.h>
@@ -31,7 +31,7 @@ __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare
if (__len > 1)
{
swap(*__first, *--__last);
- _VSTD::__sift_down<_Compare>(__first, __last, __comp, __len - 1, __first);
+ _VSTD::__sift_down<_Compare>(__first, __comp, __len - 1, __first);
}
}
diff --git a/libcxx/include/__algorithm/prev_permutation.h b/libcxx/include/__algorithm/prev_permutation.h
index 12c1816da37e..457c2695b324 100644
--- a/libcxx/include/__algorithm/prev_permutation.h
+++ b/libcxx/include/__algorithm/prev_permutation.h
@@ -9,10 +9,10 @@
#ifndef _LIBCPP___ALGORITHM_PREV_PERMUTATION_H
#define _LIBCPP___ALGORITHM_PREV_PERMUTATION_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/reverse.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#include <__utility/swap.h>
diff --git a/libcxx/include/__algorithm/push_heap.h b/libcxx/include/__algorithm/push_heap.h
index 9327fe05b51d..864d419fa203 100644
--- a/libcxx/include/__algorithm/push_heap.h
+++ b/libcxx/include/__algorithm/push_heap.h
@@ -9,9 +9,9 @@
#ifndef _LIBCPP___ALGORITHM_PUSH_HEAP_H
#define _LIBCPP___ALGORITHM_PUSH_HEAP_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#include <__utility/move.h>
diff --git a/libcxx/include/__algorithm/remove.h b/libcxx/include/__algorithm/remove.h
index 171d83284a2e..681b9cc768d9 100644
--- a/libcxx/include/__algorithm/remove.h
+++ b/libcxx/include/__algorithm/remove.h
@@ -9,9 +9,9 @@
#ifndef _LIBCPP___ALGORITHM_REMOVE_H
#define _LIBCPP___ALGORITHM_REMOVE_H
-#include <__config>
#include <__algorithm/find.h>
#include <__algorithm/find_if.h>
+#include <__config>
#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/remove_if.h b/libcxx/include/__algorithm/remove_if.h
index 4df36896afd5..36f817cfa6e1 100644
--- a/libcxx/include/__algorithm/remove_if.h
+++ b/libcxx/include/__algorithm/remove_if.h
@@ -9,8 +9,8 @@
#ifndef _LIBCPP___ALGORITHM_REMOVE_IF_H
#define _LIBCPP___ALGORITHM_REMOVE_IF_H
-#include <__config>
#include <__algorithm/find_if.h>
+#include <__config>
#include <utility>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/reverse.h b/libcxx/include/__algorithm/reverse.h
index 28bd2e84c8ae..1198aeaf41f4 100644
--- a/libcxx/include/__algorithm/reverse.h
+++ b/libcxx/include/__algorithm/reverse.h
@@ -9,8 +9,8 @@
#ifndef _LIBCPP___ALGORITHM_REVERSE_H
#define _LIBCPP___ALGORITHM_REVERSE_H
-#include <__config>
#include <__algorithm/iter_swap.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/rotate_copy.h b/libcxx/include/__algorithm/rotate_copy.h
index 4c682ef93d5a..f9e644c88d0e 100644
--- a/libcxx/include/__algorithm/rotate_copy.h
+++ b/libcxx/include/__algorithm/rotate_copy.h
@@ -9,10 +9,8 @@
#ifndef _LIBCPP___ALGORITHM_ROTATE_COPY_H
#define _LIBCPP___ALGORITHM_ROTATE_COPY_H
-#include <__config>
#include <__algorithm/copy.h>
-#include <iterator>
-#include <type_traits>
+#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
diff --git a/libcxx/include/__algorithm/search_n.h b/libcxx/include/__algorithm/search_n.h
index 67d066aa43d5..e4576cc76ac4 100644
--- a/libcxx/include/__algorithm/search_n.h
+++ b/libcxx/include/__algorithm/search_n.h
@@ -10,8 +10,8 @@
#ifndef _LIBCPP___ALGORITHM_SEARCH_N_H
#define _LIBCPP___ALGORITHM_SEARCH_N_H
-#include <__config>
#include <__algorithm/comp.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#include <type_traits> // __convert_to_integral
diff --git a/libcxx/include/__algorithm/set_difference.h b/libcxx/include/__algorithm/set_difference.h
index d4a9750d6dd7..00f61e070b4b 100644
--- a/libcxx/include/__algorithm/set_difference.h
+++ b/libcxx/include/__algorithm/set_difference.h
@@ -9,10 +9,10 @@
#ifndef _LIBCPP___ALGORITHM_SET_DIFFERENCE_H
#define _LIBCPP___ALGORITHM_SET_DIFFERENCE_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/copy.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/set_intersection.h b/libcxx/include/__algorithm/set_intersection.h
index 518e5e68b39d..f6aa38217d95 100644
--- a/libcxx/include/__algorithm/set_intersection.h
+++ b/libcxx/include/__algorithm/set_intersection.h
@@ -9,9 +9,9 @@
#ifndef _LIBCPP___ALGORITHM_SET_INTERSECTION_H
#define _LIBCPP___ALGORITHM_SET_INTERSECTION_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/set_symmetric_difference.h b/libcxx/include/__algorithm/set_symmetric_difference.h
index efdf62725709..5b5c2acff773 100644
--- a/libcxx/include/__algorithm/set_symmetric_difference.h
+++ b/libcxx/include/__algorithm/set_symmetric_difference.h
@@ -9,10 +9,10 @@
#ifndef _LIBCPP___ALGORITHM_SET_SYMMETRIC_DIFFERENCE_H
#define _LIBCPP___ALGORITHM_SET_SYMMETRIC_DIFFERENCE_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/copy.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/set_union.h b/libcxx/include/__algorithm/set_union.h
index 388f037a73a4..5b3e3af79b4f 100644
--- a/libcxx/include/__algorithm/set_union.h
+++ b/libcxx/include/__algorithm/set_union.h
@@ -9,10 +9,10 @@
#ifndef _LIBCPP___ALGORITHM_SET_UNION_H
#define _LIBCPP___ALGORITHM_SET_UNION_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/copy.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/shift_left.h b/libcxx/include/__algorithm/shift_left.h
index 8d9bc07d2e48..0466a3188a75 100644
--- a/libcxx/include/__algorithm/shift_left.h
+++ b/libcxx/include/__algorithm/shift_left.h
@@ -9,10 +9,10 @@
#ifndef _LIBCPP___ALGORITHM_SHIFT_LEFT_H
#define _LIBCPP___ALGORITHM_SHIFT_LEFT_H
-#include <__config>
#include <__algorithm/move.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
-#include <type_traits> // swap
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
diff --git a/libcxx/include/__algorithm/shift_right.h b/libcxx/include/__algorithm/shift_right.h
index cee17733a6a2..121712e85532 100644
--- a/libcxx/include/__algorithm/shift_right.h
+++ b/libcxx/include/__algorithm/shift_right.h
@@ -9,12 +9,13 @@
#ifndef _LIBCPP___ALGORITHM_SHIFT_RIGHT_H
#define _LIBCPP___ALGORITHM_SHIFT_RIGHT_H
-#include <__config>
#include <__algorithm/move.h>
#include <__algorithm/move_backward.h>
#include <__algorithm/swap_ranges.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
-#include <type_traits> // swap
+#include <__utility/swap.h>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
diff --git a/libcxx/include/__algorithm/sift_down.h b/libcxx/include/__algorithm/sift_down.h
index 4d99ff237c96..bf5447698cd6 100644
--- a/libcxx/include/__algorithm/sift_down.h
+++ b/libcxx/include/__algorithm/sift_down.h
@@ -21,8 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Compare, class _RandomAccessIterator>
_LIBCPP_CONSTEXPR_AFTER_CXX11 void
-__sift_down(_RandomAccessIterator __first, _RandomAccessIterator /*__last*/,
- _Compare __comp,
+__sift_down(_RandomAccessIterator __first, _Compare __comp,
typename iterator_traits<_RandomAccessIterator>::difference_type __len,
_RandomAccessIterator __start)
{
@@ -46,7 +45,7 @@ __sift_down(_RandomAccessIterator __first, _RandomAccessIterator /*__last*/,
// check if we are in heap-order
if (__comp(*__child_i, *__start))
- // we are, __start is larger than it's largest child
+ // we are, __start is larger than its largest child
return;
value_type __top(_VSTD::move(*__start));
diff --git a/libcxx/include/__algorithm/sort.h b/libcxx/include/__algorithm/sort.h
index bc127689a674..5e09b280080a 100644
--- a/libcxx/include/__algorithm/sort.h
+++ b/libcxx/include/__algorithm/sort.h
@@ -9,12 +9,12 @@
#ifndef _LIBCPP___ALGORITHM_SORT_H
#define _LIBCPP___ALGORITHM_SORT_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/min_element.h>
#include <__algorithm/partial_sort.h>
#include <__algorithm/unwrap_iter.h>
+#include <__config>
#include <__utility/swap.h>
#include <memory>
diff --git a/libcxx/include/__algorithm/sort_heap.h b/libcxx/include/__algorithm/sort_heap.h
index bf6200c2a08d..64291ff2e8c9 100644
--- a/libcxx/include/__algorithm/sort_heap.h
+++ b/libcxx/include/__algorithm/sort_heap.h
@@ -9,10 +9,10 @@
#ifndef _LIBCPP___ALGORITHM_SORT_HEAP_H
#define _LIBCPP___ALGORITHM_SORT_HEAP_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/pop_heap.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#include <type_traits> // swap
diff --git a/libcxx/include/__algorithm/stable_partition.h b/libcxx/include/__algorithm/stable_partition.h
index 323b323c53dd..331f0fde77dc 100644
--- a/libcxx/include/__algorithm/stable_partition.h
+++ b/libcxx/include/__algorithm/stable_partition.h
@@ -9,8 +9,8 @@
#ifndef _LIBCPP___ALGORITHM_STABLE_PARTITION_H
#define _LIBCPP___ALGORITHM_STABLE_PARTITION_H
-#include <__config>
#include <__algorithm/rotate.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#include <__utility/swap.h>
#include <memory>
diff --git a/libcxx/include/__algorithm/stable_sort.h b/libcxx/include/__algorithm/stable_sort.h
index 41e17bde99ef..4ae17e0e4d94 100644
--- a/libcxx/include/__algorithm/stable_sort.h
+++ b/libcxx/include/__algorithm/stable_sort.h
@@ -9,15 +9,15 @@
#ifndef _LIBCPP___ALGORITHM_STABLE_SORT_H
#define _LIBCPP___ALGORITHM_STABLE_SORT_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/inplace_merge.h>
#include <__algorithm/sort.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#include <__utility/swap.h>
#include <memory>
-#include <type_traits> // swap
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
diff --git a/libcxx/include/__algorithm/unique.h b/libcxx/include/__algorithm/unique.h
index 62f0490b6d63..e17ff1567fa9 100644
--- a/libcxx/include/__algorithm/unique.h
+++ b/libcxx/include/__algorithm/unique.h
@@ -9,9 +9,9 @@
#ifndef _LIBCPP___ALGORITHM_UNIQUE_H
#define _LIBCPP___ALGORITHM_UNIQUE_H
-#include <__config>
-#include <__algorithm/comp.h>
#include <__algorithm/adjacent_find.h>
+#include <__algorithm/comp.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#include <__utility/move.h>
diff --git a/libcxx/include/__algorithm/unique_copy.h b/libcxx/include/__algorithm/unique_copy.h
index 4c916dc3ada2..4833ae9b59f5 100644
--- a/libcxx/include/__algorithm/unique_copy.h
+++ b/libcxx/include/__algorithm/unique_copy.h
@@ -9,8 +9,8 @@
#ifndef _LIBCPP___ALGORITHM_UNIQUE_COPY_H
#define _LIBCPP___ALGORITHM_UNIQUE_COPY_H
-#include <__config>
#include <__algorithm/comp.h>
+#include <__config>
#include <__iterator/iterator_traits.h>
#include <utility>
diff --git a/libcxx/include/__algorithm/unwrap_iter.h b/libcxx/include/__algorithm/unwrap_iter.h
index f77ecca6eee6..35765330bb7f 100644
--- a/libcxx/include/__algorithm/unwrap_iter.h
+++ b/libcxx/include/__algorithm/unwrap_iter.h
@@ -10,8 +10,8 @@
#define _LIBCPP___ALGORITHM_UNWRAP_ITER_H
#include <__config>
-#include <iterator>
#include <__memory/pointer_traits.h>
+#include <iterator>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__algorithm/upper_bound.h b/libcxx/include/__algorithm/upper_bound.h
index 4ae7b8f9be1f..c064f1e35b9a 100644
--- a/libcxx/include/__algorithm/upper_bound.h
+++ b/libcxx/include/__algorithm/upper_bound.h
@@ -9,9 +9,9 @@
#ifndef _LIBCPP___ALGORITHM_UPPER_BOUND_H
#define _LIBCPP___ALGORITHM_UPPER_BOUND_H
-#include <__config>
#include <__algorithm/comp.h>
#include <__algorithm/half_positive.h>
+#include <__config>
#include <iterator>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)