From de6827b530d8b6fd85e6714af80eca3107c91ea2 Mon Sep 17 00:00:00 2001 From: Mark de Wever Date: Fri, 24 Feb 2023 21:35:41 +0100 Subject: [PATCH] [libc++] Improves clang-format settings. Add a new test based .clang-format file which inherits from the generic one. This moves some test specific formatting rules to the test directory. The main benefit is that headers are sorted, which makes it more likely to catch these errors before creating a review instead of spotting the error in the CI clang-tidy step. Reviewed By: ldionne, philnik, #libc Differential Revision: https://reviews.llvm.org/D144755 --- libcxx/.clang-format | 4 - libcxx/include/__chrono/convert_to_tm.h | 2 +- libcxx/include/__chrono/ostream.h | 19 +- libcxx/include/algorithm | 222 ++++++++++++------------ libcxx/include/functional | 55 +++--- libcxx/include/utility | 28 +-- libcxx/test/.clang-format | 5 + 7 files changed, 173 insertions(+), 162 deletions(-) create mode 100644 libcxx/test/.clang-format diff --git a/libcxx/.clang-format b/libcxx/.clang-format index 77ffa23435cc..68180bbef4c8 100644 --- a/libcxx/.clang-format +++ b/libcxx/.clang-format @@ -77,10 +77,6 @@ AlwaysBreakTemplateDeclarations: true PointerAlignment: Left -# Disable formatting options which may break tests. -SortIncludes: false -ReflowComments: false - # libc++'s preferred indentions of preprocessor statements. IndentPPDirectives: AfterHash diff --git a/libcxx/include/__chrono/convert_to_tm.h b/libcxx/include/__chrono/convert_to_tm.h index 5b71fc7bc729..951852fa98c6 100644 --- a/libcxx/include/__chrono/convert_to_tm.h +++ b/libcxx/include/__chrono/convert_to_tm.h @@ -136,7 +136,7 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& __value) { return __result; } -#endif //if _LIBCPP_STD_VER >= 20 +#endif // if _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__chrono/ostream.h b/libcxx/include/__chrono/ostream.h index 74d7e8544c95..23feb9d71130 100644 --- a/libcxx/include/__chrono/ostream.h +++ b/libcxx/include/__chrono/ostream.h @@ -106,15 +106,14 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const duration<_Rep, _Period>& template _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const day& __d) { - return __os - << (__d.ok() - ? std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:%d}"), __d) - // Note this error differs from the wording of the Standard. The - // Standard wording doesn't work well on AIX or Windows. There - // the formatted day seems to be either modulo 100 or completely - // omitted. Judging by the wording this is valid. - // TODO FMT Write a paper of file an LWG issue. - : std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:02} is not a valid day"), static_cast(__d))); + return __os << (__d.ok() ? std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:%d}"), __d) + // Note this error differs from the wording of the Standard. The + // Standard wording doesn't work well on AIX or Windows. There + // the formatted day seems to be either modulo 100 or completely + // omitted. Judging by the wording this is valid. + // TODO FMT Write a paper of file an LWG issue. + : std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:02} is not a valid day"), + static_cast(__d))); } template @@ -238,7 +237,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const hh_mm_ss<_Duration> __hms } // namespace chrono -#endif //if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) +#endif // if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm index 21d177cbb66f..75ba4b240dc0 100644 --- a/libcxx/include/algorithm +++ b/libcxx/include/algorithm @@ -22,41 +22,41 @@ namespace ranges { // [algorithms.results], algorithm result types template - struct in_fun_result; // since C++20 + struct in_fun_result; // since C++20 template - struct in_in_result; // since C++20 + struct in_in_result; // since C++20 template - struct in_out_result; // since C++20 + struct in_out_result; // since C++20 template - struct in_in_out_result; // since C++20 + struct in_in_out_result; // since C++20 template - struct in_out_out_result; // since C++20 + struct in_out_out_result; // since C++20 template - struct min_max_result; // since C++20 + struct min_max_result; // since C++20 template - struct in_found_result; // since C++20 + struct in_found_result; // since C++20 template S, class Proj = identity, - indirect_strict_weak_order> Comp = ranges::less> // since C++20 + indirect_strict_weak_order> Comp = ranges::less> // since C++20 constexpr I min_element(I first, S last, Comp comp = {}, Proj proj = {}); template, Proj>> Comp = ranges::less> // since C++20 + indirect_strict_weak_order, Proj>> Comp = ranges::less> // since C++20 constexpr borrowed_iterator_t min_element(R&& r, Comp comp = {}, Proj proj = {}); template S, class Proj = identity, indirect_strict_weak_order> Comp = ranges::less> - constexpr I ranges::max_element(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 + constexpr I ranges::max_element(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 template, Proj>> Comp = ranges::less> - constexpr borrowed_iterator_t ranges::max_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 + constexpr borrowed_iterator_t ranges::max_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 template using mismatch_result = in_in_result; @@ -64,86 +64,86 @@ namespace ranges { template S1, input_iterator I2, sentinel_for<_I2> S2, class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> requires indirectly_comparable - constexpr mismatch_result<_I1, _I2> - mismatch()(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20 + constexpr mismatch_result<_I1, _I2> // since C++20 + mismatch()(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) template requires indirectly_comparable, iterator_t, Pred, Proj1, Proj2> constexpr mismatch_result, borrowed_iterator_t> - mismatch(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20 + mismatch(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20 requires indirect_binary_predicate, const T*> - constexpr I find(I first, S last, const T& value, Proj proj = {}); // since C++20 + constexpr I find(I first, S last, const T& value, Proj proj = {}); // since C++20 template requires indirect_binary_predicate, Proj>, const T*> constexpr borrowed_iterator_t - find(R&& r, const T& value, Proj proj = {}); // since C++20 + find(R&& r, const T& value, Proj proj = {}); // since C++20 template S, class Proj = identity, indirect_unary_predicate> Pred> - constexpr I find_if(I first, S last, Pred pred, Proj proj = {}); // since C++20 + constexpr I find_if(I first, S last, Pred pred, Proj proj = {}); // since C++20 template, Proj>> Pred> constexpr borrowed_iterator_t - find_if(R&& r, Pred pred, Proj proj = {}); // since C++20 + find_if(R&& r, Pred pred, Proj proj = {}); // since C++20 template S, class Proj = identity, indirect_unary_predicate> Pred> - constexpr I find_if_not(I first, S last, Pred pred, Proj proj = {}); // since C++20 + constexpr I find_if_not(I first, S last, Pred pred, Proj proj = {}); // since C++20 template, Proj>> Pred> constexpr borrowed_iterator_t - find_if_not(R&& r, Pred pred, Proj proj = {}); // since C++20 + find_if_not(R&& r, Pred pred, Proj proj = {}); // since C++20 template> Comp = ranges::less> - constexpr const T& min(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20 + constexpr const T& min(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20 template> Comp = ranges::less> - constexpr T min(initializer_list r, Comp comp = {}, Proj proj = {}); // since C++20 + constexpr T min(initializer_list r, Comp comp = {}, Proj proj = {}); // since C++20 template, Proj>> Comp = ranges::less> requires indirectly_copyable_storable, range_value_t*> constexpr range_value_t - min(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 + min(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 template> Comp = ranges::less> - constexpr const T& max(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20 + constexpr const T& max(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20 template> Comp = ranges::less> - constexpr T max(initializer_list r, Comp comp = {}, Proj proj = {}); // since C++20 + constexpr T max(initializer_list r, Comp comp = {}, Proj proj = {}); // since C++20 template, Proj>> Comp = ranges::less> requires indirectly_copyable_storable, range_value_t*> constexpr range_value_t - max(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 + max(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 template - using unary_transform_result = in_out_result; // since C++20 + using unary_transform_result = in_out_result; // since C++20 template - using binary_transform_result = in_in_out_result; // since C++20 + using binary_transform_result = in_in_out_result; // since C++20 template S, weakly_incrementable O, copy_constructible F, class Proj = identity> requires indirectly_writable>> constexpr ranges::unary_transform_result - transform(I first1, S last1, O result, F op, Proj proj = {}); // since C++20 + transform(I first1, S last1, O result, F op, Proj proj = {}); // since C++20 template requires indirectly_writable, Proj>>> constexpr ranges::unary_transform_result, O> - transform(R&& r, O result, F op, Proj proj = {}); // since C++20 + transform(R&& r, O result, F op, Proj proj = {}); // since C++20 template S1, input_iterator I2, sentinel_for S2, weakly_incrementable O, copy_constructible F, class Proj1 = identity, @@ -152,7 +152,7 @@ namespace ranges { projected>> constexpr ranges::binary_transform_result transform(I1 first1, S1 last1, I2 first2, S2 last2, O result, - F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 + F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template @@ -160,27 +160,27 @@ namespace ranges { projected, Proj2>>> constexpr ranges::binary_transform_result, borrowed_iterator_t, O> transform(R1&& r1, R2&& r2, O result, - F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 + F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template S, class T, class Proj = identity> requires indirect_binary_predicate, const T*> constexpr iter_difference_t - count(I first, S last, const T& value, Proj proj = {}); // since C++20 + count(I first, S last, const T& value, Proj proj = {}); // since C++20 template requires indirect_binary_predicate, Proj>, const T*> constexpr range_difference_t - count(R&& r, const T& value, Proj proj = {}); // since C++20 + count(R&& r, const T& value, Proj proj = {}); // since C++20 template S, class Proj = identity, indirect_unary_predicate> Pred> constexpr iter_difference_t - count_if(I first, S last, Pred pred, Proj proj = {}); // since C++20 + count_if(I first, S last, Pred pred, Proj proj = {}); // since C++20 template, Proj>> Pred> constexpr range_difference_t - count_if(R&& r, Pred pred, Proj proj = {}); // since C++20 + count_if(R&& r, Pred pred, Proj proj = {}); // since C++20 template using minmax_result = min_max_result; @@ -188,18 +188,18 @@ namespace ranges { template> Comp = ranges::less> constexpr ranges::minmax_result - minmax(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20 + minmax(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20 template> Comp = ranges::less> constexpr ranges::minmax_result - minmax(initializer_list r, Comp comp = {}, Proj proj = {}); // since C++20 + minmax(initializer_list r, Comp comp = {}, Proj proj = {}); // since C++20 template, Proj>> Comp = ranges::less> requires indirectly_copyable_storable, range_value_t*> constexpr ranges::minmax_result> - minmax(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 + minmax(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 template using minmax_element_result = min_max_result; @@ -207,18 +207,18 @@ namespace ranges { template S, class Proj = identity, indirect_strict_weak_order> Comp = ranges::less> constexpr ranges::minmax_element_result - minmax_element(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 + minmax_element(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 template, Proj>> Comp = ranges::less> constexpr ranges::minmax_element_result> - minmax_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 + minmax_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 template - using copy_result = in_out_result; // since C++20 + using copy_result = in_out_result; // since C++20 template - using copy_n_result = in_out_result; // since C++20 + using copy_n_result = in_out_result; // since C++20 template using copy_if_result = in_out_result; // since C++20 @@ -333,20 +333,20 @@ namespace ranges { template S, class Proj = identity, indirect_strict_weak_order> Comp = ranges::less> - constexpr bool is_heap(I first, S last, Comp comp = {}, Proj proj = {}); // Since C++20 + constexpr bool is_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 template, Proj>> Comp = ranges::less> - constexpr bool is_heap(R&& r, Comp comp = {}, Proj proj = {}); // Since C++20 + constexpr bool is_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 template S, class Proj = identity, indirect_strict_weak_order> Comp = ranges::less> - constexpr I is_heap_until(I first, S last, Comp comp = {}, Proj proj = {}); // Since C++20 + constexpr I is_heap_until(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 template, Proj>> Comp = ranges::less> constexpr borrowed_iterator_t - is_heap_until(R&& r, Comp comp = {}, Proj proj = {}); // Since C++20 + is_heap_until(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 template S> requires permutable @@ -399,15 +399,15 @@ namespace ranges { template S, copy_constructible F> requires invocable && indirectly_writable> - constexpr O generate(O first, S last, F gen); // Since C++20 + constexpr O generate(O first, S last, F gen); // since C++20 template requires invocable && output_range> - constexpr borrowed_iterator_t generate(R&& r, F gen); // Since C++20 + constexpr borrowed_iterator_t generate(R&& r, F gen); // since C++20 template requires invocable && indirectly_writable> - constexpr O generate_n(O first, iter_difference_t n, F gen); // Since C++20 + constexpr O generate_n(O first, iter_difference_t n, F gen); // since C++20 template S1, input_iterator I2, sentinel_for S2, class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> @@ -424,27 +424,27 @@ namespace ranges { template S, class Proj = identity, indirect_unary_predicate> Pred> - constexpr bool ranges::all_of(I first, S last, Pred pred, Proj proj = {}); // since C++20 + constexpr bool ranges::all_of(I first, S last, Pred pred, Proj proj = {}); // since C++20 template, Proj>> Pred> - constexpr bool ranges::all_of(R&& r, Pred pred, Proj proj = {}); // since C++20 + constexpr bool ranges::all_of(R&& r, Pred pred, Proj proj = {}); // since C++20 template S, class Proj = identity, indirect_unary_predicate> Pred> - constexpr bool ranges::any_of(I first, S last, Pred pred, Proj proj = {}); // since C++20 + constexpr bool ranges::any_of(I first, S last, Pred pred, Proj proj = {}); // since C++20 template, Proj>> Pred> - constexpr bool ranges::any_of(R&& r, Pred pred, Proj proj = {}); // since C++20 + constexpr bool ranges::any_of(R&& r, Pred pred, Proj proj = {}); // since C++20 template S, class Proj = identity, indirect_unary_predicate> Pred> - constexpr bool ranges::none_of(I first, S last, Pred pred, Proj proj = {}); // since C++20 + constexpr bool ranges::none_of(I first, S last, Pred pred, Proj proj = {}); // since C++20 template, Proj>> Pred> - constexpr bool ranges::none_of(R&& r, Pred pred, Proj proj = {}); // since C++20 + constexpr bool ranges::none_of(R&& r, Pred pred, Proj proj = {}); // since C++20 template S1, random_access_iterator I2, sentinel_for S2, @@ -453,7 +453,7 @@ namespace ranges { indirect_strict_weak_order, projected> constexpr partial_sort_copy_result partial_sort_copy(I1 first, S1 last, I2 result_first, S2 result_last, - Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20 + Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template @@ -463,7 +463,7 @@ namespace ranges { projected, Proj2>> constexpr partial_sort_copy_result, borrowed_iterator_t> partial_sort_copy(R1&& r, R2&& result_r, Comp comp = {}, - Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20 + Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template S, class Proj = identity, indirect_strict_weak_order> Comp = ranges::less> @@ -486,64 +486,64 @@ namespace ranges { class Proj = identity> requires sortable constexpr I - ranges::nth_element(I first, I nth, S last, Comp comp = {}, Proj proj = {}); // since C++20 + ranges::nth_element(I first, I nth, S last, Comp comp = {}, Proj proj = {}); // since C++20 template requires sortable, Comp, Proj> constexpr borrowed_iterator_t - ranges::nth_element(R&& r, iterator_t nth, Comp comp = {}, Proj proj = {}); // since C++20 + ranges::nth_element(R&& r, iterator_t nth, Comp comp = {}, Proj proj = {}); // since C++20 template S, class T, class Proj = identity, - indirect_strict_weak_order> Comp = ranges::less> - constexpr I upper_bound(I first, S last, const T& value, Comp comp = {}, Proj proj = {}); // since C++20 + indirect_strict_weak_order> Comp = ranges::less> // since C++20 + constexpr I upper_bound(I first, S last, const T& value, Comp comp = {}, Proj proj = {}); template, Proj>> Comp = ranges::less> constexpr borrowed_iterator_t - upper_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20 + upper_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20 template S, class T, class Proj = identity, indirect_strict_weak_order> Comp = ranges::less> constexpr I lower_bound(I first, S last, const T& value, Comp comp = {}, - Proj proj = {}); // since C++20 + Proj proj = {}); // since C++20 template, Proj>> Comp = ranges::less> constexpr borrowed_iterator_t - lower_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20 + lower_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20 template S, class T, class Proj = identity, indirect_strict_weak_order> Comp = ranges::less> constexpr bool binary_search(I first, S last, const T& value, Comp comp = {}, - Proj proj = {}); // since C++20 + Proj proj = {}); // since C++20 template, Proj>> Comp = ranges::less> constexpr bool binary_search(R&& r, const T& value, Comp comp = {}, - Proj proj = {}); // since C++20 + Proj proj = {}); // since C++20 template S, class Proj = identity, indirect_unary_predicate> Pred> constexpr subrange - partition(I first, S last, Pred pred, Proj proj = {}); // Since C++20 + partition(I first, S last, Pred pred, Proj proj = {}); // since C++20 template, Proj>> Pred> requires permutable> constexpr borrowed_subrange_t - partition(R&& r, Pred pred, Proj proj = {}); // Since C++20 + partition(R&& r, Pred pred, Proj proj = {}); // since C++20 template S, class Proj = identity, indirect_unary_predicate> Pred> requires permutable - subrange stable_partition(I first, S last, Pred pred, Proj proj = {}); // Since C++20 + subrange stable_partition(I first, S last, Pred pred, Proj proj = {}); // since C++20 template, Proj>> Pred> requires permutable> - borrowed_subrange_t stable_partition(R&& r, Pred pred, Proj proj = {}); // Since C++20 + borrowed_subrange_t stable_partition(R&& r, Pred pred, Proj proj = {}); // since C++20 template S1, forward_iterator I2, sentinel_for S2, class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> @@ -563,7 +563,7 @@ namespace ranges { template S, class Proj = identity, indirect_binary_predicate, projected> Pred = ranges::equal_to> - constexpr I ranges::adjacent_find(I first, S last, Pred pred = {}, Proj proj = {}); // since C+20 + constexpr I ranges::adjacent_find(I first, S last, Pred pred = {}, Proj proj = {}); // since C++20 template, Proj>, @@ -604,7 +604,7 @@ namespace ranges { projected> Comp = ranges::less> constexpr bool ranges::lexicographical_compare(I1 first1, S1 last1, I2 first2, S2 last2, - Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 + Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template, Proj2>> Comp = ranges::less> constexpr bool ranges::lexicographical_compare(R1&& r1, R2&& r2, Comp comp = {}, - Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 + Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template S1, bidirectional_iterator I2> requires indirectly_movable @@ -643,7 +643,7 @@ namespace ranges { requires indirectly_copyable && indirectly_copyable constexpr partition_copy_result partition_copy(I first, S last, O1 out_true, O2 out_false, Pred pred, - Proj proj = {}); // Since C++20 + Proj proj = {}); // since C++20 template, O1> && indirectly_copyable, O2> constexpr partition_copy_result, O1, O2> - partition_copy(R&& r, O1 out_true, O2 out_false, Pred pred, Proj proj = {}); // Since C++20 + partition_copy(R&& r, O1 out_true, O2 out_false, Pred pred, Proj proj = {}); // since C++20 template S, class Proj = identity, indirect_unary_predicate> Pred> - constexpr I partition_point(I first, S last, Pred pred, Proj proj = {}); // Since C++20 + constexpr I partition_point(I first, S last, Pred pred, Proj proj = {}); // since C++20 template, Proj>> Pred> constexpr borrowed_iterator_t - partition_point(R&& r, Pred pred, Proj proj = {}); // Since C++20 + partition_point(R&& r, Pred pred, Proj proj = {}); // since C++20 template using merge_result = in_in_out_result; // since C++20 @@ -755,7 +755,7 @@ namespace ranges { template requires permutable> - constexpr borrowed_subrange_t rotate(R&& r, iterator_t middle); // Since C++20 + constexpr borrowed_subrange_t rotate(R&& r, iterator_t middle); // since C++20 template using rotate_copy_result = in_out_result<_InIter, _OutIter>; // since C++20 @@ -774,23 +774,23 @@ namespace ranges { requires (forward_iterator || random_access_iterator) && indirectly_copyable && uniform_random_bit_generator> - O sample(I first, S last, O out, iter_difference_t n, Gen&& g); // Since C++20 + O sample(I first, S last, O out, iter_difference_t n, Gen&& g); // since C++20 template requires (forward_range || random_access_iterator) && indirectly_copyable, O> && uniform_random_bit_generator> - O sample(R&& r, O out, range_difference_t n, Gen&& g); // Since C++20 + O sample(R&& r, O out, range_difference_t n, Gen&& g); // since C++20 template S, class Gen> requires permutable && uniform_random_bit_generator> - I shuffle(I first, S last, Gen&& g); // Since C++20 + I shuffle(I first, S last, Gen&& g); // since C++20 template requires permutable> && uniform_random_bit_generator> - borrowed_iterator_t shuffle(R&& r, Gen&& g); // Since C++20 + borrowed_iterator_t shuffle(R&& r, Gen&& g); // since C++20 template S1, forward_iterator I2, sentinel_for S2, class Proj1 = identity, class Proj2 = identity, @@ -798,14 +798,14 @@ namespace ranges { projected> Pred = ranges::equal_to> constexpr bool ranges::is_permutation(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, - Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20 + Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template, Proj1>, projected, Proj2>> Pred = ranges::equal_to> constexpr bool ranges::is_permutation(R1&& r1, R2&& r2, Pred pred = {}, - Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20 + Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template S1, forward_iterator I2, sentinel_for S2, class Pred = ranges::equal_to, @@ -904,35 +904,35 @@ namespace ranges { indirect_strict_weak_order, projected> Comp = ranges::less> constexpr bool includes(I1 first1, S1 last1, I2 first2, S2 last2, Comp comp = {}, - Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20 + Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template, Proj1>, projected, Proj2>> Comp = ranges::less> constexpr bool includes(R1&& r1, R2&& r2, Comp comp = {}, - Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20 + Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 template S, class Comp = ranges::less, class Proj = identity> requires sortable - I inplace_merge(I first, I middle, S last, Comp comp = {}, Proj proj = {}); // Since C++20 + I inplace_merge(I first, I middle, S last, Comp comp = {}, Proj proj = {}); // since C++20 template requires sortable, Comp, Proj> borrowed_iterator_t inplace_merge(R&& r, iterator_t middle, Comp comp = {}, - Proj proj = {}); // Since C++20 + Proj proj = {}); // since C++20 template S, class Proj = identity, indirect_equivalence_relation> C = ranges::equal_to> - constexpr subrange unique(I first, S last, C comp = {}, Proj proj = {}); // Since C++20 + constexpr subrange unique(I first, S last, C comp = {}, Proj proj = {}); // since C++20 template, Proj>> C = ranges::equal_to> requires permutable> constexpr borrowed_subrange_t - unique(R&& r, C comp = {}, Proj proj = {}); // Since C++20 + unique(R&& r, C comp = {}, Proj proj = {}); // since C++20 template S, weakly_incrementable O, class Proj = identity, indirect_equivalence_relation> C = ranges::equal_to> @@ -941,7 +941,7 @@ namespace ranges { (input_iterator && same_as, iter_value_t>) || indirectly_copyable_storable) constexpr unique_copy_result - unique_copy(I first, S last, O result, C comp = {}, Proj proj = {}); // Since C++20 + unique_copy(I first, S last, O result, C comp = {}, Proj proj = {}); // since C++20 template, Proj>> C = ranges::equal_to> @@ -950,41 +950,41 @@ namespace ranges { (input_iterator && same_as, iter_value_t>) || indirectly_copyable_storable, O>) constexpr unique_copy_result, O> - unique_copy(R&& r, O result, C comp = {}, Proj proj = {}); // Since C++20 + unique_copy(R&& r, O result, C comp = {}, Proj proj = {}); // since C++20 template - using remove_copy_result = in_out_result; // Since C++20 + using remove_copy_result = in_out_result; // since C++20 template S, weakly_incrementable O, class T, class Proj = identity> indirect_binary_predicate, const T*> constexpr remove_copy_result - remove_copy(I first, S last, O result, const T& value, Proj proj = {}); // Since C++20 + remove_copy(I first, S last, O result, const T& value, Proj proj = {}); // since C++20 template requires indirectly_copyable, O> && indirect_binary_predicate, Proj>, const T*> constexpr remove_copy_result, O> - remove_copy(R&& r, O result, const T& value, Proj proj = {}); // Since C++20 + remove_copy(R&& r, O result, const T& value, Proj proj = {}); // since C++20 template - using remove_copy_if_result = in_out_result; // Since C++20 + using remove_copy_if_result = in_out_result; // since C++20 template S, weakly_incrementable O, class Proj = identity, indirect_unary_predicate> Pred> requires indirectly_copyable constexpr remove_copy_if_result - remove_copy_if(I first, S last, O result, Pred pred, Proj proj = {}); // Since C++20 + remove_copy_if(I first, S last, O result, Pred pred, Proj proj = {}); // since C++20 template, Proj>> Pred> requires indirectly_copyable, O> constexpr remove_copy_if_result, O> - remove_copy_if(R&& r, O result, Pred pred, Proj proj = {}); // Since C++20 + remove_copy_if(R&& r, O result, Pred pred, Proj proj = {}); // since C++20 template - using replace_copy_result = in_out_result; // Since C++20 + using replace_copy_result = in_out_result; // since C++20 template S, class T1, class T2, output_iterator O, class Proj = identity> @@ -992,7 +992,7 @@ namespace ranges { indirect_binary_predicate, const T1*> constexpr replace_copy_result replace_copy(I first, S last, O result, const T1& old_value, const T2& new_value, - Proj proj = {}); // Since C++20 + Proj proj = {}); // since C++20 template O, class Proj = identity> @@ -1001,54 +1001,54 @@ namespace ranges { projected, Proj>, const T1*> constexpr replace_copy_result, O> replace_copy(R&& r, O result, const T1& old_value, const T2& new_value, - Proj proj = {}); // Since C++20 + Proj proj = {}); // since C++20 template - using replace_copy_if_result = in_out_result; // Since C++20 + using replace_copy_if_result = in_out_result; // since C++20 template S, class T, output_iterator O, class Proj = identity, indirect_unary_predicate> Pred> requires indirectly_copyable constexpr replace_copy_if_result replace_copy_if(I first, S last, O result, Pred pred, const T& new_value, - Proj proj = {}); // Since C++20 + Proj proj = {}); // since C++20 template O, class Proj = identity, indirect_unary_predicate, Proj>> Pred> requires indirectly_copyable, O> constexpr replace_copy_if_result, O> replace_copy_if(R&& r, O result, Pred pred, const T& new_value, - Proj proj = {}); // Since C++20 + Proj proj = {}); // since C++20 template - using prev_permutation_result = in_found_result; // Since C++20 + using prev_permutation_result = in_found_result; // since C++20 template S, class Comp = ranges::less, class Proj = identity> requires sortable constexpr ranges::prev_permutation_result - ranges::prev_permutation(I first, S last, Comp comp = {}, Proj proj = {}); // Since C++20 + ranges::prev_permutation(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 template requires sortable, Comp, Proj> constexpr ranges::prev_permutation_result> - ranges::prev_permutation(R&& r, Comp comp = {}, Proj proj = {}); // Since C++20 + ranges::prev_permutation(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 template - using next_permutation_result = in_found_result; // Since C++20 + using next_permutation_result = in_found_result; // since C++20 template S, class Comp = ranges::less, class Proj = identity> requires sortable constexpr ranges::next_permutation_result - ranges::next_permutation(I first, S last, Comp comp = {}, Proj proj = {}); // Since C++20 + ranges::next_permutation(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 template requires sortable, Comp, Proj> constexpr ranges::next_permutation_result> - ranges::next_permutation(R&& r, Comp comp = {}, Proj proj = {}); // Since C++20 + ranges::next_permutation(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 } diff --git a/libcxx/include/functional b/libcxx/include/functional index 23baa2cf6fe7..bb5db290f5a4 100644 --- a/libcxx/include/functional +++ b/libcxx/include/functional @@ -257,10 +257,10 @@ public: }; template -binder1st bind1st(const Operation& op, const T& x); // deprecated in C++11, removed in C++17 +binder1st bind1st(const Operation& op, const T& x); // deprecated in C++11, removed in C++17 template -class binder2nd // deprecated in C++11, removed in C++17 +class binder2nd // deprecated in C++11, removed in C++17 : public unary_function { @@ -274,9 +274,9 @@ public: }; template -binder2nd bind2nd(const Operation& op, const T& x); // deprecated in C++11, removed in C++17 +binder2nd bind2nd(const Operation& op, const T& x); // deprecated in C++11, removed in C++17 -template // deprecated in C++11, removed in C++17 +template // deprecated in C++11, removed in C++17 class pointer_to_unary_function : public unary_function { public: @@ -285,9 +285,9 @@ public: }; template -pointer_to_unary_function ptr_fun(Result (*f)(Arg)); // deprecated in C++11, removed in C++17 +pointer_to_unary_function ptr_fun(Result (*f)(Arg)); // deprecated in C++11, removed in C++17 -template // deprecated in C++11, removed in C++17 +template // deprecated in C++11, removed in C++17 class pointer_to_binary_function : public binary_function { public: @@ -296,9 +296,9 @@ public: }; template -pointer_to_binary_function ptr_fun(Result (*f)(Arg1,Arg2)); // deprecated in C++11, removed in C++17 +pointer_to_binary_function ptr_fun(Result (*f)(Arg1,Arg2)); // deprecated in C++11, removed in C++17 -template // deprecated in C++11, removed in C++17 +template // deprecated in C++11, removed in C++17 class mem_fun_t : public unary_function { public: @@ -307,18 +307,18 @@ public: }; template -class mem_fun1_t : public binary_function // deprecated in C++11, removed in C++17 +class mem_fun1_t : public binary_function // deprecated in C++11, removed in C++17 { public: explicit mem_fun1_t(S (T::*p)(A)); S operator()(T* p, A x) const; }; -template mem_fun_t mem_fun(S (T::*f)()); // deprecated in C++11, removed in C++17 -template mem_fun1_t mem_fun(S (T::*f)(A)); // deprecated in C++11, removed in C++17 +template mem_fun_t mem_fun(S (T::*f)()); // deprecated in C++11, removed in C++17 +template mem_fun1_t mem_fun(S (T::*f)(A)); // deprecated in C++11, removed in C++17 template -class mem_fun_ref_t : public unary_function // deprecated in C++11, removed in C++17 +class mem_fun_ref_t : public unary_function // deprecated in C++11, removed in C++17 { public: explicit mem_fun_ref_t(S (T::*p)()); @@ -326,18 +326,20 @@ public: }; template -class mem_fun1_ref_t : public binary_function // deprecated in C++11, removed in C++17 +class mem_fun1_ref_t : public binary_function // deprecated in C++11, removed in C++17 { public: explicit mem_fun1_ref_t(S (T::*p)(A)); S operator()(T& p, A x) const; }; -template mem_fun_ref_t mem_fun_ref(S (T::*f)()); // deprecated in C++11, removed in C++17 -template mem_fun1_ref_t mem_fun_ref(S (T::*f)(A)); // deprecated in C++11, removed in C++17 +template +mem_fun_ref_t mem_fun_ref(S (T::*f)()); // deprecated in C++11, removed in C++17 +template +mem_fun1_ref_t mem_fun_ref(S (T::*f)(A)); // deprecated in C++11, removed in C++17 template -class const_mem_fun_t : public unary_function // deprecated in C++11, removed in C++17 +class const_mem_fun_t : public unary_function // deprecated in C++11, removed in C++17 { public: explicit const_mem_fun_t(S (T::*p)() const); @@ -345,18 +347,20 @@ public: }; template -class const_mem_fun1_t : public binary_function // deprecated in C++11, removed in C++17 +class const_mem_fun1_t : public binary_function // deprecated in C++11, removed in C++17 { public: explicit const_mem_fun1_t(S (T::*p)(A) const); S operator()(const T* p, A x) const; }; -template const_mem_fun_t mem_fun(S (T::*f)() const); // deprecated in C++11, removed in C++17 -template const_mem_fun1_t mem_fun(S (T::*f)(A) const); // deprecated in C++11, removed in C++17 +template +const_mem_fun_t mem_fun(S (T::*f)() const); // deprecated in C++11, removed in C++17 +template +const_mem_fun1_t mem_fun(S (T::*f)(A) const); // deprecated in C++11, removed in C++17 template -class const_mem_fun_ref_t : public unary_function // deprecated in C++11, removed in C++17 +class const_mem_fun_ref_t : public unary_function // deprecated in C++11, removed in C++17 { public: explicit const_mem_fun_ref_t(S (T::*p)() const); @@ -364,18 +368,19 @@ public: }; template -class const_mem_fun1_ref_t : public binary_function // deprecated in C++11, removed in C++17 +class const_mem_fun1_ref_t : public binary_function // deprecated in C++11, removed in C++17 { public: explicit const_mem_fun1_ref_t(S (T::*p)(A) const); S operator()(const T& p, A x) const; }; -template const_mem_fun_ref_t mem_fun_ref(S (T::*f)() const); // deprecated in C++11, removed in C++17 -template const_mem_fun1_ref_t mem_fun_ref(S (T::*f)(A) const); // deprecated in C++11, removed in C++17 +template +const_mem_fun_ref_t mem_fun_ref(S (T::*f)() const); // deprecated in C++11, removed in C++17 +template +const_mem_fun1_ref_t mem_fun_ref(S (T::*f)(A) const); // deprecated in C++11, removed in C++17 -template -constexpr unspecified mem_fn(R T::*); // constexpr in C++20 +template constexpr unspecified mem_fn(R T::*); // constexpr in C++20 class bad_function_call : public exception diff --git a/libcxx/include/utility b/libcxx/include/utility index a4d8cf853d20..845b542132d3 100644 --- a/libcxx/include/utility +++ b/libcxx/include/utility @@ -117,24 +117,30 @@ struct common_type, pair>; template pair(T1, T2) -> pair; -template bool operator==(const pair&, const pair&); // constexpr in C++14 -template bool operator!=(const pair&, const pair&); // constexpr in C++14, removed in C++20 -template bool operator< (const pair&, const pair&); // constexpr in C++14, removed in C++20 -template bool operator> (const pair&, const pair&); // constexpr in C++14, removed in C++20 -template bool operator>=(const pair&, const pair&); // constexpr in C++14, removed in C++20 -template bool operator<=(const pair&, const pair&); // constexpr in C++14, removed in C++20 +template +bool operator==(const pair&, const pair&); // constexpr in C++14 +template +bool operator!=(const pair&, const pair&); // constexpr in C++14, removed in C++20 +template +bool operator< (const pair&, const pair&); // constexpr in C++14, removed in C++20 +template +bool operator> (const pair&, const pair&); // constexpr in C++14, removed in C++20 +template +bool operator>=(const pair&, const pair&); // constexpr in C++14, removed in C++20 +template +bool operator<=(const pair&, const pair&); // constexpr in C++14, removed in C++20 template constexpr common_comparison_type_t, synth-three-way-result> - operator<=>(const pair&, const pair&); // C++20 + operator<=>(const pair&, const pair&); // C++20 template pair make_pair(T1&&, T2&&); // constexpr in C++14 template void swap(pair& x, pair& y) noexcept(noexcept(x.swap(y))); // constexpr in C++20 -template -constexpr void swap(const pair& x, const pair& y) noexcept(noexcept(x.swap(y))); // since C++23 +template // since C++23 +constexpr void swap(const pair& x, const pair& y) noexcept(noexcept(x.swap(y))); struct piecewise_construct_t { explicit piecewise_construct_t() = default; }; inline constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t(); @@ -208,8 +214,8 @@ template using index_sequence_for = make_index_sequence; template - constexpr T exchange(T& obj, U&& new_value) - noexcept(is_nothrow_move_constructible::value && is_nothrow_assignable::value); // constexpr in C++17, noexcept in C++23 + constexpr T exchange(T& obj, U&& new_value) // constexpr in C++17, noexcept in C++23 + noexcept(is_nothrow_move_constructible::value && is_nothrow_assignable::value); // 20.2.7, in-place construction // C++17 struct in_place_t { diff --git a/libcxx/test/.clang-format b/libcxx/test/.clang-format new file mode 100644 index 000000000000..b446ff718d7a --- /dev/null +++ b/libcxx/test/.clang-format @@ -0,0 +1,5 @@ +BasedOnStyle: InheritParentConfig + +# Disable formatting options which may break tests. +SortIncludes: false +ReflowComments: false