[libcxx-commits] [libcxx] [libc++][NFC] Simplify some overloads in fs::path a bit (PR #181053)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Feb 12 02:04:17 PST 2026
https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/181053
>From 7e6f956b75d1263cd59aed18061dfd826998ac54 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Thu, 12 Feb 2026 01:11:57 +0100
Subject: [PATCH] [libc++][NFC] Simplify some overloads in fs::path a bit
---
libcxx/include/__filesystem/path.h | 43 +++++++++---------------------
1 file changed, 13 insertions(+), 30 deletions(-)
diff --git a/libcxx/include/__filesystem/path.h b/libcxx/include/__filesystem/path.h
index d567ff5dbb4f4..47ecf1ce19782 100644
--- a/libcxx/include/__filesystem/path.h
+++ b/libcxx/include/__filesystem/path.h
@@ -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>
- _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>
+ template <class _Iter>
_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 @@ class _LIBCPP_EXPORTED_FROM_ABI path {
[[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>
- _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>
+ 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.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;
}
More information about the libcxx-commits
mailing list