[libc++][NFC] Simplify some overloads in fs::path a bit (#181053)

We can use `if constexpr` instead, removing a bit of code and making
things easier to read.
This commit is contained in:
Nikolas Klauser 2026-02-13 10:50:17 +01:00 committed by GitHub
parent 900fac763f
commit a7a249f072
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -259,15 +259,14 @@ struct _PathCVT {
template <>
struct _PathCVT<__path_value> {
template <class _Iter, __enable_if_t<__has_exactly_input_iterator_category<_Iter>::value, int> = 0>
template <class _Iter>
_LIBCPP_HIDE_FROM_ABI static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
for (; __b != __e; ++__b)
__dest.push_back(*__b);
}
template <class _Iter, __enable_if_t<__has_forward_iterator_category<_Iter>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
__dest.append(__b, __e);
if constexpr (__has_forward_iterator_category<_Iter>::value) {
__dest.append(__b, __e);
} else {
for (; __b != __e; ++__b)
__dest.push_back(*__b);
}
}
template <class _Iter>
@ -294,13 +293,7 @@ struct _PathCVT<char> {
__char_to_wide(__str, const_cast<__path_value*>(__dest.data()) + __pos, __size);
}
template <class _Iter, __enable_if_t<__has_exactly_input_iterator_category<_Iter>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
basic_string<char> __tmp(__b, __e);
__append_string(__dest, __tmp);
}
template <class _Iter, __enable_if_t<__has_forward_iterator_category<_Iter>::value, int> = 0>
template <class _Iter>
_LIBCPP_HIDE_FROM_ABI static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
basic_string<char> __tmp(__b, __e);
__append_string(__dest, __tmp);
@ -874,23 +867,13 @@ public:
[[nodiscard]] iterator end() const;
# if _LIBCPP_HAS_LOCALIZATION
template <
class _CharT,
class _Traits,
__enable_if_t<is_same<_CharT, value_type>::value && is_same<_Traits, char_traits<value_type> >::value, int> = 0>
template <class _CharT, class _Traits>
_LIBCPP_HIDE_FROM_ABI friend basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) {
__os << std::quoted(__p.native());
return __os;
}
template <
class _CharT,
class _Traits,
__enable_if_t<!is_same<_CharT, value_type>::value || !is_same<_Traits, char_traits<value_type> >::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI friend basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) {
__os << std::quoted(__p.string<_CharT, _Traits>());
if constexpr (is_same<_CharT, value_type>::value && is_same<_Traits, char_traits<value_type> >::value)
__os << std::quoted(__p.native());
else
__os << std::quoted(__p.string<_CharT, _Traits>());
return __os;
}