Skip to content

Conversation

@philnik777
Copy link
Contributor

This reduces compile time and memory, since template variables are more efficient. NFC otherwise.

@github-actions
Copy link

github-actions bot commented May 12, 2025

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff origin/main HEAD --extensions ,h,cpp -- libcxx/include/__algorithm/equal.h libcxx/include/__algorithm/equal_range.h libcxx/include/__algorithm/find.h libcxx/include/__algorithm/includes.h libcxx/include/__algorithm/is_permutation.h libcxx/include/__algorithm/lexicographical_compare.h libcxx/include/__algorithm/lower_bound.h libcxx/include/__algorithm/max_element.h libcxx/include/__algorithm/min_element.h libcxx/include/__algorithm/minmax.h libcxx/include/__algorithm/minmax_element.h libcxx/include/__algorithm/mismatch.h libcxx/include/__algorithm/partial_sort_copy.h libcxx/include/__algorithm/search.h libcxx/include/__algorithm/search_n.h libcxx/include/__algorithm/upper_bound.h libcxx/include/__expected/expected.h libcxx/include/__expected/unexpected.h libcxx/include/__functional/bind.h libcxx/include/__hash_table libcxx/include/__mdspan/extents.h libcxx/include/__mdspan/layout_left.h libcxx/include/__mdspan/layout_right.h libcxx/include/__mdspan/layout_stride.h libcxx/include/__memory/shared_ptr.h libcxx/include/__random/discard_block_engine.h libcxx/include/__random/independent_bits_engine.h libcxx/include/__random/is_seed_sequence.h libcxx/include/__random/linear_congruential_engine.h libcxx/include/__random/mersenne_twister_engine.h libcxx/include/__random/shuffle_order_engine.h libcxx/include/__random/subtract_with_carry_engine.h libcxx/include/__string/constexpr_c_functions.h libcxx/include/__type_traits/invoke.h libcxx/include/__type_traits/is_callable.h libcxx/include/__type_traits/is_core_convertible.h libcxx/include/__type_traits/is_equality_comparable.h libcxx/include/__type_traits/is_reference_wrapper.h libcxx/include/__utility/in_place.h libcxx/include/__utility/is_pointer_in_range.h libcxx/include/any libcxx/include/cwchar libcxx/include/experimental/propagate_const libcxx/include/optional libcxx/include/span libcxx/include/valarray libcxx/include/variant libcxx/test/libcxx/type_traits/is_callable.compile.pass.cpp libcxx/test/libcxx/type_traits/is_trivially_comparable.compile.pass.cpp libcxx/test/libcxx/utilities/utility/__is_inplace_index.pass.cpp libcxx/test/libcxx/utilities/utility/__is_inplace_type.pass.cpp --diff_from_common_commit

⚠️
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing origin/main to the base branch/commit you want to compare against.
⚠️

View the diff from clang-format here.
diff --git a/libcxx/include/__algorithm/find.h b/libcxx/include/__algorithm/find.h
index 4541473f5..00616aac0 100644
--- a/libcxx/include/__algorithm/find.h
+++ b/libcxx/include/__algorithm/find.h
@@ -114,11 +114,10 @@ _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __find_vectorized(_Tp* __first, _Tp* __last,
 
 #ifndef _LIBCPP_CXX03_LANG
 // trivially equality comparable implementations
-template <
-    class _Tp,
-    class _Up,
-    class _Proj,
-    __enable_if_t<__is_identity<_Proj>::value && __is_trivially_equality_comparable_v<_Tp, _Up>, int> = 0>
+template < class _Tp,
+           class _Up,
+           class _Proj,
+           __enable_if_t<__is_identity<_Proj>::value && __is_trivially_equality_comparable_v<_Tp, _Up>, int> = 0>
 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __find(_Tp* __first, _Tp* __last, const _Up& __value, _Proj&) {
   if constexpr (sizeof(_Tp) == 1) {
     if (auto __ret = std::__constexpr_memchr(__first, __value, __last - __first))
diff --git a/libcxx/include/cwchar b/libcxx/include/cwchar
index 03db9e5fb..d41af176f 100644
--- a/libcxx/include/cwchar
+++ b/libcxx/include/cwchar
@@ -231,7 +231,7 @@ __constexpr_wmemcmp(const wchar_t* __lhs, const wchar_t* __rhs, size_t __count)
 
 template <class _Tp, class _Up>
 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp* __str, _Up __value, size_t __count) {
-  static_assert(sizeof(_Tp) == sizeof(wchar_t)&& _LIBCPP_ALIGNOF(_Tp) >= _LIBCPP_ALIGNOF(wchar_t) &&
+  static_assert(sizeof(_Tp) == sizeof(wchar_t) && _LIBCPP_ALIGNOF(_Tp) >= _LIBCPP_ALIGNOF(wchar_t) &&
                     __is_trivially_equality_comparable_v<_Tp, _Tp>,
                 "Calling wmemchr on non-trivially equality comparable types is unsafe.");
 

@philnik777 philnik777 force-pushed the use_template_variables branch 2 times, most recently from 8b3ad40 to c5cd751 Compare May 15, 2025 12:09
@philnik777 philnik777 force-pushed the use_template_variables branch from c5cd751 to d889b58 Compare June 8, 2025 14:50
@philnik777 philnik777 force-pushed the use_template_variables branch from d889b58 to 015399f Compare October 31, 2025 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant