diff --git a/libcxx/.clang-tidy b/libcxx/.clang-tidy --- a/libcxx/.clang-tidy +++ b/libcxx/.clang-tidy @@ -50,6 +50,14 @@ value: lower_case - key: readability-identifier-naming.LocalVariablePrefix value: __ + - key: readability-identifier-naming.TemplateParameterCase + value: CamelCase + - key: readability-identifier-naming.TemplateParameterPrefix + value: _ + - key: readability-identifier-naming.TemplateParameterIgnoredRegexp + value: (.*\:auto|expr-type) # This is https://llvm.org/PR56464 + - key: readability-identifier-naming.ValueTemplateParameterIgnoredRegexp # TODO: enforce naming of variable parameters + value: .* # TODO: investigate these checks # bugprone-branch-clone, diff --git a/libcxx/include/__bit_reference b/libcxx/include/__bit_reference --- a/libcxx/include/__bit_reference +++ b/libcxx/include/__bit_reference @@ -731,12 +731,12 @@ // swap_ranges -template -_LIBCPP_HIDE_FROM_ABI __bit_iterator<__C2, false> -__swap_ranges_aligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1, false> __last, - __bit_iterator<__C2, false> __result) +template +_LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cr, false> +__swap_ranges_aligned(__bit_iterator<_Cl, false> __first, __bit_iterator<_Cl, false> __last, + __bit_iterator<_Cr, false> __result) { - typedef __bit_iterator<__C1, false> _I1; + typedef __bit_iterator<_Cl, false> _I1; typedef typename _I1::difference_type difference_type; typedef typename _I1::__storage_type __storage_type; const int __bits_per_word = _I1::__bits_per_word; @@ -781,12 +781,12 @@ return __result; } -template -_LIBCPP_HIDE_FROM_ABI __bit_iterator<__C2, false> -__swap_ranges_unaligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1, false> __last, - __bit_iterator<__C2, false> __result) +template +_LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cr, false> +__swap_ranges_unaligned(__bit_iterator<_Cl, false> __first, __bit_iterator<_Cl, false> __last, + __bit_iterator<_Cr, false> __result) { - typedef __bit_iterator<__C1, false> _I1; + typedef __bit_iterator<_Cl, false> _I1; typedef typename _I1::difference_type difference_type; typedef typename _I1::__storage_type __storage_type; const int __bits_per_word = _I1::__bits_per_word; @@ -881,11 +881,11 @@ return __result; } -template +template inline _LIBCPP_INLINE_VISIBILITY -__bit_iterator<__C2, false> -swap_ranges(__bit_iterator<__C1, false> __first1, __bit_iterator<__C1, false> __last1, - __bit_iterator<__C2, false> __first2) +__bit_iterator<_Cr, false> +swap_ranges(__bit_iterator<_Cl, false> __first1, __bit_iterator<_Cl, false> __last1, + __bit_iterator<_Cr, false> __first2) { if (__first1.__ctz_ == __first2.__ctz_) return _VSTD::__swap_ranges_aligned(__first1, __last1, __first2); @@ -1314,15 +1314,15 @@ friend __bit_iterator<_Dp, false> copy_backward(__bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result); - template friend __bit_iterator<__C2, false> __swap_ranges_aligned(__bit_iterator<__C1, false>, - __bit_iterator<__C1, false>, - __bit_iterator<__C2, false>); - template friend __bit_iterator<__C2, false> __swap_ranges_unaligned(__bit_iterator<__C1, false>, - __bit_iterator<__C1, false>, - __bit_iterator<__C2, false>); - template friend __bit_iterator<__C2, false> swap_ranges(__bit_iterator<__C1, false>, - __bit_iterator<__C1, false>, - __bit_iterator<__C2, false>); + template friend __bit_iterator<_Cr, false> __swap_ranges_aligned(__bit_iterator<_Cl, false>, + __bit_iterator<_Cl, false>, + __bit_iterator<_Cr, false>); + template friend __bit_iterator<_Cr, false> __swap_ranges_unaligned(__bit_iterator<_Cl, false>, + __bit_iterator<_Cl, false>, + __bit_iterator<_Cr, false>); + template friend __bit_iterator<_Cr, false> swap_ranges(__bit_iterator<_Cl, false>, + __bit_iterator<_Cl, false>, + __bit_iterator<_Cr, false>); template _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> rotate(__bit_iterator<_Dp, false>, diff --git a/libcxx/include/__chrono/calendar.h b/libcxx/include/__chrono/calendar.h --- a/libcxx/include/__chrono/calendar.h +++ b/libcxx/include/__chrono/calendar.h @@ -26,8 +26,8 @@ { struct local_t {}; -template -using local_time = time_point; +template +using local_time = time_point; using local_seconds = local_time; using local_days = local_time; diff --git a/libcxx/include/__format/format_context.h b/libcxx/include/__format/format_context.h --- a/libcxx/include/__format/format_context.h +++ b/libcxx/include/__format/format_context.h @@ -120,9 +120,9 @@ // TODO FMT Validate whether lazy creation is the best solution. optional<_VSTD::locale> __loc_; - template - friend _LIBCPP_HIDE_FROM_ABI basic_format_context<__OutIt, __CharT> - __format_context_create(__OutIt, basic_format_args>, + template + friend _LIBCPP_HIDE_FROM_ABI basic_format_context<_OtherOutIt, _OtherCharT> + __format_context_create(_OtherOutIt, basic_format_args>, optional<_VSTD::locale>&&); // Note: the Standard doesn't specify the required constructors. @@ -133,9 +133,9 @@ : __out_it_(_VSTD::move(__out_it)), __args_(__args), __loc_(_VSTD::move(__loc)) {} #else - template - friend _LIBCPP_HIDE_FROM_ABI basic_format_context<__OutIt, __CharT> - __format_context_create(__OutIt, basic_format_args>); + template + friend _LIBCPP_HIDE_FROM_ABI basic_format_context<_OtherOutIt, _OtherCharT> + __format_context_create(_OtherOutIt, basic_format_args>); _LIBCPP_HIDE_FROM_ABI explicit basic_format_context(_OutIt __out_it, diff --git a/libcxx/include/__format/range_default_formatter.h b/libcxx/include/__format/range_default_formatter.h --- a/libcxx/include/__format/range_default_formatter.h +++ b/libcxx/include/__format/range_default_formatter.h @@ -111,8 +111,9 @@ return __underlying_.parse(__ctx); } - template - _LIBCPP_HIDE_FROM_ABI typename FormatContext::iterator format(__maybe_const_r& __range, FormatContext& __ctx) const { + template + _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator + format(__maybe_const_r& __range, _FormatContext& __ctx) const { return __underlying_.format(__range, __ctx); } }; diff --git a/libcxx/include/__functional/binder1st.h b/libcxx/include/__functional/binder1st.h --- a/libcxx/include/__functional/binder1st.h +++ b/libcxx/include/__functional/binder1st.h @@ -21,30 +21,30 @@ #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) -template +template class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder1st - : public __unary_function + : public __unary_function { protected: - __Operation op; - typename __Operation::first_argument_type value; + _Operation op; + typename _Operation::first_argument_type value; public: - _LIBCPP_INLINE_VISIBILITY binder1st(const __Operation& __x, - const typename __Operation::first_argument_type __y) + _LIBCPP_INLINE_VISIBILITY binder1st(const _Operation& __x, + const typename _Operation::first_argument_type __y) : op(__x), value(__y) {} - _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() - (typename __Operation::second_argument_type& __x) const + _LIBCPP_INLINE_VISIBILITY typename _Operation::result_type operator() + (typename _Operation::second_argument_type& __x) const {return op(value, __x);} - _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() - (const typename __Operation::second_argument_type& __x) const + _LIBCPP_INLINE_VISIBILITY typename _Operation::result_type operator() + (const typename _Operation::second_argument_type& __x) const {return op(value, __x);} }; -template +template _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY -binder1st<__Operation> -bind1st(const __Operation& __op, const _Tp& __x) - {return binder1st<__Operation>(__op, __x);} +binder1st<_Operation> +bind1st(const _Operation& __op, const _Tp& __x) + {return binder1st<_Operation>(__op, __x);} #endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) diff --git a/libcxx/include/__functional/binder2nd.h b/libcxx/include/__functional/binder2nd.h --- a/libcxx/include/__functional/binder2nd.h +++ b/libcxx/include/__functional/binder2nd.h @@ -21,30 +21,30 @@ #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) -template +template class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder2nd - : public __unary_function + : public __unary_function { protected: - __Operation op; - typename __Operation::second_argument_type value; + _Operation op; + typename _Operation::second_argument_type value; public: _LIBCPP_INLINE_VISIBILITY - binder2nd(const __Operation& __x, const typename __Operation::second_argument_type __y) + binder2nd(const _Operation& __x, const typename _Operation::second_argument_type __y) : op(__x), value(__y) {} - _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() - ( typename __Operation::first_argument_type& __x) const + _LIBCPP_INLINE_VISIBILITY typename _Operation::result_type operator() + ( typename _Operation::first_argument_type& __x) const {return op(__x, value);} - _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() - (const typename __Operation::first_argument_type& __x) const + _LIBCPP_INLINE_VISIBILITY typename _Operation::result_type operator() + (const typename _Operation::first_argument_type& __x) const {return op(__x, value);} }; -template +template _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY -binder2nd<__Operation> -bind2nd(const __Operation& __op, const _Tp& __x) - {return binder2nd<__Operation>(__op, __x);} +binder2nd<_Operation> +bind2nd(const _Operation& __op, const _Tp& __x) + {return binder2nd<_Operation>(__op, __x);} #endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) diff --git a/libcxx/include/__fwd/mdspan.h b/libcxx/include/__fwd/mdspan.h --- a/libcxx/include/__fwd/mdspan.h +++ b/libcxx/include/__fwd/mdspan.h @@ -32,13 +32,13 @@ // Layout policy with a mapping which corresponds to FORTRAN-style array layouts struct layout_left { - template + template class mapping; }; // Layout policy with a mapping which corresponds to C-style array layouts struct layout_right { - template + template class mapping; }; diff --git a/libcxx/include/__stop_token/stop_callback.h b/libcxx/include/__stop_token/stop_callback.h --- a/libcxx/include/__stop_token/stop_callback.h +++ b/libcxx/include/__stop_token/stop_callback.h @@ -89,8 +89,8 @@ } }; -template -_LIBCPP_AVAILABILITY_SYNC stop_callback(stop_token, Callback) -> stop_callback; +template +_LIBCPP_AVAILABILITY_SYNC stop_callback(stop_token, _Callback) -> stop_callback<_Callback>; #endif // _LIBCPP_STD_VER >= 20 diff --git a/libcxx/include/experimental/propagate_const b/libcxx/include/experimental/propagate_const --- a/libcxx/include/experimental/propagate_const +++ b/libcxx/include/experimental/propagate_const @@ -284,8 +284,8 @@ return get(); } - template ::value>> + template ::value>> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR operator const element_type *() const { return get(); } @@ -300,8 +300,8 @@ return get(); } - template ::value>> + template ::value>> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR operator element_type *() { return get(); } diff --git a/libcxx/include/experimental/type_traits b/libcxx/include/experimental/type_traits --- a/libcxx/include/experimental/type_traits +++ b/libcxx/include/experimental/type_traits @@ -132,20 +132,20 @@ template class _Op, class... _Args> _LIBCPP_CONSTEXPR bool is_detected_v = is_detected<_Op, _Args...>::value; -template class _Op, class... _Args> - using detected_or = _DETECTOR; -template class _Op, class... _Args> - using detected_or_t = typename detected_or::type; - -template class _Op, class... _Args> - using is_detected_exact = is_same>; -template class _Op, class... _Args> - _LIBCPP_CONSTEXPR bool is_detected_exact_v = is_detected_exact::value; - -template class _Op, class... _Args> - using is_detected_convertible = is_convertible, To>; -template class _Op, class... _Args> - _LIBCPP_CONSTEXPR bool is_detected_convertible_v = is_detected_convertible::value; +template class _Op, class... _Args> + using detected_or = _DETECTOR<_Default, void, _Op, _Args...>; +template class _Op, class... _Args> + using detected_or_t = typename detected_or<_Default, _Op, _Args...>::type; + +template class _Op, class... _Args> + using is_detected_exact = is_same<_Expected, detected_t<_Op, _Args...>>; +template class _Op, class... _Args> + _LIBCPP_CONSTEXPR bool is_detected_exact_v = is_detected_exact<_Expected, _Op, _Args...>::value; + +template class _Op, class... _Args> + using is_detected_convertible = is_convertible, _To>; +template class _Op, class... _Args> + _LIBCPP_CONSTEXPR bool is_detected_convertible_v = is_detected_convertible<_To, _Op, _Args...>::value; _LIBCPP_END_NAMESPACE_LFTS diff --git a/libcxx/include/locale b/libcxx/include/locale --- a/libcxx/include/locale +++ b/libcxx/include/locale @@ -3593,15 +3593,15 @@ #endif template, - class _Byte_alloc = allocator > + class _WideAlloc = allocator<_Elem>, + class _ByteAlloc = allocator > class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 wstring_convert { public: - typedef basic_string, _Byte_alloc> byte_string; - typedef basic_string<_Elem, char_traits<_Elem>, _Wide_alloc> wide_string; - typedef typename _Codecvt::state_type state_type; - typedef typename wide_string::traits_type::int_type int_type; + typedef basic_string, _ByteAlloc> byte_string; + typedef basic_string<_Elem, char_traits<_Elem>, _WideAlloc> wide_string; + typedef typename _Codecvt::state_type state_type; + typedef typename wide_string::traits_type::int_type int_type; private: byte_string __byte_err_string_; @@ -3663,25 +3663,25 @@ }; _LIBCPP_SUPPRESS_DEPRECATED_PUSH -template +template inline -wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: +wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>:: wstring_convert(_Codecvt* __pcvt) : __cvtptr_(__pcvt), __cvtstate_(), __cvtcount_(0) { } _LIBCPP_SUPPRESS_DEPRECATED_POP -template +template inline -wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: +wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>:: wstring_convert(_Codecvt* __pcvt, state_type __state) : __cvtptr_(__pcvt), __cvtstate_(__state), __cvtcount_(0) { } -template -wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: +template +wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>:: wstring_convert(const byte_string& __byte_err, const wide_string& __wide_err) : __byte_err_string_(__byte_err), __wide_err_string_(__wide_err), __cvtstate_(), __cvtcount_(0) @@ -3691,9 +3691,9 @@ #ifndef _LIBCPP_CXX03_LANG -template +template inline -wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: +wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>:: wstring_convert(wstring_convert&& __wc) : __byte_err_string_(_VSTD::move(__wc.__byte_err_string_)), __wide_err_string_(_VSTD::move(__wc.__wide_err_string_)), @@ -3706,15 +3706,15 @@ #endif // _LIBCPP_CXX03_LANG _LIBCPP_SUPPRESS_DEPRECATED_PUSH -template -wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::~wstring_convert() +template +wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::~wstring_convert() { delete __cvtptr_; } -template -typename wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::wide_string -wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: +template +typename wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wide_string +wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>:: from_bytes(const char* __frm, const char* __frm_end) { _LIBCPP_SUPPRESS_DEPRECATED_POP @@ -3774,9 +3774,9 @@ return __wide_err_string_; } -template -typename wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::byte_string -wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: +template +typename wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::byte_string +wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>:: to_bytes(const _Elem* __frm, const _Elem* __frm_end) { __cvtcount_ = 0; diff --git a/libcxx/include/optional b/libcxx/include/optional --- a/libcxx/include/optional +++ b/libcxx/include/optional @@ -683,7 +683,7 @@ #if _LIBCPP_STD_VER >= 20 template -concept __is_derived_from_optional = requires(const _Tp& __t) { [](const optional<__Up>&) {}(__t); }; +concept __is_derived_from_optional = requires(const _Tp& __t) { [](const optional<_Up>&) {}(__t); }; # endif // _LIBCPP_STD_VER >= 20 diff --git a/libcxx/include/queue b/libcxx/include/queue --- a/libcxx/include/queue +++ b/libcxx/include/queue @@ -453,17 +453,17 @@ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } - template + template friend _LIBCPP_INLINE_VISIBILITY bool - operator==(const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y); + operator==(const queue<_T1, _OtherContainer>& __x,const queue<_T1, _OtherContainer>& __y); - template + template friend _LIBCPP_INLINE_VISIBILITY bool - operator< (const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y); + operator< (const queue<_T1, _OtherContainer>& __x,const queue<_T1, _OtherContainer>& __y); }; #if _LIBCPP_STD_VER >= 17 diff --git a/libcxx/include/semaphore b/libcxx/include/semaphore --- a/libcxx/include/semaphore +++ b/libcxx/include/semaphore @@ -116,11 +116,11 @@ }; __cxx_atomic_wait(&__a_.__a_, __test_fn); } - template + template _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY - bool try_acquire_for(chrono::duration const& __rel_time) + bool try_acquire_for(chrono::duration<_Rep, _Period> const& __rel_time) { - if (__rel_time == chrono::duration::zero()) + if (__rel_time == chrono::duration<_Rep, _Period>::zero()) return try_acquire(); auto const __test_fn = [this]() { return try_acquire(); }; return std::__libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy(), __rel_time); @@ -178,9 +178,9 @@ { __semaphore_.acquire(); } - template + template _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY - bool try_acquire_for(chrono::duration const& __rel_time) + bool try_acquire_for(chrono::duration<_Rep, _Period> const& __rel_time) { return __semaphore_.try_acquire_for(chrono::duration_cast(__rel_time)); } @@ -189,11 +189,11 @@ { return __semaphore_.try_acquire(); } - template + template _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY - bool try_acquire_until(chrono::time_point const& __abs_time) + bool try_acquire_until(chrono::time_point<_Clock, _Duration> const& __abs_time) { - auto const __current = Clock::now(); + auto const __current = _Clock::now(); if (__current >= __abs_time) return try_acquire(); else diff --git a/libcxx/include/shared_mutex b/libcxx/include/shared_mutex --- a/libcxx/include/shared_mutex +++ b/libcxx/include/shared_mutex @@ -370,10 +370,10 @@ _LIBCPP_HIDE_FROM_ABI void lock(); _LIBCPP_HIDE_FROM_ABI bool try_lock(); - template - _LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration& __rel_time); - template - _LIBCPP_HIDE_FROM_ABI bool try_lock_until(const chrono::time_point& __abs_time); + template + _LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __rel_time); + template + _LIBCPP_HIDE_FROM_ABI bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __abs_time); _LIBCPP_HIDE_FROM_ABI void unlock(); // Setters diff --git a/libcxx/include/stack b/libcxx/include/stack --- a/libcxx/include/stack +++ b/libcxx/include/stack @@ -304,15 +304,15 @@ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } - template + template friend bool - operator==(const stack& __x, const stack& __y); + operator==(const stack<_T1, _OtherContainer>& __x, const stack<_T1, _OtherContainer>& __y); - template + template friend bool - operator< (const stack& __x, const stack& __y); + operator< (const stack<_T1, _OtherContainer>& __x, const stack<_T1, _OtherContainer>& __y); }; #if _LIBCPP_STD_VER >= 17 diff --git a/libcxx/include/tuple b/libcxx/include/tuple --- a/libcxx/include/tuple +++ b/libcxx/include/tuple @@ -960,13 +960,13 @@ // tuple(const pair&) constructors (including allocator_arg_t variants) - template