File indexing completed on 2026-05-03 08:13:28
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _LIBCPP___CXX03___FILESYSTEM_U8PATH_H
0011 #define _LIBCPP___CXX03___FILESYSTEM_U8PATH_H
0012
0013 #include <__cxx03/__algorithm/unwrap_iter.h>
0014 #include <__cxx03/__config>
0015 #include <__cxx03/__filesystem/path.h>
0016 #include <__cxx03/string>
0017
0018
0019
0020 #if defined(_LIBCPP_WIN32API)
0021 # include <__cxx03/locale>
0022 #endif
0023
0024 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0025 # pragma GCC system_header
0026 #endif
0027
0028 #if _LIBCPP_STD_VER >= 17
0029
0030 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
0031
0032 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH
0033
0034 template <class _InputIt, __enable_if_t<__is_pathable<_InputIt>::value, int> = 0>
0035 _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f, _InputIt __l) {
0036 static_assert(
0037 # ifndef _LIBCPP_HAS_NO_CHAR8_T
0038 is_same<typename __is_pathable<_InputIt>::__char_type, char8_t>::value ||
0039 # endif
0040 is_same<typename __is_pathable<_InputIt>::__char_type, char>::value,
0041 "u8path(Iter, Iter) requires Iter have a value_type of type 'char'"
0042 " or 'char8_t'");
0043 # if defined(_LIBCPP_WIN32API)
0044 string __tmp(__f, __l);
0045 using _CVT = __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__>;
0046 std::wstring __w;
0047 __w.reserve(__tmp.size());
0048 _CVT()(back_inserter(__w), __tmp.data(), __tmp.data() + __tmp.size());
0049 return path(__w);
0050 # else
0051 return path(__f, __l);
0052 # endif
0053 }
0054
0055 # if defined(_LIBCPP_WIN32API)
0056 template <class _InputIt, __enable_if_t<__is_pathable<_InputIt>::value, int> = 0>
0057 _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f, _NullSentinel) {
0058 static_assert(
0059 # ifndef _LIBCPP_HAS_NO_CHAR8_T
0060 is_same<typename __is_pathable<_InputIt>::__char_type, char8_t>::value ||
0061 # endif
0062 is_same<typename __is_pathable<_InputIt>::__char_type, char>::value,
0063 "u8path(Iter, Iter) requires Iter have a value_type of type 'char'"
0064 " or 'char8_t'");
0065 string __tmp;
0066 const char __sentinel = char{};
0067 for (; *__f != __sentinel; ++__f)
0068 __tmp.push_back(*__f);
0069 using _CVT = __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__>;
0070 std::wstring __w;
0071 __w.reserve(__tmp.size());
0072 _CVT()(back_inserter(__w), __tmp.data(), __tmp.data() + __tmp.size());
0073 return path(__w);
0074 }
0075 # endif
0076
0077 template <class _Source, __enable_if_t<__is_pathable<_Source>::value, int> = 0>
0078 _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(const _Source& __s) {
0079 static_assert(
0080 # ifndef _LIBCPP_HAS_NO_CHAR8_T
0081 is_same<typename __is_pathable<_Source>::__char_type, char8_t>::value ||
0082 # endif
0083 is_same<typename __is_pathable<_Source>::__char_type, char>::value,
0084 "u8path(Source const&) requires Source have a character type of type "
0085 "'char' or 'char8_t'");
0086 # if defined(_LIBCPP_WIN32API)
0087 using _Traits = __is_pathable<_Source>;
0088 return u8path(std::__unwrap_iter(_Traits::__range_begin(__s)), std::__unwrap_iter(_Traits::__range_end(__s)));
0089 # else
0090 return path(__s);
0091 # endif
0092 }
0093
0094 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP
0095
0096 _LIBCPP_END_NAMESPACE_FILESYSTEM
0097
0098 #endif
0099
0100 #endif