xref: /freebsd-src/contrib/llvm-project/libcxx/include/__filesystem/path.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
10eae32dcSDimitry Andric // -*- C++ -*-
20eae32dcSDimitry Andric //===----------------------------------------------------------------------===//
30eae32dcSDimitry Andric //
40eae32dcSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
50eae32dcSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
60eae32dcSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
70eae32dcSDimitry Andric //
80eae32dcSDimitry Andric //===----------------------------------------------------------------------===//
90eae32dcSDimitry Andric 
100eae32dcSDimitry Andric #ifndef _LIBCPP___FILESYSTEM_PATH_H
110eae32dcSDimitry Andric #define _LIBCPP___FILESYSTEM_PATH_H
120eae32dcSDimitry Andric 
1381ad6265SDimitry Andric #include <__algorithm/replace.h>
1481ad6265SDimitry Andric #include <__algorithm/replace_copy.h>
150eae32dcSDimitry Andric #include <__config>
1606c3fb27SDimitry Andric #include <__functional/unary_function.h>
17*0fca6ea1SDimitry Andric #include <__fwd/functional.h>
180eae32dcSDimitry Andric #include <__iterator/back_insert_iterator.h>
190eae32dcSDimitry Andric #include <__iterator/iterator_traits.h>
2006c3fb27SDimitry Andric #include <__type_traits/decay.h>
2106c3fb27SDimitry Andric #include <__type_traits/is_pointer.h>
2206c3fb27SDimitry Andric #include <__type_traits/remove_const.h>
2306c3fb27SDimitry Andric #include <__type_traits/remove_pointer.h>
240eae32dcSDimitry Andric #include <cstddef>
2504eeddc0SDimitry Andric #include <string>
260eae32dcSDimitry Andric #include <string_view>
270eae32dcSDimitry Andric 
280eae32dcSDimitry Andric #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
290eae32dcSDimitry Andric #  include <iomanip> // for quoted
3004eeddc0SDimitry Andric #  include <locale>
310eae32dcSDimitry Andric #endif
320eae32dcSDimitry Andric 
3381ad6265SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3481ad6265SDimitry Andric #  pragma GCC system_header
3581ad6265SDimitry Andric #endif
3681ad6265SDimitry Andric 
37b3edf446SDimitry Andric _LIBCPP_PUSH_MACROS
38b3edf446SDimitry Andric #include <__undef_macros>
39b3edf446SDimitry Andric 
405f757f3fSDimitry Andric #if _LIBCPP_STD_VER >= 17
410eae32dcSDimitry Andric 
420eae32dcSDimitry Andric _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
430eae32dcSDimitry Andric 
4406c3fb27SDimitry Andric _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH
450eae32dcSDimitry Andric 
460eae32dcSDimitry Andric template <class _Tp>
470eae32dcSDimitry Andric struct __can_convert_char {
480eae32dcSDimitry Andric   static const bool value = false;
490eae32dcSDimitry Andric };
500eae32dcSDimitry Andric template <class _Tp>
510eae32dcSDimitry Andric struct __can_convert_char<const _Tp> : public __can_convert_char<_Tp> {};
520eae32dcSDimitry Andric template <>
530eae32dcSDimitry Andric struct __can_convert_char<char> {
540eae32dcSDimitry Andric   static const bool value = true;
550eae32dcSDimitry Andric   using __char_type       = char;
560eae32dcSDimitry Andric };
570eae32dcSDimitry Andric template <>
580eae32dcSDimitry Andric struct __can_convert_char<wchar_t> {
590eae32dcSDimitry Andric   static const bool value = true;
600eae32dcSDimitry Andric   using __char_type       = wchar_t;
610eae32dcSDimitry Andric };
620eae32dcSDimitry Andric #  ifndef _LIBCPP_HAS_NO_CHAR8_T
630eae32dcSDimitry Andric template <>
640eae32dcSDimitry Andric struct __can_convert_char<char8_t> {
650eae32dcSDimitry Andric   static const bool value = true;
660eae32dcSDimitry Andric   using __char_type       = char8_t;
670eae32dcSDimitry Andric };
680eae32dcSDimitry Andric #  endif
690eae32dcSDimitry Andric template <>
700eae32dcSDimitry Andric struct __can_convert_char<char16_t> {
710eae32dcSDimitry Andric   static const bool value = true;
720eae32dcSDimitry Andric   using __char_type       = char16_t;
730eae32dcSDimitry Andric };
740eae32dcSDimitry Andric template <>
750eae32dcSDimitry Andric struct __can_convert_char<char32_t> {
760eae32dcSDimitry Andric   static const bool value = true;
770eae32dcSDimitry Andric   using __char_type       = char32_t;
780eae32dcSDimitry Andric };
790eae32dcSDimitry Andric 
805f757f3fSDimitry Andric template <class _ECharT, __enable_if_t<__can_convert_char<_ECharT>::value, int> = 0>
81cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI bool __is_separator(_ECharT __e) {
820eae32dcSDimitry Andric #  if defined(_LIBCPP_WIN32API)
830eae32dcSDimitry Andric   return __e == _ECharT('/') || __e == _ECharT('\\');
840eae32dcSDimitry Andric #  else
850eae32dcSDimitry Andric   return __e == _ECharT('/');
860eae32dcSDimitry Andric #  endif
870eae32dcSDimitry Andric }
880eae32dcSDimitry Andric 
890eae32dcSDimitry Andric #  ifndef _LIBCPP_HAS_NO_CHAR8_T
900eae32dcSDimitry Andric typedef u8string __u8_string;
910eae32dcSDimitry Andric #  else
920eae32dcSDimitry Andric typedef string __u8_string;
930eae32dcSDimitry Andric #  endif
940eae32dcSDimitry Andric 
950eae32dcSDimitry Andric struct _NullSentinel {};
960eae32dcSDimitry Andric 
970eae32dcSDimitry Andric template <class _Tp>
980eae32dcSDimitry Andric using _Void = void;
990eae32dcSDimitry Andric 
1000eae32dcSDimitry Andric template <class _Tp, class = void>
1010eae32dcSDimitry Andric struct __is_pathable_string : public false_type {};
1020eae32dcSDimitry Andric 
1030eae32dcSDimitry Andric template <class _ECharT, class _Traits, class _Alloc>
104cb14a3feSDimitry Andric struct __is_pathable_string< basic_string<_ECharT, _Traits, _Alloc>,
1050eae32dcSDimitry Andric                              _Void<typename __can_convert_char<_ECharT>::__char_type> >
1060eae32dcSDimitry Andric     : public __can_convert_char<_ECharT> {
1070eae32dcSDimitry Andric   using _Str = basic_string<_ECharT, _Traits, _Alloc>;
10881ad6265SDimitry Andric 
109cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); }
11081ad6265SDimitry Andric 
111cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static _ECharT const* __range_end(_Str const& __s) { return __s.data() + __s.length(); }
11281ad6265SDimitry Andric 
113cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static _ECharT __first_or_null(_Str const& __s) { return __s.empty() ? _ECharT{} : __s[0]; }
1140eae32dcSDimitry Andric };
1150eae32dcSDimitry Andric 
1160eae32dcSDimitry Andric template <class _ECharT, class _Traits>
117cb14a3feSDimitry Andric struct __is_pathable_string< basic_string_view<_ECharT, _Traits>,
1180eae32dcSDimitry Andric                              _Void<typename __can_convert_char<_ECharT>::__char_type> >
1190eae32dcSDimitry Andric     : public __can_convert_char<_ECharT> {
1200eae32dcSDimitry Andric   using _Str = basic_string_view<_ECharT, _Traits>;
12181ad6265SDimitry Andric 
122cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); }
12381ad6265SDimitry Andric 
124cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static _ECharT const* __range_end(_Str const& __s) { return __s.data() + __s.length(); }
12581ad6265SDimitry Andric 
126cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static _ECharT __first_or_null(_Str const& __s) { return __s.empty() ? _ECharT{} : __s[0]; }
1270eae32dcSDimitry Andric };
1280eae32dcSDimitry Andric 
129cb14a3feSDimitry Andric template <class _Source,
130cb14a3feSDimitry Andric           class _DS            = __decay_t<_Source>,
131cb14a3feSDimitry Andric           class _UnqualPtrType = __remove_const_t<__remove_pointer_t<_DS> >,
132cb14a3feSDimitry Andric           bool _IsCharPtr      = is_pointer<_DS>::value && __can_convert_char<_UnqualPtrType>::value>
1330eae32dcSDimitry Andric struct __is_pathable_char_array : false_type {};
1340eae32dcSDimitry Andric 
1350eae32dcSDimitry Andric template <class _Source, class _ECharT, class _UPtr>
136cb14a3feSDimitry Andric struct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true> : __can_convert_char<__remove_const_t<_ECharT> > {
137cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static _ECharT const* __range_begin(const _ECharT* __b) { return __b; }
13881ad6265SDimitry Andric 
139cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static _ECharT const* __range_end(const _ECharT* __b) {
1400eae32dcSDimitry Andric     using _Iter              = const _ECharT*;
1410eae32dcSDimitry Andric     const _ECharT __sentinel = _ECharT{};
1420eae32dcSDimitry Andric     _Iter __e                = __b;
1430eae32dcSDimitry Andric     for (; *__e != __sentinel; ++__e)
1440eae32dcSDimitry Andric       ;
1450eae32dcSDimitry Andric     return __e;
1460eae32dcSDimitry Andric   }
1470eae32dcSDimitry Andric 
148cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static _ECharT __first_or_null(const _ECharT* __b) { return *__b; }
1490eae32dcSDimitry Andric };
1500eae32dcSDimitry Andric 
151cb14a3feSDimitry Andric template <class _Iter, bool _IsIt = __has_input_iterator_category<_Iter>::value, class = void>
1520eae32dcSDimitry Andric struct __is_pathable_iter : false_type {};
1530eae32dcSDimitry Andric 
1540eae32dcSDimitry Andric template <class _Iter>
1550eae32dcSDimitry Andric struct __is_pathable_iter<
156cb14a3feSDimitry Andric     _Iter,
157cb14a3feSDimitry Andric     true,
158cb14a3feSDimitry Andric     _Void<typename __can_convert_char< typename iterator_traits<_Iter>::value_type>::__char_type> >
1590eae32dcSDimitry Andric     : __can_convert_char<typename iterator_traits<_Iter>::value_type> {
1600eae32dcSDimitry Andric   using _ECharT = typename iterator_traits<_Iter>::value_type;
1610eae32dcSDimitry Andric 
162cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static _Iter __range_begin(_Iter __b) { return __b; }
16381ad6265SDimitry Andric 
164cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static _NullSentinel __range_end(_Iter) { return _NullSentinel{}; }
1650eae32dcSDimitry Andric 
166cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static _ECharT __first_or_null(_Iter __b) { return *__b; }
1670eae32dcSDimitry Andric };
1680eae32dcSDimitry Andric 
169cb14a3feSDimitry Andric template <class _Tp,
170cb14a3feSDimitry Andric           bool _IsStringT   = __is_pathable_string<_Tp>::value,
1710eae32dcSDimitry Andric           bool _IsCharIterT = __is_pathable_char_array<_Tp>::value,
1720eae32dcSDimitry Andric           bool _IsIterT     = !_IsCharIterT && __is_pathable_iter<_Tp>::value>
1730eae32dcSDimitry Andric struct __is_pathable : false_type {
1740eae32dcSDimitry Andric   static_assert(!_IsStringT && !_IsCharIterT && !_IsIterT, "Must all be false");
1750eae32dcSDimitry Andric };
1760eae32dcSDimitry Andric 
1770eae32dcSDimitry Andric template <class _Tp>
1780eae32dcSDimitry Andric struct __is_pathable<_Tp, true, false, false> : __is_pathable_string<_Tp> {};
1790eae32dcSDimitry Andric 
1800eae32dcSDimitry Andric template <class _Tp>
181cb14a3feSDimitry Andric struct __is_pathable<_Tp, false, true, false> : __is_pathable_char_array<_Tp> {};
1820eae32dcSDimitry Andric 
1830eae32dcSDimitry Andric template <class _Tp>
1840eae32dcSDimitry Andric struct __is_pathable<_Tp, false, false, true> : __is_pathable_iter<_Tp> {};
1850eae32dcSDimitry Andric 
1860eae32dcSDimitry Andric #  if defined(_LIBCPP_WIN32API)
1870eae32dcSDimitry Andric typedef wstring __path_string;
1880eae32dcSDimitry Andric typedef wchar_t __path_value;
1890eae32dcSDimitry Andric #  else
1900eae32dcSDimitry Andric typedef string __path_string;
1910eae32dcSDimitry Andric typedef char __path_value;
1920eae32dcSDimitry Andric #  endif
1930eae32dcSDimitry Andric 
1940eae32dcSDimitry Andric #  if defined(_LIBCPP_WIN32API)
19506c3fb27SDimitry Andric _LIBCPP_EXPORTED_FROM_ABI size_t __wide_to_char(const wstring&, char*, size_t);
19606c3fb27SDimitry Andric _LIBCPP_EXPORTED_FROM_ABI size_t __char_to_wide(const string&, wchar_t*, size_t);
1970eae32dcSDimitry Andric #  endif
1980eae32dcSDimitry Andric 
1990eae32dcSDimitry Andric template <class _ECharT>
2000eae32dcSDimitry Andric struct _PathCVT;
2010eae32dcSDimitry Andric 
2020eae32dcSDimitry Andric #  if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
2030eae32dcSDimitry Andric template <class _ECharT>
2040eae32dcSDimitry Andric struct _PathCVT {
205cb14a3feSDimitry Andric   static_assert(__can_convert_char<_ECharT>::value, "Char type not convertible");
2060eae32dcSDimitry Andric 
2070eae32dcSDimitry Andric   typedef __narrow_to_utf8<sizeof(_ECharT) * __CHAR_BIT__> _Narrower;
2080eae32dcSDimitry Andric #    if defined(_LIBCPP_WIN32API)
2090eae32dcSDimitry Andric   typedef __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Widener;
2100eae32dcSDimitry Andric #    endif
2110eae32dcSDimitry Andric 
212cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static void __append_range(__path_string& __dest, _ECharT const* __b, _ECharT const* __e) {
2130eae32dcSDimitry Andric #    if defined(_LIBCPP_WIN32API)
2140eae32dcSDimitry Andric     string __utf8;
2150eae32dcSDimitry Andric     _Narrower()(back_inserter(__utf8), __b, __e);
2160eae32dcSDimitry Andric     _Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size());
2170eae32dcSDimitry Andric #    else
2180eae32dcSDimitry Andric     _Narrower()(back_inserter(__dest), __b, __e);
2190eae32dcSDimitry Andric #    endif
2200eae32dcSDimitry Andric   }
2210eae32dcSDimitry Andric 
2220eae32dcSDimitry Andric   template <class _Iter>
223cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
2240eae32dcSDimitry Andric     static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload");
2250eae32dcSDimitry Andric     if (__b == __e)
2260eae32dcSDimitry Andric       return;
2270eae32dcSDimitry Andric     basic_string<_ECharT> __tmp(__b, __e);
2280eae32dcSDimitry Andric #    if defined(_LIBCPP_WIN32API)
2290eae32dcSDimitry Andric     string __utf8;
230cb14a3feSDimitry Andric     _Narrower()(back_inserter(__utf8), __tmp.data(), __tmp.data() + __tmp.length());
2310eae32dcSDimitry Andric     _Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size());
2320eae32dcSDimitry Andric #    else
233cb14a3feSDimitry Andric     _Narrower()(back_inserter(__dest), __tmp.data(), __tmp.data() + __tmp.length());
2340eae32dcSDimitry Andric #    endif
2350eae32dcSDimitry Andric   }
2360eae32dcSDimitry Andric 
2370eae32dcSDimitry Andric   template <class _Iter>
238cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) {
2390eae32dcSDimitry Andric     static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload");
2400eae32dcSDimitry Andric     const _ECharT __sentinel = _ECharT{};
2410eae32dcSDimitry Andric     if (*__b == __sentinel)
2420eae32dcSDimitry Andric       return;
2430eae32dcSDimitry Andric     basic_string<_ECharT> __tmp;
2440eae32dcSDimitry Andric     for (; *__b != __sentinel; ++__b)
2450eae32dcSDimitry Andric       __tmp.push_back(*__b);
2460eae32dcSDimitry Andric #    if defined(_LIBCPP_WIN32API)
2470eae32dcSDimitry Andric     string __utf8;
248cb14a3feSDimitry Andric     _Narrower()(back_inserter(__utf8), __tmp.data(), __tmp.data() + __tmp.length());
2490eae32dcSDimitry Andric     _Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size());
2500eae32dcSDimitry Andric #    else
251cb14a3feSDimitry Andric     _Narrower()(back_inserter(__dest), __tmp.data(), __tmp.data() + __tmp.length());
2520eae32dcSDimitry Andric #    endif
2530eae32dcSDimitry Andric   }
2540eae32dcSDimitry Andric 
2550eae32dcSDimitry Andric   template <class _Source>
256cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static void __append_source(__path_string& __dest, _Source const& __s) {
2570eae32dcSDimitry Andric     using _Traits = __is_pathable<_Source>;
258cb14a3feSDimitry Andric     __append_range(__dest, _Traits::__range_begin(__s), _Traits::__range_end(__s));
2590eae32dcSDimitry Andric   }
2600eae32dcSDimitry Andric };
2610eae32dcSDimitry Andric #  endif // !_LIBCPP_HAS_NO_LOCALIZATION
2620eae32dcSDimitry Andric 
2630eae32dcSDimitry Andric template <>
2640eae32dcSDimitry Andric struct _PathCVT<__path_value> {
2655f757f3fSDimitry Andric   template <class _Iter, __enable_if_t<__has_exactly_input_iterator_category<_Iter>::value, int> = 0>
266cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
2670eae32dcSDimitry Andric     for (; __b != __e; ++__b)
2680eae32dcSDimitry Andric       __dest.push_back(*__b);
2690eae32dcSDimitry Andric   }
2700eae32dcSDimitry Andric 
2715f757f3fSDimitry Andric   template <class _Iter, __enable_if_t<__has_forward_iterator_category<_Iter>::value, int> = 0>
272cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
2730eae32dcSDimitry Andric     __dest.append(__b, __e);
2740eae32dcSDimitry Andric   }
2750eae32dcSDimitry Andric 
2760eae32dcSDimitry Andric   template <class _Iter>
277cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) {
2780eae32dcSDimitry Andric     const char __sentinel = char{};
2790eae32dcSDimitry Andric     for (; *__b != __sentinel; ++__b)
2800eae32dcSDimitry Andric       __dest.push_back(*__b);
2810eae32dcSDimitry Andric   }
2820eae32dcSDimitry Andric 
2830eae32dcSDimitry Andric   template <class _Source>
284cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static void __append_source(__path_string& __dest, _Source const& __s) {
2850eae32dcSDimitry Andric     using _Traits = __is_pathable<_Source>;
286cb14a3feSDimitry Andric     __append_range(__dest, _Traits::__range_begin(__s), _Traits::__range_end(__s));
2870eae32dcSDimitry Andric   }
2880eae32dcSDimitry Andric };
2890eae32dcSDimitry Andric 
2900eae32dcSDimitry Andric #  if defined(_LIBCPP_WIN32API)
2910eae32dcSDimitry Andric template <>
2920eae32dcSDimitry Andric struct _PathCVT<char> {
293cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static void __append_string(__path_string& __dest, const basic_string<char>& __str) {
2940eae32dcSDimitry Andric     size_t __size = __char_to_wide(__str, nullptr, 0);
2950eae32dcSDimitry Andric     size_t __pos  = __dest.size();
2960eae32dcSDimitry Andric     __dest.resize(__pos + __size);
2970eae32dcSDimitry Andric     __char_to_wide(__str, const_cast<__path_value*>(__dest.data()) + __pos, __size);
2980eae32dcSDimitry Andric   }
2990eae32dcSDimitry Andric 
3005f757f3fSDimitry Andric   template <class _Iter, __enable_if_t<__has_exactly_input_iterator_category<_Iter>::value, int> = 0>
301cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
3020eae32dcSDimitry Andric     basic_string<char> __tmp(__b, __e);
3030eae32dcSDimitry Andric     __append_string(__dest, __tmp);
3040eae32dcSDimitry Andric   }
3050eae32dcSDimitry Andric 
3065f757f3fSDimitry Andric   template <class _Iter, __enable_if_t<__has_forward_iterator_category<_Iter>::value, int> = 0>
307cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
3080eae32dcSDimitry Andric     basic_string<char> __tmp(__b, __e);
3090eae32dcSDimitry Andric     __append_string(__dest, __tmp);
3100eae32dcSDimitry Andric   }
3110eae32dcSDimitry Andric 
3120eae32dcSDimitry Andric   template <class _Iter>
313cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) {
3140eae32dcSDimitry Andric     const char __sentinel = char{};
3150eae32dcSDimitry Andric     basic_string<char> __tmp;
3160eae32dcSDimitry Andric     for (; *__b != __sentinel; ++__b)
3170eae32dcSDimitry Andric       __tmp.push_back(*__b);
3180eae32dcSDimitry Andric     __append_string(__dest, __tmp);
3190eae32dcSDimitry Andric   }
3200eae32dcSDimitry Andric 
3210eae32dcSDimitry Andric   template <class _Source>
322cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static void __append_source(__path_string& __dest, _Source const& __s) {
3230eae32dcSDimitry Andric     using _Traits = __is_pathable<_Source>;
324cb14a3feSDimitry Andric     __append_range(__dest, _Traits::__range_begin(__s), _Traits::__range_end(__s));
3250eae32dcSDimitry Andric   }
3260eae32dcSDimitry Andric };
3270eae32dcSDimitry Andric 
3280eae32dcSDimitry Andric template <class _ECharT>
3290eae32dcSDimitry Andric struct _PathExport {
3300eae32dcSDimitry Andric   typedef __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Narrower;
3310eae32dcSDimitry Andric   typedef __widen_from_utf8<sizeof(_ECharT) * __CHAR_BIT__> _Widener;
3320eae32dcSDimitry Andric 
3330eae32dcSDimitry Andric   template <class _Str>
334cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static void __append(_Str& __dest, const __path_string& __src) {
3350eae32dcSDimitry Andric     string __utf8;
3360eae32dcSDimitry Andric     _Narrower()(back_inserter(__utf8), __src.data(), __src.data() + __src.size());
3370eae32dcSDimitry Andric     _Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size());
3380eae32dcSDimitry Andric   }
3390eae32dcSDimitry Andric };
3400eae32dcSDimitry Andric 
3410eae32dcSDimitry Andric template <>
3420eae32dcSDimitry Andric struct _PathExport<char> {
3430eae32dcSDimitry Andric   template <class _Str>
344cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static void __append(_Str& __dest, const __path_string& __src) {
3450eae32dcSDimitry Andric     size_t __size = __wide_to_char(__src, nullptr, 0);
3460eae32dcSDimitry Andric     size_t __pos  = __dest.size();
3470eae32dcSDimitry Andric     __dest.resize(__size);
3480eae32dcSDimitry Andric     __wide_to_char(__src, const_cast<char*>(__dest.data()) + __pos, __size);
3490eae32dcSDimitry Andric   }
3500eae32dcSDimitry Andric };
3510eae32dcSDimitry Andric 
3520eae32dcSDimitry Andric template <>
3530eae32dcSDimitry Andric struct _PathExport<wchar_t> {
3540eae32dcSDimitry Andric   template <class _Str>
355cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static void __append(_Str& __dest, const __path_string& __src) {
3560eae32dcSDimitry Andric     __dest.append(__src.begin(), __src.end());
3570eae32dcSDimitry Andric   }
3580eae32dcSDimitry Andric };
3590eae32dcSDimitry Andric 
3600eae32dcSDimitry Andric template <>
3610eae32dcSDimitry Andric struct _PathExport<char16_t> {
3620eae32dcSDimitry Andric   template <class _Str>
363cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static void __append(_Str& __dest, const __path_string& __src) {
3640eae32dcSDimitry Andric     __dest.append(__src.begin(), __src.end());
3650eae32dcSDimitry Andric   }
3660eae32dcSDimitry Andric };
3670eae32dcSDimitry Andric 
3680eae32dcSDimitry Andric #    ifndef _LIBCPP_HAS_NO_CHAR8_T
3690eae32dcSDimitry Andric template <>
3700eae32dcSDimitry Andric struct _PathExport<char8_t> {
3710eae32dcSDimitry Andric   typedef __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Narrower;
3720eae32dcSDimitry Andric 
3730eae32dcSDimitry Andric   template <class _Str>
374cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI static void __append(_Str& __dest, const __path_string& __src) {
3750eae32dcSDimitry Andric     _Narrower()(back_inserter(__dest), __src.data(), __src.data() + __src.size());
3760eae32dcSDimitry Andric   }
3770eae32dcSDimitry Andric };
3780eae32dcSDimitry Andric #    endif /* !_LIBCPP_HAS_NO_CHAR8_T */
3790eae32dcSDimitry Andric #  endif   /* _LIBCPP_WIN32API */
3800eae32dcSDimitry Andric 
38106c3fb27SDimitry Andric class _LIBCPP_EXPORTED_FROM_ABI path {
3820eae32dcSDimitry Andric   template <class _SourceOrIter, class _Tp = path&>
3835f757f3fSDimitry Andric   using _EnableIfPathable = __enable_if_t<__is_pathable<_SourceOrIter>::value, _Tp>;
3840eae32dcSDimitry Andric 
3850eae32dcSDimitry Andric   template <class _Tp>
3860eae32dcSDimitry Andric   using _SourceChar = typename __is_pathable<_Tp>::__char_type;
3870eae32dcSDimitry Andric 
3880eae32dcSDimitry Andric   template <class _Tp>
3890eae32dcSDimitry Andric   using _SourceCVT = _PathCVT<_SourceChar<_Tp> >;
3900eae32dcSDimitry Andric 
3910eae32dcSDimitry Andric public:
3920eae32dcSDimitry Andric #  if defined(_LIBCPP_WIN32API)
3930eae32dcSDimitry Andric   typedef wchar_t value_type;
3940eae32dcSDimitry Andric   static constexpr value_type preferred_separator = L'\\';
3950eae32dcSDimitry Andric #  else
3960eae32dcSDimitry Andric   typedef char value_type;
3970eae32dcSDimitry Andric   static constexpr value_type preferred_separator = '/';
3980eae32dcSDimitry Andric #  endif
3990eae32dcSDimitry Andric   typedef basic_string<value_type> string_type;
4000eae32dcSDimitry Andric   typedef basic_string_view<value_type> __string_view;
4010eae32dcSDimitry Andric 
402cb14a3feSDimitry Andric   enum format : unsigned char { auto_format, native_format, generic_format };
4030eae32dcSDimitry Andric 
4040eae32dcSDimitry Andric   // constructors and destructor
40581ad6265SDimitry Andric   _LIBCPP_HIDE_FROM_ABI path() noexcept {}
40681ad6265SDimitry Andric   _LIBCPP_HIDE_FROM_ABI path(const path& __p) : __pn_(__p.__pn_) {}
407cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path(path&& __p) noexcept : __pn_(std::move(__p.__pn_)) {}
4080eae32dcSDimitry Andric 
409cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path(string_type&& __s, format = format::auto_format) noexcept : __pn_(std::move(__s)) {}
4100eae32dcSDimitry Andric 
4110eae32dcSDimitry Andric   template <class _Source, class = _EnableIfPathable<_Source, void> >
412cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path(const _Source& __src, format = format::auto_format) {
4130eae32dcSDimitry Andric     _SourceCVT<_Source>::__append_source(__pn_, __src);
4140eae32dcSDimitry Andric   }
4150eae32dcSDimitry Andric 
4160eae32dcSDimitry Andric   template <class _InputIt>
417cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path(_InputIt __first, _InputIt __last, format = format::auto_format) {
4180eae32dcSDimitry Andric     typedef typename iterator_traits<_InputIt>::value_type _ItVal;
4190eae32dcSDimitry Andric     _PathCVT<_ItVal>::__append_range(__pn_, __first, __last);
4200eae32dcSDimitry Andric   }
4210eae32dcSDimitry Andric 
4220eae32dcSDimitry Andric   /*
4230eae32dcSDimitry Andric   #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
4240eae32dcSDimitry Andric     // TODO Implement locale conversions.
4250eae32dcSDimitry Andric     template <class _Source, class = _EnableIfPathable<_Source, void> >
4260eae32dcSDimitry Andric     path(const _Source& __src, const locale& __loc, format = format::auto_format);
4270eae32dcSDimitry Andric     template <class _InputIt>
4280eae32dcSDimitry Andric     path(_InputIt __first, _InputIt _last, const locale& __loc,
4290eae32dcSDimitry Andric          format = format::auto_format);
4300eae32dcSDimitry Andric   #endif
4310eae32dcSDimitry Andric   */
4320eae32dcSDimitry Andric 
433cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI ~path() = default;
4340eae32dcSDimitry Andric 
4350eae32dcSDimitry Andric   // assignments
436cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path& operator=(const path& __p) {
4370eae32dcSDimitry Andric     __pn_ = __p.__pn_;
4380eae32dcSDimitry Andric     return *this;
4390eae32dcSDimitry Andric   }
4400eae32dcSDimitry Andric 
441cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path& operator=(path&& __p) noexcept {
4425f757f3fSDimitry Andric     __pn_ = std::move(__p.__pn_);
4430eae32dcSDimitry Andric     return *this;
4440eae32dcSDimitry Andric   }
4450eae32dcSDimitry Andric 
446cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path& operator=(string_type&& __s) noexcept {
4475f757f3fSDimitry Andric     __pn_ = std::move(__s);
4480eae32dcSDimitry Andric     return *this;
4490eae32dcSDimitry Andric   }
4500eae32dcSDimitry Andric 
451cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path& assign(string_type&& __s) noexcept {
4525f757f3fSDimitry Andric     __pn_ = std::move(__s);
4530eae32dcSDimitry Andric     return *this;
4540eae32dcSDimitry Andric   }
4550eae32dcSDimitry Andric 
4560eae32dcSDimitry Andric   template <class _Source>
457cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI _EnableIfPathable<_Source> operator=(const _Source& __src) {
4580eae32dcSDimitry Andric     return this->assign(__src);
4590eae32dcSDimitry Andric   }
4600eae32dcSDimitry Andric 
4610eae32dcSDimitry Andric   template <class _Source>
462cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI _EnableIfPathable<_Source> assign(const _Source& __src) {
4630eae32dcSDimitry Andric     __pn_.clear();
4640eae32dcSDimitry Andric     _SourceCVT<_Source>::__append_source(__pn_, __src);
4650eae32dcSDimitry Andric     return *this;
4660eae32dcSDimitry Andric   }
4670eae32dcSDimitry Andric 
4680eae32dcSDimitry Andric   template <class _InputIt>
469cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path& assign(_InputIt __first, _InputIt __last) {
4700eae32dcSDimitry Andric     typedef typename iterator_traits<_InputIt>::value_type _ItVal;
4710eae32dcSDimitry Andric     __pn_.clear();
4720eae32dcSDimitry Andric     _PathCVT<_ItVal>::__append_range(__pn_, __first, __last);
4730eae32dcSDimitry Andric     return *this;
4740eae32dcSDimitry Andric   }
4750eae32dcSDimitry Andric 
4760eae32dcSDimitry Andric public:
4770eae32dcSDimitry Andric   // appends
4780eae32dcSDimitry Andric #  if defined(_LIBCPP_WIN32API)
479cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path& operator/=(const path& __p) {
4800eae32dcSDimitry Andric     auto __p_root_name      = __p.__root_name();
4810eae32dcSDimitry Andric     auto __p_root_name_size = __p_root_name.size();
482cb14a3feSDimitry Andric     if (__p.is_absolute() || (!__p_root_name.empty() && __p_root_name != __string_view(root_name().__pn_))) {
4830eae32dcSDimitry Andric       __pn_ = __p.__pn_;
4840eae32dcSDimitry Andric       return *this;
4850eae32dcSDimitry Andric     }
4860eae32dcSDimitry Andric     if (__p.has_root_directory()) {
4870eae32dcSDimitry Andric       path __root_name_str = root_name();
4880eae32dcSDimitry Andric       __pn_                = __root_name_str.native();
4890eae32dcSDimitry Andric       __pn_ += __string_view(__p.__pn_).substr(__p_root_name_size);
4900eae32dcSDimitry Andric       return *this;
4910eae32dcSDimitry Andric     }
4920eae32dcSDimitry Andric     if (has_filename() || (!has_root_directory() && is_absolute()))
4930eae32dcSDimitry Andric       __pn_ += preferred_separator;
4940eae32dcSDimitry Andric     __pn_ += __string_view(__p.__pn_).substr(__p_root_name_size);
4950eae32dcSDimitry Andric     return *this;
4960eae32dcSDimitry Andric   }
4970eae32dcSDimitry Andric   template <class _Source>
498cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI _EnableIfPathable<_Source> operator/=(const _Source& __src) {
4990eae32dcSDimitry Andric     return operator/=(path(__src));
5000eae32dcSDimitry Andric   }
5010eae32dcSDimitry Andric 
5020eae32dcSDimitry Andric   template <class _Source>
503cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI _EnableIfPathable<_Source> append(const _Source& __src) {
5040eae32dcSDimitry Andric     return operator/=(path(__src));
5050eae32dcSDimitry Andric   }
5060eae32dcSDimitry Andric 
5070eae32dcSDimitry Andric   template <class _InputIt>
508cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path& append(_InputIt __first, _InputIt __last) {
5090eae32dcSDimitry Andric     return operator/=(path(__first, __last));
5100eae32dcSDimitry Andric   }
5110eae32dcSDimitry Andric #  else
512cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path& operator/=(const path& __p) {
5130eae32dcSDimitry Andric     if (__p.is_absolute()) {
5140eae32dcSDimitry Andric       __pn_ = __p.__pn_;
5150eae32dcSDimitry Andric       return *this;
5160eae32dcSDimitry Andric     }
5170eae32dcSDimitry Andric     if (has_filename())
5180eae32dcSDimitry Andric       __pn_ += preferred_separator;
5190eae32dcSDimitry Andric     __pn_ += __p.native();
5200eae32dcSDimitry Andric     return *this;
5210eae32dcSDimitry Andric   }
5220eae32dcSDimitry Andric 
5230eae32dcSDimitry Andric   // FIXME: Use _LIBCPP_DIAGNOSE_WARNING to produce a diagnostic when __src
5240eae32dcSDimitry Andric   // is known at compile time to be "/' since the user almost certainly intended
5250eae32dcSDimitry Andric   // to append a separator instead of overwriting the path with "/"
5260eae32dcSDimitry Andric   template <class _Source>
527cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI _EnableIfPathable<_Source> operator/=(const _Source& __src) {
5280eae32dcSDimitry Andric     return this->append(__src);
5290eae32dcSDimitry Andric   }
5300eae32dcSDimitry Andric 
5310eae32dcSDimitry Andric   template <class _Source>
532cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI _EnableIfPathable<_Source> append(const _Source& __src) {
5330eae32dcSDimitry Andric     using _Traits             = __is_pathable<_Source>;
5340eae32dcSDimitry Andric     using _CVT                = _PathCVT<_SourceChar<_Source> >;
5355f757f3fSDimitry Andric     bool __source_is_absolute = filesystem::__is_separator(_Traits::__first_or_null(__src));
5360eae32dcSDimitry Andric     if (__source_is_absolute)
5370eae32dcSDimitry Andric       __pn_.clear();
5380eae32dcSDimitry Andric     else if (has_filename())
5390eae32dcSDimitry Andric       __pn_ += preferred_separator;
5400eae32dcSDimitry Andric     _CVT::__append_source(__pn_, __src);
5410eae32dcSDimitry Andric     return *this;
5420eae32dcSDimitry Andric   }
5430eae32dcSDimitry Andric 
5440eae32dcSDimitry Andric   template <class _InputIt>
545cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path& append(_InputIt __first, _InputIt __last) {
5460eae32dcSDimitry Andric     typedef typename iterator_traits<_InputIt>::value_type _ItVal;
5470eae32dcSDimitry Andric     static_assert(__can_convert_char<_ItVal>::value, "Must convertible");
5480eae32dcSDimitry Andric     using _CVT = _PathCVT<_ItVal>;
5495f757f3fSDimitry Andric     if (__first != __last && filesystem::__is_separator(*__first))
5500eae32dcSDimitry Andric       __pn_.clear();
5510eae32dcSDimitry Andric     else if (has_filename())
5520eae32dcSDimitry Andric       __pn_ += preferred_separator;
5530eae32dcSDimitry Andric     _CVT::__append_range(__pn_, __first, __last);
5540eae32dcSDimitry Andric     return *this;
5550eae32dcSDimitry Andric   }
5560eae32dcSDimitry Andric #  endif
5570eae32dcSDimitry Andric 
5580eae32dcSDimitry Andric   // concatenation
559cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path& operator+=(const path& __x) {
5600eae32dcSDimitry Andric     __pn_ += __x.__pn_;
5610eae32dcSDimitry Andric     return *this;
5620eae32dcSDimitry Andric   }
5630eae32dcSDimitry Andric 
564cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path& operator+=(const string_type& __x) {
5650eae32dcSDimitry Andric     __pn_ += __x;
5660eae32dcSDimitry Andric     return *this;
5670eae32dcSDimitry Andric   }
5680eae32dcSDimitry Andric 
569cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path& operator+=(__string_view __x) {
5700eae32dcSDimitry Andric     __pn_ += __x;
5710eae32dcSDimitry Andric     return *this;
5720eae32dcSDimitry Andric   }
5730eae32dcSDimitry Andric 
574cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path& operator+=(const value_type* __x) {
5750eae32dcSDimitry Andric     __pn_ += __x;
5760eae32dcSDimitry Andric     return *this;
5770eae32dcSDimitry Andric   }
5780eae32dcSDimitry Andric 
579cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path& operator+=(value_type __x) {
5800eae32dcSDimitry Andric     __pn_ += __x;
5810eae32dcSDimitry Andric     return *this;
5820eae32dcSDimitry Andric   }
5830eae32dcSDimitry Andric 
5845f757f3fSDimitry Andric   template <class _ECharT, __enable_if_t<__can_convert_char<_ECharT>::value, int> = 0>
585cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path& operator+=(_ECharT __x) {
586cb14a3feSDimitry Andric     _PathCVT<_ECharT>::__append_source(__pn_, basic_string_view<_ECharT>(&__x, 1));
5870eae32dcSDimitry Andric     return *this;
5880eae32dcSDimitry Andric   }
5890eae32dcSDimitry Andric 
5900eae32dcSDimitry Andric   template <class _Source>
591cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI _EnableIfPathable<_Source> operator+=(const _Source& __x) {
5920eae32dcSDimitry Andric     return this->concat(__x);
5930eae32dcSDimitry Andric   }
5940eae32dcSDimitry Andric 
5950eae32dcSDimitry Andric   template <class _Source>
596cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI _EnableIfPathable<_Source> concat(const _Source& __x) {
5970eae32dcSDimitry Andric     _SourceCVT<_Source>::__append_source(__pn_, __x);
5980eae32dcSDimitry Andric     return *this;
5990eae32dcSDimitry Andric   }
6000eae32dcSDimitry Andric 
6010eae32dcSDimitry Andric   template <class _InputIt>
602cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path& concat(_InputIt __first, _InputIt __last) {
6030eae32dcSDimitry Andric     typedef typename iterator_traits<_InputIt>::value_type _ItVal;
6040eae32dcSDimitry Andric     _PathCVT<_ItVal>::__append_range(__pn_, __first, __last);
6050eae32dcSDimitry Andric     return *this;
6060eae32dcSDimitry Andric   }
6070eae32dcSDimitry Andric 
6080eae32dcSDimitry Andric   // modifiers
609cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI void clear() noexcept { __pn_.clear(); }
6100eae32dcSDimitry Andric 
611cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path& make_preferred() {
6120eae32dcSDimitry Andric #  if defined(_LIBCPP_WIN32API)
6135f757f3fSDimitry Andric     std::replace(__pn_.begin(), __pn_.end(), L'/', L'\\');
6140eae32dcSDimitry Andric #  endif
6150eae32dcSDimitry Andric     return *this;
6160eae32dcSDimitry Andric   }
6170eae32dcSDimitry Andric 
618cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path& remove_filename() {
6190eae32dcSDimitry Andric     auto __fname = __filename();
6200eae32dcSDimitry Andric     if (!__fname.empty())
6210eae32dcSDimitry Andric       __pn_.erase(__fname.data() - __pn_.data());
6220eae32dcSDimitry Andric     return *this;
6230eae32dcSDimitry Andric   }
6240eae32dcSDimitry Andric 
625cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path& replace_filename(const path& __replacement) {
6260eae32dcSDimitry Andric     remove_filename();
6270eae32dcSDimitry Andric     return (*this /= __replacement);
6280eae32dcSDimitry Andric   }
6290eae32dcSDimitry Andric 
6300eae32dcSDimitry Andric   path& replace_extension(const path& __replacement = path());
6310eae32dcSDimitry Andric 
632bdd1243dSDimitry Andric   friend _LIBCPP_HIDE_FROM_ABI bool operator==(const path& __lhs, const path& __rhs) noexcept {
633bdd1243dSDimitry Andric     return __lhs.__compare(__rhs.__pn_) == 0;
634bdd1243dSDimitry Andric   }
635bdd1243dSDimitry Andric #  if _LIBCPP_STD_VER <= 17
636bdd1243dSDimitry Andric   friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const path& __lhs, const path& __rhs) noexcept {
637bdd1243dSDimitry Andric     return __lhs.__compare(__rhs.__pn_) != 0;
638bdd1243dSDimitry Andric   }
639bdd1243dSDimitry Andric   friend _LIBCPP_HIDE_FROM_ABI bool operator<(const path& __lhs, const path& __rhs) noexcept {
640bdd1243dSDimitry Andric     return __lhs.__compare(__rhs.__pn_) < 0;
641bdd1243dSDimitry Andric   }
642bdd1243dSDimitry Andric   friend _LIBCPP_HIDE_FROM_ABI bool operator<=(const path& __lhs, const path& __rhs) noexcept {
643bdd1243dSDimitry Andric     return __lhs.__compare(__rhs.__pn_) <= 0;
644bdd1243dSDimitry Andric   }
645bdd1243dSDimitry Andric   friend _LIBCPP_HIDE_FROM_ABI bool operator>(const path& __lhs, const path& __rhs) noexcept {
646bdd1243dSDimitry Andric     return __lhs.__compare(__rhs.__pn_) > 0;
647bdd1243dSDimitry Andric   }
648bdd1243dSDimitry Andric   friend _LIBCPP_HIDE_FROM_ABI bool operator>=(const path& __lhs, const path& __rhs) noexcept {
649bdd1243dSDimitry Andric     return __lhs.__compare(__rhs.__pn_) >= 0;
650bdd1243dSDimitry Andric   }
651bdd1243dSDimitry Andric #  else  // _LIBCPP_STD_VER <= 17
652bdd1243dSDimitry Andric   friend _LIBCPP_HIDE_FROM_ABI strong_ordering operator<=>(const path& __lhs, const path& __rhs) noexcept {
653bdd1243dSDimitry Andric     return __lhs.__compare(__rhs.__pn_) <=> 0;
654bdd1243dSDimitry Andric   }
655bdd1243dSDimitry Andric #  endif // _LIBCPP_STD_VER <= 17
656bdd1243dSDimitry Andric 
657bdd1243dSDimitry Andric   friend _LIBCPP_HIDE_FROM_ABI path operator/(const path& __lhs, const path& __rhs) {
658bdd1243dSDimitry Andric     path __result(__lhs);
659bdd1243dSDimitry Andric     __result /= __rhs;
660bdd1243dSDimitry Andric     return __result;
661bdd1243dSDimitry Andric   }
662bdd1243dSDimitry Andric 
663cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI void swap(path& __rhs) noexcept { __pn_.swap(__rhs.__pn_); }
6640eae32dcSDimitry Andric 
6650eae32dcSDimitry Andric   // private helper to allow reserving memory in the path
666cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI void __reserve(size_t __s) { __pn_.reserve(__s); }
6670eae32dcSDimitry Andric 
6680eae32dcSDimitry Andric   // native format observers
669cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI const string_type& native() const noexcept { return __pn_; }
6700eae32dcSDimitry Andric 
671cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI const value_type* c_str() const noexcept { return __pn_.c_str(); }
6720eae32dcSDimitry Andric 
67381ad6265SDimitry Andric   _LIBCPP_HIDE_FROM_ABI operator string_type() const { return __pn_; }
6740eae32dcSDimitry Andric 
6750eae32dcSDimitry Andric #  if defined(_LIBCPP_WIN32API)
6765f757f3fSDimitry Andric   _LIBCPP_HIDE_FROM_ABI std::wstring wstring() const { return __pn_; }
6770eae32dcSDimitry Andric 
678cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI std::wstring generic_wstring() const {
6795f757f3fSDimitry Andric     std::wstring __s;
6800eae32dcSDimitry Andric     __s.resize(__pn_.size());
6815f757f3fSDimitry Andric     std::replace_copy(__pn_.begin(), __pn_.end(), __s.begin(), '\\', '/');
6820eae32dcSDimitry Andric     return __s;
6830eae32dcSDimitry Andric   }
6840eae32dcSDimitry Andric 
6850eae32dcSDimitry Andric #    if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
686cb14a3feSDimitry Andric   template <class _ECharT, class _Traits = char_traits<_ECharT>, class _Allocator = allocator<_ECharT> >
687cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI basic_string<_ECharT, _Traits, _Allocator> string(const _Allocator& __a = _Allocator()) const {
6880eae32dcSDimitry Andric     using _Str = basic_string<_ECharT, _Traits, _Allocator>;
6890eae32dcSDimitry Andric     _Str __s(__a);
6900eae32dcSDimitry Andric     __s.reserve(__pn_.size());
6910eae32dcSDimitry Andric     _PathExport<_ECharT>::__append(__s, __pn_);
6920eae32dcSDimitry Andric     return __s;
6930eae32dcSDimitry Andric   }
6940eae32dcSDimitry Andric 
695cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI std::string string() const { return string<char>(); }
69681ad6265SDimitry Andric   _LIBCPP_HIDE_FROM_ABI __u8_string u8string() const {
6970eae32dcSDimitry Andric     using _CVT = __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__>;
6980eae32dcSDimitry Andric     __u8_string __s;
6990eae32dcSDimitry Andric     __s.reserve(__pn_.size());
7000eae32dcSDimitry Andric     _CVT()(back_inserter(__s), __pn_.data(), __pn_.data() + __pn_.size());
7010eae32dcSDimitry Andric     return __s;
7020eae32dcSDimitry Andric   }
7030eae32dcSDimitry Andric 
704cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI std::u16string u16string() const { return string<char16_t>(); }
705cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI std::u32string u32string() const { return string<char32_t>(); }
7060eae32dcSDimitry Andric 
7070eae32dcSDimitry Andric   // generic format observers
708cb14a3feSDimitry Andric   template <class _ECharT, class _Traits = char_traits<_ECharT>, class _Allocator = allocator<_ECharT> >
709cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI basic_string<_ECharT, _Traits, _Allocator>
7100eae32dcSDimitry Andric   generic_string(const _Allocator& __a = _Allocator()) const {
7110eae32dcSDimitry Andric     using _Str = basic_string<_ECharT, _Traits, _Allocator>;
7120eae32dcSDimitry Andric     _Str __s   = string<_ECharT, _Traits, _Allocator>(__a);
7130eae32dcSDimitry Andric     // Note: This (and generic_u8string below) is slightly suboptimal as
7140eae32dcSDimitry Andric     // it iterates twice over the string; once to convert it to the right
7150eae32dcSDimitry Andric     // character type, and once to replace path delimiters.
716cb14a3feSDimitry Andric     std::replace(__s.begin(), __s.end(), static_cast<_ECharT>('\\'), static_cast<_ECharT>('/'));
7170eae32dcSDimitry Andric     return __s;
7180eae32dcSDimitry Andric   }
7190eae32dcSDimitry Andric 
7205f757f3fSDimitry Andric   _LIBCPP_HIDE_FROM_ABI std::string generic_string() const { return generic_string<char>(); }
7215f757f3fSDimitry Andric   _LIBCPP_HIDE_FROM_ABI std::u16string generic_u16string() const { return generic_string<char16_t>(); }
7225f757f3fSDimitry Andric   _LIBCPP_HIDE_FROM_ABI std::u32string generic_u32string() const { return generic_string<char32_t>(); }
723cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI __u8_string generic_u8string() const {
7240eae32dcSDimitry Andric     __u8_string __s = u8string();
7255f757f3fSDimitry Andric     std::replace(__s.begin(), __s.end(), '\\', '/');
7260eae32dcSDimitry Andric     return __s;
7270eae32dcSDimitry Andric   }
7280eae32dcSDimitry Andric #    endif /* !_LIBCPP_HAS_NO_LOCALIZATION */
7290eae32dcSDimitry Andric #  else    /* _LIBCPP_WIN32API */
7300eae32dcSDimitry Andric 
7315f757f3fSDimitry Andric   _LIBCPP_HIDE_FROM_ABI std::string string() const { return __pn_; }
7320eae32dcSDimitry Andric #    ifndef _LIBCPP_HAS_NO_CHAR8_T
7335f757f3fSDimitry Andric   _LIBCPP_HIDE_FROM_ABI std::u8string u8string() const { return std::u8string(__pn_.begin(), __pn_.end()); }
7340eae32dcSDimitry Andric #    else
7355f757f3fSDimitry Andric   _LIBCPP_HIDE_FROM_ABI std::string u8string() const { return __pn_; }
7360eae32dcSDimitry Andric #    endif
7370eae32dcSDimitry Andric 
7380eae32dcSDimitry Andric #    if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
739cb14a3feSDimitry Andric   template <class _ECharT, class _Traits = char_traits<_ECharT>, class _Allocator = allocator<_ECharT> >
740cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI basic_string<_ECharT, _Traits, _Allocator> string(const _Allocator& __a = _Allocator()) const {
7410eae32dcSDimitry Andric     using _CVT = __widen_from_utf8<sizeof(_ECharT) * __CHAR_BIT__>;
7420eae32dcSDimitry Andric     using _Str = basic_string<_ECharT, _Traits, _Allocator>;
7430eae32dcSDimitry Andric     _Str __s(__a);
7440eae32dcSDimitry Andric     __s.reserve(__pn_.size());
745bdd1243dSDimitry Andric     _CVT()(std::back_inserter(__s), __pn_.data(), __pn_.data() + __pn_.size());
7460eae32dcSDimitry Andric     return __s;
7470eae32dcSDimitry Andric   }
7480eae32dcSDimitry Andric 
7490eae32dcSDimitry Andric #      ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
750cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI std::wstring wstring() const { return string<wchar_t>(); }
7510eae32dcSDimitry Andric #      endif
752cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI std::u16string u16string() const { return string<char16_t>(); }
753cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI std::u32string u32string() const { return string<char32_t>(); }
7540eae32dcSDimitry Andric #    endif /* !_LIBCPP_HAS_NO_LOCALIZATION */
7550eae32dcSDimitry Andric 
7560eae32dcSDimitry Andric   // generic format observers
7575f757f3fSDimitry Andric   _LIBCPP_HIDE_FROM_ABI std::string generic_string() const { return __pn_; }
7580eae32dcSDimitry Andric #    ifndef _LIBCPP_HAS_NO_CHAR8_T
7595f757f3fSDimitry Andric   _LIBCPP_HIDE_FROM_ABI std::u8string generic_u8string() const { return std::u8string(__pn_.begin(), __pn_.end()); }
7600eae32dcSDimitry Andric #    else
7615f757f3fSDimitry Andric   _LIBCPP_HIDE_FROM_ABI std::string generic_u8string() const { return __pn_; }
7620eae32dcSDimitry Andric #    endif
7630eae32dcSDimitry Andric 
7640eae32dcSDimitry Andric #    if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
765cb14a3feSDimitry Andric   template <class _ECharT, class _Traits = char_traits<_ECharT>, class _Allocator = allocator<_ECharT> >
766cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI basic_string<_ECharT, _Traits, _Allocator>
7670eae32dcSDimitry Andric   generic_string(const _Allocator& __a = _Allocator()) const {
7680eae32dcSDimitry Andric     return string<_ECharT, _Traits, _Allocator>(__a);
7690eae32dcSDimitry Andric   }
7700eae32dcSDimitry Andric 
7710eae32dcSDimitry Andric #      ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
7725f757f3fSDimitry Andric   _LIBCPP_HIDE_FROM_ABI std::wstring generic_wstring() const { return string<wchar_t>(); }
7730eae32dcSDimitry Andric #      endif
7745f757f3fSDimitry Andric   _LIBCPP_HIDE_FROM_ABI std::u16string generic_u16string() const { return string<char16_t>(); }
7755f757f3fSDimitry Andric   _LIBCPP_HIDE_FROM_ABI std::u32string generic_u32string() const { return string<char32_t>(); }
7760eae32dcSDimitry Andric #    endif /* !_LIBCPP_HAS_NO_LOCALIZATION */
7770eae32dcSDimitry Andric #  endif   /* !_LIBCPP_WIN32API */
7780eae32dcSDimitry Andric 
7790eae32dcSDimitry Andric private:
7800eae32dcSDimitry Andric   int __compare(__string_view) const;
7810eae32dcSDimitry Andric   __string_view __root_name() const;
7820eae32dcSDimitry Andric   __string_view __root_directory() const;
7830eae32dcSDimitry Andric   __string_view __root_path_raw() const;
7840eae32dcSDimitry Andric   __string_view __relative_path() const;
7850eae32dcSDimitry Andric   __string_view __parent_path() const;
7860eae32dcSDimitry Andric   __string_view __filename() const;
7870eae32dcSDimitry Andric   __string_view __stem() const;
7880eae32dcSDimitry Andric   __string_view __extension() const;
7890eae32dcSDimitry Andric 
7900eae32dcSDimitry Andric public:
7910eae32dcSDimitry Andric   // compare
792cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI int compare(const path& __p) const noexcept { return __compare(__p.__pn_); }
793cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI int compare(const string_type& __s) const { return __compare(__s); }
794cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI int compare(__string_view __s) const { return __compare(__s); }
795cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI int compare(const value_type* __s) const { return __compare(__s); }
7960eae32dcSDimitry Andric 
7970eae32dcSDimitry Andric   // decomposition
798cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path root_name() const { return string_type(__root_name()); }
799cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path root_directory() const { return string_type(__root_directory()); }
80081ad6265SDimitry Andric   _LIBCPP_HIDE_FROM_ABI path root_path() const {
8010eae32dcSDimitry Andric #  if defined(_LIBCPP_WIN32API)
8020eae32dcSDimitry Andric     return string_type(__root_path_raw());
8030eae32dcSDimitry Andric #  else
8040eae32dcSDimitry Andric     return root_name().append(string_type(__root_directory()));
8050eae32dcSDimitry Andric #  endif
8060eae32dcSDimitry Andric   }
807cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path relative_path() const { return string_type(__relative_path()); }
808cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path parent_path() const { return string_type(__parent_path()); }
809cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path filename() const { return string_type(__filename()); }
81081ad6265SDimitry Andric   _LIBCPP_HIDE_FROM_ABI path stem() const { return string_type(__stem()); }
811cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI path extension() const { return string_type(__extension()); }
8120eae32dcSDimitry Andric 
8130eae32dcSDimitry Andric   // query
814*0fca6ea1SDimitry Andric   _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const noexcept { return __pn_.empty(); }
8150eae32dcSDimitry Andric 
816cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI bool has_root_name() const { return !__root_name().empty(); }
817cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI bool has_root_directory() const { return !__root_directory().empty(); }
818cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI bool has_root_path() const { return !__root_path_raw().empty(); }
819cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI bool has_relative_path() const { return !__relative_path().empty(); }
820cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI bool has_parent_path() const { return !__parent_path().empty(); }
821cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI bool has_filename() const { return !__filename().empty(); }
82281ad6265SDimitry Andric   _LIBCPP_HIDE_FROM_ABI bool has_stem() const { return !__stem().empty(); }
823cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI bool has_extension() const { return !__extension().empty(); }
8240eae32dcSDimitry Andric 
82581ad6265SDimitry Andric   _LIBCPP_HIDE_FROM_ABI bool is_absolute() const {
8260eae32dcSDimitry Andric #  if defined(_LIBCPP_WIN32API)
8270eae32dcSDimitry Andric     __string_view __root_name_str = __root_name();
8280eae32dcSDimitry Andric     __string_view __root_dir      = __root_directory();
8290eae32dcSDimitry Andric     if (__root_name_str.size() == 2 && __root_name_str[1] == ':') {
8300eae32dcSDimitry Andric       // A drive letter with no root directory is relative, e.g. x:example.
8310eae32dcSDimitry Andric       return !__root_dir.empty();
8320eae32dcSDimitry Andric     }
8330eae32dcSDimitry Andric     // If no root name, it's relative, e.g. \example is relative to the current drive
8340eae32dcSDimitry Andric     if (__root_name_str.empty())
8350eae32dcSDimitry Andric       return false;
8360eae32dcSDimitry Andric     if (__root_name_str.size() < 3)
8370eae32dcSDimitry Andric       return false;
8380eae32dcSDimitry Andric     // A server root name, like \\server, is always absolute
8390eae32dcSDimitry Andric     if (__root_name_str[0] != '/' && __root_name_str[0] != '\\')
8400eae32dcSDimitry Andric       return false;
8410eae32dcSDimitry Andric     if (__root_name_str[1] != '/' && __root_name_str[1] != '\\')
8420eae32dcSDimitry Andric       return false;
8430eae32dcSDimitry Andric     // Seems to be a server root name
8440eae32dcSDimitry Andric     return true;
8450eae32dcSDimitry Andric #  else
8460eae32dcSDimitry Andric     return has_root_directory();
8470eae32dcSDimitry Andric #  endif
8480eae32dcSDimitry Andric   }
84981ad6265SDimitry Andric   _LIBCPP_HIDE_FROM_ABI bool is_relative() const { return !is_absolute(); }
8500eae32dcSDimitry Andric 
8510eae32dcSDimitry Andric   // relative paths
8520eae32dcSDimitry Andric   path lexically_normal() const;
8530eae32dcSDimitry Andric   path lexically_relative(const path& __base) const;
8540eae32dcSDimitry Andric 
85581ad6265SDimitry Andric   _LIBCPP_HIDE_FROM_ABI path lexically_proximate(const path& __base) const {
8560eae32dcSDimitry Andric     path __result = this->lexically_relative(__base);
8570eae32dcSDimitry Andric     if (__result.native().empty())
8580eae32dcSDimitry Andric       return *this;
8590eae32dcSDimitry Andric     return __result;
8600eae32dcSDimitry Andric   }
8610eae32dcSDimitry Andric 
8620eae32dcSDimitry Andric   // iterators
86306c3fb27SDimitry Andric   class _LIBCPP_EXPORTED_FROM_ABI iterator;
8640eae32dcSDimitry Andric   typedef iterator const_iterator;
8650eae32dcSDimitry Andric 
8660eae32dcSDimitry Andric   iterator begin() const;
8670eae32dcSDimitry Andric   iterator end() const;
8680eae32dcSDimitry Andric 
8690eae32dcSDimitry Andric #  if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
870cb14a3feSDimitry Andric   template <
871cb14a3feSDimitry Andric       class _CharT,
872cb14a3feSDimitry Andric       class _Traits,
873cb14a3feSDimitry Andric       __enable_if_t<is_same<_CharT, value_type>::value && is_same<_Traits, char_traits<value_type> >::value, int> = 0>
874cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI friend basic_ostream<_CharT, _Traits>&
8750eae32dcSDimitry Andric   operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) {
8765f757f3fSDimitry Andric     __os << std::__quoted(__p.native());
8770eae32dcSDimitry Andric     return __os;
8780eae32dcSDimitry Andric   }
8790eae32dcSDimitry Andric 
880cb14a3feSDimitry Andric   template <
881cb14a3feSDimitry Andric       class _CharT,
882cb14a3feSDimitry Andric       class _Traits,
883cb14a3feSDimitry Andric       __enable_if_t<!is_same<_CharT, value_type>::value || !is_same<_Traits, char_traits<value_type> >::value, int> = 0>
884cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI friend basic_ostream<_CharT, _Traits>&
8850eae32dcSDimitry Andric   operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) {
8865f757f3fSDimitry Andric     __os << std::__quoted(__p.string<_CharT, _Traits>());
8870eae32dcSDimitry Andric     return __os;
8880eae32dcSDimitry Andric   }
8890eae32dcSDimitry Andric 
8900eae32dcSDimitry Andric   template <class _CharT, class _Traits>
89181ad6265SDimitry Andric   _LIBCPP_HIDE_FROM_ABI friend basic_istream<_CharT, _Traits>&
8920eae32dcSDimitry Andric   operator>>(basic_istream<_CharT, _Traits>& __is, path& __p) {
8930eae32dcSDimitry Andric     basic_string<_CharT, _Traits> __tmp;
8945f757f3fSDimitry Andric     __is >> std::__quoted(__tmp);
8950eae32dcSDimitry Andric     __p = __tmp;
8960eae32dcSDimitry Andric     return __is;
8970eae32dcSDimitry Andric   }
8980eae32dcSDimitry Andric #  endif // !_LIBCPP_HAS_NO_LOCALIZATION
8990eae32dcSDimitry Andric 
9000eae32dcSDimitry Andric private:
9015f757f3fSDimitry Andric   inline _LIBCPP_HIDE_FROM_ABI path& __assign_view(__string_view const& __s) {
9020eae32dcSDimitry Andric     __pn_ = string_type(__s);
9030eae32dcSDimitry Andric     return *this;
9040eae32dcSDimitry Andric   }
9050eae32dcSDimitry Andric   string_type __pn_;
9060eae32dcSDimitry Andric };
9070eae32dcSDimitry Andric 
908cb14a3feSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI void swap(path& __lhs, path& __rhs) noexcept { __lhs.swap(__rhs); }
9090eae32dcSDimitry Andric 
91006c3fb27SDimitry Andric _LIBCPP_EXPORTED_FROM_ABI size_t hash_value(const path& __p) noexcept;
9110eae32dcSDimitry Andric 
91206c3fb27SDimitry Andric _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP
9130eae32dcSDimitry Andric 
9140eae32dcSDimitry Andric _LIBCPP_END_NAMESPACE_FILESYSTEM
9150eae32dcSDimitry Andric 
91606c3fb27SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
91706c3fb27SDimitry Andric 
91806c3fb27SDimitry Andric template <>
9195f757f3fSDimitry Andric struct _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY hash<filesystem::path> : __unary_function<filesystem::path, size_t> {
9205f757f3fSDimitry Andric   _LIBCPP_HIDE_FROM_ABI size_t operator()(filesystem::path const& __p) const noexcept {
9215f757f3fSDimitry Andric     return filesystem::hash_value(__p);
92206c3fb27SDimitry Andric   }
92306c3fb27SDimitry Andric };
92406c3fb27SDimitry Andric 
92506c3fb27SDimitry Andric _LIBCPP_END_NAMESPACE_STD
92606c3fb27SDimitry Andric 
9275f757f3fSDimitry Andric #endif // _LIBCPP_STD_VER >= 17
9280eae32dcSDimitry Andric 
929b3edf446SDimitry Andric _LIBCPP_POP_MACROS
930b3edf446SDimitry Andric 
9310eae32dcSDimitry Andric #endif // _LIBCPP___FILESYSTEM_PATH_H
932