libstdc++
bits/fs_path.h
Go to the documentation of this file.
1 // Class filesystem::path -*- C++ -*-
2 
3 // Copyright (C) 2014-2020 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
10 
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
19 
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
24 
25 /** @file include/bits/fs_path.h
26  * This is an internal header file, included by other library headers.
27  * Do not attempt to use it directly. @headername{filesystem}
28  */
29 
30 #ifndef _GLIBCXX_FS_PATH_H
31 #define _GLIBCXX_FS_PATH_H 1
32 
33 #if __cplusplus >= 201703L
34 
35 #include <utility>
36 #include <type_traits>
37 #include <locale>
38 #include <iosfwd>
39 #include <iomanip>
40 #include <codecvt>
41 #include <string_view>
42 #include <system_error>
43 #include <bits/stl_algobase.h>
44 #include <bits/locale_conv.h>
45 #include <ext/concurrence.h>
46 #include <bits/shared_ptr.h>
47 #include <bits/unique_ptr.h>
48 
49 #if __cplusplus > 201703L
50 # include <compare>
51 #endif
52 
53 #if defined(_WIN32) && !defined(__CYGWIN__)
54 # define _GLIBCXX_FILESYSTEM_IS_WINDOWS 1
55 # include <algorithm>
56 #endif
57 
58 namespace std _GLIBCXX_VISIBILITY(default)
59 {
60 _GLIBCXX_BEGIN_NAMESPACE_VERSION
61 
62 namespace filesystem
63 {
64 _GLIBCXX_BEGIN_NAMESPACE_CXX11
65 
66  /** @addtogroup filesystem
67  * @{
68  */
69 
70  class path;
71 
72  /// @cond undocumented
73 namespace __detail
74 {
75  template<typename _CharT>
76  inline constexpr bool __is_encoded_char = false;
77  template<>
78  inline constexpr bool __is_encoded_char<char> = true;
79 #ifdef _GLIBCXX_USE_CHAR8_T
80  template<>
81  inline constexpr bool __is_encoded_char<char8_t> = true;
82 #endif
83 #if _GLIBCXX_USE_WCHAR_T
84  template<>
85  inline constexpr bool __is_encoded_char<wchar_t> = true;
86 #endif
87  template<>
88  inline constexpr bool __is_encoded_char<char16_t> = true;
89  template<>
90  inline constexpr bool __is_encoded_char<char32_t> = true;
91 
92 #if __cpp_concepts >= 201907L
93  template<typename _Iter>
94  using __safe_iterator_traits = std::iterator_traits<_Iter>;
95 #else
96  template<typename _Iter>
97  struct __safe_iterator_traits : std::iterator_traits<_Iter>
98  { };
99 
100  // Protect against ill-formed iterator_traits specializations in C++17
101  template<> struct __safe_iterator_traits<void*> { };
102  template<> struct __safe_iterator_traits<const void*> { };
103  template<> struct __safe_iterator_traits<volatile void*> { };
104  template<> struct __safe_iterator_traits<const volatile void*> { };
105 #endif
106 
107  template<typename _Iter_traits, typename = void>
108  struct __is_path_iter_src
109  : false_type
110  { };
111 
112  template<typename _Iter_traits>
113  struct __is_path_iter_src<_Iter_traits,
114  void_t<typename _Iter_traits::value_type>>
115  : bool_constant<__is_encoded_char<typename _Iter_traits::value_type>>
116  { };
117 
118  template<typename _Source>
119  inline constexpr bool __is_path_src
120  = __is_path_iter_src<iterator_traits<decay_t<_Source>>>::value;
121 
122  template<>
123  inline constexpr bool __is_path_src<path> = false;
124 
125  template<>
126  inline constexpr bool __is_path_src<volatile path> = false;
127 
128  template<>
129  inline constexpr bool __is_path_src<void*> = false;
130 
131  template<>
132  inline constexpr bool __is_path_src<const void*> = false;
133 
134  template<>
135  inline constexpr bool __is_path_src<volatile void*> = false;
136 
137  template<>
138  inline constexpr bool __is_path_src<const volatile void*> = false;
139 
140  template<typename _CharT, typename _Traits, typename _Alloc>
141  inline constexpr bool
142  __is_path_src<basic_string<_CharT, _Traits, _Alloc>>
143  = __is_encoded_char<_CharT>;
144 
145  template<typename _CharT, typename _Traits>
146  inline constexpr bool
147  __is_path_src<basic_string_view<_CharT, _Traits>>
148  = __is_encoded_char<_CharT>;
149 
150  // SFINAE constraint for Source parameters as required by [fs.path.req].
151  template<typename _Tp>
152  using _Path = enable_if_t<__is_path_src<_Tp>, path>;
153 
154  // SFINAE constraint for InputIterator parameters as required by [fs.req].
155  template<typename _Iter, typename _Tr = __safe_iterator_traits<_Iter>>
156  using _Path2 = enable_if_t<__is_path_iter_src<_Tr>::value, path>;
157 
158  // The __effective_range overloads convert a Source parameter into
159  // either a basic_string_view or basic_string containing the
160  // effective range of the Source, as defined in [fs.path.req].
161 
162  template<typename _CharT, typename _Traits, typename _Alloc>
163  inline basic_string_view<_CharT, _Traits>
164  __effective_range(const basic_string<_CharT, _Traits, _Alloc>& __source)
165  { return __source; }
166 
167  template<typename _CharT, typename _Traits>
168  inline const basic_string_view<_CharT, _Traits>&
169  __effective_range(const basic_string_view<_CharT, _Traits>& __source)
170  { return __source; }
171 
172  template<typename _Source>
173  inline auto
174  __effective_range(const _Source& __source)
175  {
176  if constexpr (is_pointer_v<decay_t<_Source>>)
177  return basic_string_view{&*__source};
178  else
179  {
180  // _Source is an input iterator that iterates over an NTCTS.
181  // Create a basic_string by reading until the null character.
182  using value_type
183  = typename iterator_traits<_Source>::value_type;
184  basic_string<value_type> __str;
185  _Source __it = __source;
186  for (value_type __ch = *__it; __ch != value_type(); __ch = *++__it)
187  __str.push_back(__ch);
188  return __str;
189  }
190  }
191 
192  // The value type of a Source parameter's effective range.
193  template<typename _Tp>
194  using __value_t = typename remove_reference_t<
195  decltype(__detail::__effective_range(std::declval<_Tp>()))>::value_type;
196 
197  // SFINAE helper to check that an effective range has value_type char,
198  // as required by path constructors taking a std::locale parameter.
199  // The type _Tp must have already been checked by _Path<Tp> or _Path2<_Tp>.
200  template<typename _Tp, typename _Val = __value_t<_Tp>>
201  using __value_type_is_char
203 
204  // As above, but also allows char8_t, as required by u8path
205  // C++20 [depr.fs.path.factory]
206  template<typename _Tp, typename _Val = __value_t<_Tp>>
207  using __value_type_is_char_or_char8_t
209 #ifdef _GLIBCXX_USE_CHAR8_T
210  || std::is_same_v<_Val, char8_t>
211 #endif
212  , _Val>;
213 
214  // Create a string or string view from an iterator range.
215  template<typename _InputIterator>
216  inline auto
217  __string_from_range(_InputIterator __first, _InputIterator __last)
218  {
219  using _EcharT
221  static_assert(__is_encoded_char<_EcharT>);
222 
223 #if __cpp_lib_concepts
224  constexpr bool __contiguous = std::contiguous_iterator<_InputIterator>;
225 #else
226  constexpr bool __contiguous
227  = is_pointer_v<decltype(std::__niter_base(__first))>;
228 #endif
229  if constexpr (__contiguous)
230  {
231  // For contiguous iterators we can just return a string view.
232  const auto* __f = std::__to_address(std::__niter_base(__first));
233  const auto* __l = std::__to_address(std::__niter_base(__last));
234  return basic_string_view<_EcharT>(__f, __l - __f);
235  }
236  else
237  // Conversion requires contiguous characters, so create a string.
238  return basic_string<_EcharT>(__first, __last);
239  }
240 
241 #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
242  template<typename _Tp>
243  inline std::wstring
244  __wstr_from_utf8(const _Tp& __str)
245  {
246  static_assert(std::is_same_v<typename _Tp::value_type, char>);
247  std::wstring __wstr;
248  // XXX This assumes native wide encoding is UTF-16.
249  std::codecvt_utf8_utf16<wchar_t> __wcvt;
250  const auto __p = __str.data();
251  if (!__str_codecvt_in_all(__p, __p + __str.size(), __wstr, __wcvt))
252  _GLIBCXX_THROW_OR_ABORT(filesystem_error(
253  "Cannot convert character sequence",
254  std::make_error_code(errc::illegal_byte_sequence)));
255  return __wstr;
256  }
257 #endif
258 
259 } // namespace __detail
260  /// @endcond
261 
262  /// A filesystem path.
263  class path
264  {
265  public:
266 #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
267  using value_type = wchar_t;
268  static constexpr value_type preferred_separator = L'\\';
269 #else
270 # ifdef _GLIBCXX_DOXYGEN
271  /// Windows uses wchar_t for path::value_type, POSIX uses char.
272  using value_type = __os_dependent__;
273 # else
274  using value_type = char;
275 # endif
276  static constexpr value_type preferred_separator = '/';
277 #endif
279 
280  /// path::format is ignored in this implementation
281  enum format : unsigned char { native_format, generic_format, auto_format };
282 
283  // constructors and destructor
284 
285  path() noexcept { }
286 
287  path(const path& __p) = default;
288 
289  path(path&& __p)
290 #if _GLIBCXX_USE_CXX11_ABI || _GLIBCXX_FULLY_DYNAMIC_STRING == 0
291  noexcept
292 #endif
293  : _M_pathname(std::move(__p._M_pathname)),
294  _M_cmpts(std::move(__p._M_cmpts))
295  { __p.clear(); }
296 
297  path(string_type&& __source, format = auto_format)
298  : _M_pathname(std::move(__source))
299  { _M_split_cmpts(); }
300 
301  template<typename _Source,
302  typename _Require = __detail::_Path<_Source>>
303  path(_Source const& __source, format = auto_format)
304  : _M_pathname(_S_convert(__detail::__effective_range(__source)))
305  { _M_split_cmpts(); }
306 
307  template<typename _InputIterator,
308  typename _Require = __detail::_Path2<_InputIterator>>
309  path(_InputIterator __first, _InputIterator __last, format = auto_format)
310  : _M_pathname(_S_convert(__first, __last))
311  { _M_split_cmpts(); }
312 
313  template<typename _Source,
314  typename _Require = __detail::_Path<_Source>,
315  typename _Require2 = __detail::__value_type_is_char<_Source>>
316  path(_Source const& __src, const locale& __loc, format = auto_format)
317  : _M_pathname(_S_convert_loc(__detail::__effective_range(__src), __loc))
318  { _M_split_cmpts(); }
319 
320  template<typename _InputIterator,
321  typename _Require = __detail::_Path2<_InputIterator>,
322  typename _Req2 = __detail::__value_type_is_char<_InputIterator>>
323  path(_InputIterator __first, _InputIterator __last, const locale& __loc,
324  format = auto_format)
325  : _M_pathname(_S_convert_loc(__first, __last, __loc))
326  { _M_split_cmpts(); }
327 
328  ~path() = default;
329 
330  // assignments
331 
332  path& operator=(const path&);
333  path& operator=(path&&) noexcept;
334  path& operator=(string_type&& __source);
335  path& assign(string_type&& __source);
336 
337  template<typename _Source>
338  __detail::_Path<_Source>&
339  operator=(_Source const& __source)
340  { return *this = path(__source); }
341 
342  template<typename _Source>
343  __detail::_Path<_Source>&
344  assign(_Source const& __source)
345  { return *this = path(__source); }
346 
347  template<typename _InputIterator>
348  __detail::_Path2<_InputIterator>&
349  assign(_InputIterator __first, _InputIterator __last)
350  { return *this = path(__first, __last); }
351 
352  // appends
353 
354  path& operator/=(const path& __p);
355 
356  template<typename _Source>
357  __detail::_Path<_Source>&
358  operator/=(_Source const& __source)
359  {
360  _M_append(_S_convert(__detail::__effective_range(__source)));
361  return *this;
362  }
363 
364  template<typename _Source>
365  __detail::_Path<_Source>&
366  append(_Source const& __source)
367  {
368  _M_append(_S_convert(__detail::__effective_range(__source)));
369  return *this;
370  }
371 
372  template<typename _InputIterator>
373  __detail::_Path2<_InputIterator>&
374  append(_InputIterator __first, _InputIterator __last)
375  {
376  _M_append(_S_convert(__first, __last));
377  return *this;
378  }
379 
380  // concatenation
381 
382  path& operator+=(const path& __x);
383  path& operator+=(const string_type& __x);
384  path& operator+=(const value_type* __x);
385  path& operator+=(value_type __x);
386  path& operator+=(basic_string_view<value_type> __x);
387 
388  template<typename _Source>
389  __detail::_Path<_Source>&
390  operator+=(_Source const& __x) { return concat(__x); }
391 
392  template<typename _CharT>
393  __detail::_Path2<_CharT*>&
394  operator+=(_CharT __x);
395 
396  template<typename _Source>
397  __detail::_Path<_Source>&
398  concat(_Source const& __x)
399  {
400  _M_concat(_S_convert(__detail::__effective_range(__x)));
401  return *this;
402  }
403 
404  template<typename _InputIterator>
405  __detail::_Path2<_InputIterator>&
406  concat(_InputIterator __first, _InputIterator __last)
407  {
408  _M_concat(_S_convert(__first, __last));
409  return *this;
410  }
411 
412  // modifiers
413 
414  void clear() noexcept { _M_pathname.clear(); _M_split_cmpts(); }
415 
416  path& make_preferred();
417  path& remove_filename();
418  path& replace_filename(const path& __replacement);
419  path& replace_extension(const path& __replacement = path());
420 
421  void swap(path& __rhs) noexcept;
422 
423  // native format observers
424 
425  const string_type& native() const noexcept { return _M_pathname; }
426  const value_type* c_str() const noexcept { return _M_pathname.c_str(); }
427  operator string_type() const { return _M_pathname; }
428 
429  template<typename _CharT, typename _Traits = std::char_traits<_CharT>,
430  typename _Allocator = std::allocator<_CharT>>
432  string(const _Allocator& __a = _Allocator()) const;
433 
434  std::string string() const;
435 #if _GLIBCXX_USE_WCHAR_T
436  std::wstring wstring() const;
437 #endif
438 #ifdef _GLIBCXX_USE_CHAR8_T
439  __attribute__((__abi_tag__("__u8")))
440  std::u8string u8string() const;
441 #else
442  std::string u8string() const;
443 #endif // _GLIBCXX_USE_CHAR8_T
444  std::u16string u16string() const;
445  std::u32string u32string() const;
446 
447  // generic format observers
448  template<typename _CharT, typename _Traits = std::char_traits<_CharT>,
449  typename _Allocator = std::allocator<_CharT>>
451  generic_string(const _Allocator& __a = _Allocator()) const;
452 
453  std::string generic_string() const;
454 #if _GLIBCXX_USE_WCHAR_T
455  std::wstring generic_wstring() const;
456 #endif
457 #ifdef _GLIBCXX_USE_CHAR8_T
458  __attribute__((__abi_tag__("__u8")))
459  std::u8string generic_u8string() const;
460 #else
461  std::string generic_u8string() const;
462 #endif // _GLIBCXX_USE_CHAR8_T
463  std::u16string generic_u16string() const;
464  std::u32string generic_u32string() const;
465 
466  // compare
467 
468  int compare(const path& __p) const noexcept;
469  int compare(const string_type& __s) const noexcept;
470  int compare(const value_type* __s) const noexcept;
471  int compare(basic_string_view<value_type> __s) const noexcept;
472 
473  // decomposition
474 
475  path root_name() const;
476  path root_directory() const;
477  path root_path() const;
478  path relative_path() const;
479  path parent_path() const;
480  path filename() const;
481  path stem() const;
482  path extension() const;
483 
484  // query
485 
486  [[nodiscard]] bool empty() const noexcept { return _M_pathname.empty(); }
487  bool has_root_name() const noexcept;
488  bool has_root_directory() const noexcept;
489  bool has_root_path() const noexcept;
490  bool has_relative_path() const noexcept;
491  bool has_parent_path() const noexcept;
492  bool has_filename() const noexcept;
493  bool has_stem() const noexcept;
494  bool has_extension() const noexcept;
495  bool is_absolute() const noexcept;
496  bool is_relative() const noexcept { return !is_absolute(); }
497 
498  // generation
499  path lexically_normal() const;
500  path lexically_relative(const path& base) const;
501  path lexically_proximate(const path& base) const;
502 
503  // iterators
504  class iterator;
505  using const_iterator = iterator;
506 
507  iterator begin() const;
508  iterator end() const;
509 
510  /// Write a path to a stream
511  template<typename _CharT, typename _Traits>
514  {
515  __os << std::quoted(__p.string<_CharT, _Traits>());
516  return __os;
517  }
518 
519  /// Read a path from a stream
520  template<typename _CharT, typename _Traits>
523  {
525  if (__is >> std::quoted(__tmp))
526  __p = std::move(__tmp);
527  return __is;
528  }
529 
530  // non-member operators
531 
532  /// Compare paths
533  friend bool operator==(const path& __lhs, const path& __rhs) noexcept
534  { return __lhs.compare(__rhs) == 0; }
535 
536 #if __cpp_lib_three_way_comparison
537  /// Compare paths
538  friend strong_ordering
539  operator<=>(const path& __lhs, const path& __rhs) noexcept
540  { return __lhs.compare(__rhs) <=> 0; }
541 #else
542  /// Compare paths
543  friend bool operator!=(const path& __lhs, const path& __rhs) noexcept
544  { return !(__lhs == __rhs); }
545 
546  /// Compare paths
547  friend bool operator<(const path& __lhs, const path& __rhs) noexcept
548  { return __lhs.compare(__rhs) < 0; }
549 
550  /// Compare paths
551  friend bool operator<=(const path& __lhs, const path& __rhs) noexcept
552  { return !(__rhs < __lhs); }
553 
554  /// Compare paths
555  friend bool operator>(const path& __lhs, const path& __rhs) noexcept
556  { return __rhs < __lhs; }
557 
558  /// Compare paths
559  friend bool operator>=(const path& __lhs, const path& __rhs) noexcept
560  { return !(__lhs < __rhs); }
561 #endif
562 
563  /// Append one path to another
564  friend path operator/(const path& __lhs, const path& __rhs)
565  {
566  path __result(__lhs);
567  __result /= __rhs;
568  return __result;
569  }
570 
571  private:
572  enum class _Type : unsigned char {
573  _Multi = 0, _Root_name, _Root_dir, _Filename
574  };
575 
576  path(basic_string_view<value_type> __str, _Type __type)
577  : _M_pathname(__str)
578  {
579  __glibcxx_assert(__type != _Type::_Multi);
580  _M_cmpts.type(__type);
581  }
582 
583  enum class _Split { _Stem, _Extension };
584 
585  void _M_append(basic_string_view<value_type>);
586  void _M_concat(basic_string_view<value_type>);
587 
588  pair<const string_type*, size_t> _M_find_extension() const noexcept;
589 
590  // path::_S_convert creates a basic_string<value_type> or
591  // basic_string_view<value_type> from a range (either the effective
592  // range of a Source parameter, or a pair of InputIterator parameters),
593  // performing the conversions required by [fs.path.type.cvt].
594  // If the value_type of the range value type is path::value_type,
595  // no encoding conversion is performed. If the range is contiguous
596  // a string_view
597 
598  static string_type
599  _S_convert(string_type __str)
600  { return __str; }
601 
602  template<typename _Tp>
603  static auto
604  _S_convert(const _Tp& __str)
605  {
606  if constexpr (is_same_v<_Tp, string_type>)
607  return __str;
608  else if constexpr (is_same_v<_Tp, basic_string_view<value_type>>)
609  return __str;
610  else if constexpr (is_same_v<typename _Tp::value_type, value_type>)
611  return basic_string_view<value_type>(__str.data(), __str.size());
612  else
613  return _S_convert(__str.data(), __str.data() + __str.size());
614  }
615 
616  template<typename _EcharT>
617  static auto
618  _S_convert(const _EcharT* __first, const _EcharT* __last);
619 
620  template<typename _Iter>
621  static auto
622  _S_convert(_Iter __first, _Iter __last)
623  { return _S_convert(__detail::__string_from_range(__first, __last)); }
624 
625  static string_type
626  _S_convert_loc(const char* __first, const char* __last,
627  const std::locale& __loc);
628 
629  template<typename _Iter>
630  static string_type
631  _S_convert_loc(_Iter __first, _Iter __last, const std::locale& __loc)
632  {
633  const auto __s = __detail::__string_from_range(__first, __last);
634  return _S_convert_loc(__s.data(), __s.data() + __s.size(), __loc);
635  }
636 
637  template<typename _Tp>
638  static string_type
639  _S_convert_loc(const _Tp& __s, const std::locale& __loc)
640  {
641  return _S_convert_loc(__s.data(), __s.data() + __s.size(), __loc);
642  }
643 
644  template<typename _CharT, typename _Traits, typename _Allocator>
645  static basic_string<_CharT, _Traits, _Allocator>
646  _S_str_convert(basic_string_view<value_type>, const _Allocator&);
647 
648  void _M_split_cmpts();
649 
650  _Type _M_type() const noexcept { return _M_cmpts.type(); }
651 
652  string_type _M_pathname;
653 
654  struct _Cmpt;
655 
656  struct _List
657  {
658  using value_type = _Cmpt;
659  using iterator = value_type*;
660  using const_iterator = const value_type*;
661 
662  _List();
663  _List(const _List&);
664  _List(_List&&) = default;
665  _List& operator=(const _List&);
666  _List& operator=(_List&&) = default;
667  ~_List() = default;
668 
669  _Type type() const noexcept
670  { return _Type(reinterpret_cast<uintptr_t>(_M_impl.get()) & 0x3); }
671 
672  void type(_Type) noexcept;
673 
674  int size() const noexcept; // zero unless type() == _Type::_Multi
675  bool empty() const noexcept; // true unless type() == _Type::_Multi
676  void clear();
677  void swap(_List& __l) noexcept { _M_impl.swap(__l._M_impl); }
678  int capacity() const noexcept;
679  void reserve(int, bool); ///< @pre type() == _Type::_Multi
680 
681  // All the member functions below here have a precondition !empty()
682  // (and they should only be called from within the library).
683 
684  iterator begin() noexcept;
685  iterator end() noexcept;
686  const_iterator begin() const noexcept;
687  const_iterator end() const noexcept;
688 
689  value_type& front() noexcept;
690  value_type& back() noexcept;
691  const value_type& front() const noexcept;
692  const value_type& back() const noexcept;
693 
694  void pop_back();
695  void _M_erase_from(const_iterator __pos); // erases [__pos,end())
696 
697  struct _Impl;
698  struct _Impl_deleter
699  {
700  void operator()(_Impl*) const noexcept;
701  };
703  };
704  _List _M_cmpts;
705 
706  struct _Parser;
707  };
708 
709  /// @relates std::filesystem::path @{
710 
711  inline void swap(path& __lhs, path& __rhs) noexcept { __lhs.swap(__rhs); }
712 
713  size_t hash_value(const path& __p) noexcept;
714 
715  /// @}
716 
717  /// Exception type thrown by the Filesystem library
719  {
720  public:
721  filesystem_error(const string& __what_arg, error_code __ec);
722 
723  filesystem_error(const string& __what_arg, const path& __p1,
724  error_code __ec);
725 
726  filesystem_error(const string& __what_arg, const path& __p1,
727  const path& __p2, error_code __ec);
728 
729  filesystem_error(const filesystem_error&) = default;
730  filesystem_error& operator=(const filesystem_error&) = default;
731 
732  // No move constructor or assignment operator.
733  // Copy rvalues instead, so that _M_impl is not left empty.
734 
735  ~filesystem_error();
736 
737  const path& path1() const noexcept;
738  const path& path2() const noexcept;
739  const char* what() const noexcept;
740 
741  private:
742  struct _Impl;
743  std::__shared_ptr<const _Impl> _M_impl;
744  };
745 
746  /** Create a path from a UTF-8-encoded sequence of char
747  *
748  * @relates std::filesystem::path
749  */
750  template<typename _InputIterator,
751  typename _Require = __detail::_Path2<_InputIterator>,
752  typename _CharT
753  = __detail::__value_type_is_char_or_char8_t<_InputIterator>>
754  inline path
755  u8path(_InputIterator __first, _InputIterator __last)
756  {
757 #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
758  if constexpr (is_same_v<_CharT, char>)
759  return path{ __detail::__wstr_from_utf8(
760  __detail::__string_from_range(__first, __last)) };
761  else
762  return path{ __first, __last }; // constructor handles char8_t
763 #else
764  // This assumes native normal encoding is UTF-8.
765  return path{ __first, __last };
766 #endif
767  }
768 
769  /** Create a path from a UTF-8-encoded sequence of char
770  *
771  * @relates std::filesystem::path
772  */
773  template<typename _Source,
774  typename _Require = __detail::_Path<_Source>,
775  typename _CharT = __detail::__value_type_is_char_or_char8_t<_Source>>
776  inline path
777  u8path(const _Source& __source)
778  {
779 #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
780  if constexpr (is_same_v<_CharT, char>)
781  return path{ __detail::__wstr_from_utf8(
782  __detail::__effective_range(__source)) };
783  else
784  return path{ __source }; // constructor handles char8_t
785 #else
786  // This assumes native normal encoding is UTF-8.
787  return path{ __source };
788 #endif
789  }
790 
791  /// @cond undocumented
792 
793  struct path::_Cmpt : path
794  {
795  _Cmpt(basic_string_view<value_type> __s, _Type __t, size_t __pos)
796  : path(__s, __t), _M_pos(__pos) { }
797 
798  _Cmpt() : _M_pos(-1) { }
799 
800  size_t _M_pos;
801  };
802 
803  template<typename _EcharT>
804  auto
805  path::_S_convert(const _EcharT* __f, const _EcharT* __l)
806  {
807  static_assert(__detail::__is_encoded_char<_EcharT>);
808 
809  if constexpr (is_same_v<_EcharT, value_type>)
810  return basic_string_view<value_type>(__f, __l - __f);
811 #if !defined _GLIBCXX_FILESYSTEM_IS_WINDOWS && defined _GLIBCXX_USE_CHAR8_T
812  else if constexpr (is_same_v<_EcharT, char8_t>)
813  // For POSIX converting from char8_t to char is also 'noconv'
814  return string_view(reinterpret_cast<const char*>(__f), __l - __f);
815 #endif
816  else
817  {
818 #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
819  std::wstring __wstr;
820  if constexpr (is_same_v<_EcharT, char>)
821  {
822  struct _UCvt : std::codecvt<wchar_t, char, std::mbstate_t>
823  { } __cvt;
824  if (__str_codecvt_in_all(__f, __l, __wstr, __cvt))
825  return __wstr;
826  }
827 #ifdef _GLIBCXX_USE_CHAR8_T
828  else if constexpr (is_same_v<_EcharT, char8_t>)
829  {
830  const auto __f2 = reinterpret_cast<const char*>(__f);
831  return __detail::__wstr_from_utf8(string_view(__f2, __l - __f));
832  }
833 #endif
834  else // char16_t or char32_t
835  {
836  struct _UCvt : std::codecvt<_EcharT, char, std::mbstate_t>
837  { } __cvt;
838  std::string __str;
839  if (__str_codecvt_out_all(__f, __l, __str, __cvt))
840  return __detail::__wstr_from_utf8(__str);
841  }
842 #else // ! windows
843  struct _UCvt : std::codecvt<_EcharT, char, std::mbstate_t>
844  { } __cvt;
845  std::string __str;
846  if (__str_codecvt_out_all(__f, __l, __str, __cvt))
847  return __str;
848 #endif
849  _GLIBCXX_THROW_OR_ABORT(filesystem_error(
850  "Cannot convert character sequence",
851  std::make_error_code(errc::illegal_byte_sequence)));
852  }
853  }
854 
855  /// @endcond
856 
857  /// An iterator for the components of a path
859  {
860  public:
861  using difference_type = std::ptrdiff_t;
862  using value_type = path;
863  using reference = const path&;
864  using pointer = const path*;
866 
867  iterator() : _M_path(nullptr), _M_cur(), _M_at_end() { }
868 
869  iterator(const iterator&) = default;
870  iterator& operator=(const iterator&) = default;
871 
872  reference operator*() const;
873  pointer operator->() const { return std::__addressof(**this); }
874 
875  iterator& operator++();
876  iterator operator++(int) { auto __tmp = *this; ++*this; return __tmp; }
877 
878  iterator& operator--();
879  iterator operator--(int) { auto __tmp = *this; --*this; return __tmp; }
880 
881  friend bool operator==(const iterator& __lhs, const iterator& __rhs)
882  { return __lhs._M_equals(__rhs); }
883 
884  friend bool operator!=(const iterator& __lhs, const iterator& __rhs)
885  { return !__lhs._M_equals(__rhs); }
886 
887  private:
888  friend class path;
889 
890  bool _M_is_multi() const { return _M_path->_M_type() == _Type::_Multi; }
891 
892  friend difference_type
893  __path_iter_distance(const iterator& __first, const iterator& __last)
894  {
895  __glibcxx_assert(__first._M_path != nullptr);
896  __glibcxx_assert(__first._M_path == __last._M_path);
897  if (__first._M_is_multi())
898  return std::distance(__first._M_cur, __last._M_cur);
899  else if (__first._M_at_end == __last._M_at_end)
900  return 0;
901  else
902  return __first._M_at_end ? -1 : 1;
903  }
904 
905  friend void
906  __path_iter_advance(iterator& __i, difference_type __n)
907  {
908  if (__n == 1)
909  ++__i;
910  else if (__n == -1)
911  --__i;
912  else if (__n != 0)
913  {
914  __glibcxx_assert(__i._M_path != nullptr);
915  __glibcxx_assert(__i._M_is_multi());
916  // __glibcxx_assert(__i._M_path->_M_cmpts.end() - __i._M_cur >= __n);
917  __i._M_cur += __n;
918  }
919  }
920 
921  iterator(const path* __path, path::_List::const_iterator __iter)
922  : _M_path(__path), _M_cur(__iter), _M_at_end()
923  { }
924 
925  iterator(const path* __path, bool __at_end)
926  : _M_path(__path), _M_cur(), _M_at_end(__at_end)
927  { }
928 
929  bool _M_equals(iterator) const;
930 
931  const path* _M_path;
932  path::_List::const_iterator _M_cur;
933  bool _M_at_end; // only used when type != _Multi
934  };
935 
936 
937  inline path&
938  path::operator=(path&& __p) noexcept
939  {
940  if (&__p == this) [[__unlikely__]]
941  return *this;
942 
943  _M_pathname = std::move(__p._M_pathname);
944  _M_cmpts = std::move(__p._M_cmpts);
945  __p.clear();
946  return *this;
947  }
948 
949  inline path&
950  path::operator=(string_type&& __source)
951  { return *this = path(std::move(__source)); }
952 
953  inline path&
954  path::assign(string_type&& __source)
955  { return *this = path(std::move(__source)); }
956 
957  inline path&
958  path::operator+=(const string_type& __x)
959  {
960  _M_concat(__x);
961  return *this;
962  }
963 
964  inline path&
965  path::operator+=(const value_type* __x)
966  {
967  _M_concat(__x);
968  return *this;
969  }
970 
971  inline path&
972  path::operator+=(value_type __x)
973  {
974  _M_concat(basic_string_view<value_type>(&__x, 1));
975  return *this;
976  }
977 
978  inline path&
979  path::operator+=(basic_string_view<value_type> __x)
980  {
981  _M_concat(__x);
982  return *this;
983  }
984 
985  template<typename _CharT>
986  inline __detail::_Path2<_CharT*>&
987  path::operator+=(const _CharT __x)
988  {
989  _M_concat(_S_convert(&__x, &__x + 1));
990  return *this;
991  }
992 
993  inline path&
994  path::make_preferred()
995  {
996 #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
997  std::replace(_M_pathname.begin(), _M_pathname.end(), L'/',
998  preferred_separator);
999 #endif
1000  return *this;
1001  }
1002 
1003  inline void path::swap(path& __rhs) noexcept
1004  {
1005  _M_pathname.swap(__rhs._M_pathname);
1006  _M_cmpts.swap(__rhs._M_cmpts);
1007  }
1008 
1009  /// @cond undocumented
1010  template<typename _CharT, typename _Traits, typename _Allocator>
1012  path::_S_str_convert(basic_string_view<value_type> __str,
1013  const _Allocator& __a)
1014  {
1015  static_assert(!is_same_v<_CharT, value_type>);
1016 
1017  using _WString = basic_string<_CharT, _Traits, _Allocator>;
1018 
1019  if (__str.size() == 0)
1020  return _WString(__a);
1021 
1022 #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
1023  // First convert native string from UTF-16 to to UTF-8.
1024  // XXX This assumes that the execution wide-character set is UTF-16.
1025  std::codecvt_utf8_utf16<value_type> __cvt;
1026 
1027  using _CharAlloc = __alloc_rebind<_Allocator, char>;
1028  using _String = basic_string<char, char_traits<char>, _CharAlloc>;
1029  _String __u8str{_CharAlloc{__a}};
1030  const value_type* __wfirst = __str.data();
1031  const value_type* __wlast = __wfirst + __str.size();
1032  if (__str_codecvt_out_all(__wfirst, __wlast, __u8str, __cvt)) {
1033  if constexpr (is_same_v<_CharT, char>)
1034  return __u8str; // XXX assumes native ordinary encoding is UTF-8.
1035  else {
1036 
1037  const char* __first = __u8str.data();
1038  const char* __last = __first + __u8str.size();
1039 #else
1040  const value_type* __first = __str.data();
1041  const value_type* __last = __first + __str.size();
1042 #endif
1043 
1044  // Convert UTF-8 string to requested format.
1045 #ifdef _GLIBCXX_USE_CHAR8_T
1046  if constexpr (is_same_v<_CharT, char8_t>)
1047  return _WString(__first, __last, __a);
1048  else
1049 #endif
1050  {
1051  // Convert UTF-8 to wide string.
1052  _WString __wstr(__a);
1053  struct _UCvt : std::codecvt<_CharT, char, std::mbstate_t> { } __cvt;
1054  if (__str_codecvt_in_all(__first, __last, __wstr, __cvt))
1055  return __wstr;
1056  }
1057 
1058 #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
1059  } }
1060 #endif
1061  _GLIBCXX_THROW_OR_ABORT(filesystem_error(
1062  "Cannot convert character sequence",
1063  std::make_error_code(errc::illegal_byte_sequence)));
1064  }
1065  /// @endcond
1066 
1067  template<typename _CharT, typename _Traits, typename _Allocator>
1068  inline basic_string<_CharT, _Traits, _Allocator>
1069  path::string(const _Allocator& __a) const
1070  {
1071  if constexpr (is_same_v<_CharT, value_type>)
1072  return { _M_pathname.c_str(), _M_pathname.length(), __a };
1073  else
1074  return _S_str_convert<_CharT, _Traits>(_M_pathname, __a);
1075  }
1076 
1077  inline std::string
1078  path::string() const { return string<char>(); }
1079 
1080 #if _GLIBCXX_USE_WCHAR_T
1081  inline std::wstring
1082  path::wstring() const { return string<wchar_t>(); }
1083 #endif
1084 
1085 #ifdef _GLIBCXX_USE_CHAR8_T
1086  inline std::u8string
1087  path::u8string() const { return string<char8_t>(); }
1088 #else
1089  inline std::string
1090  path::u8string() const
1091  {
1092 #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
1093  std::string __str;
1094  // convert from native wide encoding (assumed to be UTF-16) to UTF-8
1095  std::codecvt_utf8_utf16<value_type> __cvt;
1096  const value_type* __first = _M_pathname.data();
1097  const value_type* __last = __first + _M_pathname.size();
1098  if (__str_codecvt_out_all(__first, __last, __str, __cvt))
1099  return __str;
1100  _GLIBCXX_THROW_OR_ABORT(filesystem_error(
1101  "Cannot convert character sequence",
1102  std::make_error_code(errc::illegal_byte_sequence)));
1103 #else
1104  return _M_pathname;
1105 #endif
1106  }
1107 #endif // _GLIBCXX_USE_CHAR8_T
1108 
1109  inline std::u16string
1110  path::u16string() const { return string<char16_t>(); }
1111 
1112  inline std::u32string
1113  path::u32string() const { return string<char32_t>(); }
1114 
1115  template<typename _CharT, typename _Traits, typename _Allocator>
1117  path::generic_string(const _Allocator& __a) const
1118  {
1119 #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
1120  const value_type __slash = L'/';
1121 #else
1122  const value_type __slash = '/';
1123 #endif
1124  using _Alloc2 = typename allocator_traits<_Allocator>::template
1125  rebind_alloc<value_type>;
1126  basic_string<value_type, char_traits<value_type>, _Alloc2> __str(__a);
1127 
1128  if (_M_type() == _Type::_Root_dir)
1129  __str.assign(1, __slash);
1130  else
1131  {
1132  __str.reserve(_M_pathname.size());
1133  bool __add_slash = false;
1134  for (auto& __elem : *this)
1135  {
1136 #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
1137  if (__elem._M_type() == _Type::_Root_dir)
1138  {
1139  __str += __slash;
1140  continue;
1141  }
1142 #endif
1143  if (__add_slash)
1144  __str += __slash;
1145  __str += basic_string_view<value_type>(__elem._M_pathname);
1146  __add_slash = __elem._M_type() == _Type::_Filename;
1147  }
1148  }
1149 
1150  if constexpr (is_same_v<_CharT, value_type>)
1151  return __str;
1152  else
1153  return _S_str_convert<_CharT, _Traits>(__str, __a);
1154  }
1155 
1156  inline std::string
1157  path::generic_string() const
1158  { return generic_string<char>(); }
1159 
1160 #if _GLIBCXX_USE_WCHAR_T
1161  inline std::wstring
1162  path::generic_wstring() const
1163  { return generic_string<wchar_t>(); }
1164 #endif
1165 
1166 #ifdef _GLIBCXX_USE_CHAR8_T
1167  inline std::u8string
1168  path::generic_u8string() const
1169  { return generic_string<char8_t>(); }
1170 #else
1171  inline std::string
1172  path::generic_u8string() const
1173  { return generic_string(); }
1174 #endif
1175 
1176  inline std::u16string
1177  path::generic_u16string() const
1178  { return generic_string<char16_t>(); }
1179 
1180  inline std::u32string
1181  path::generic_u32string() const
1182  { return generic_string<char32_t>(); }
1183 
1184  inline int
1185  path::compare(const string_type& __s) const noexcept
1186  { return compare(basic_string_view<value_type>(__s)); }
1187 
1188  inline int
1189  path::compare(const value_type* __s) const noexcept
1190  { return compare(basic_string_view<value_type>(__s)); }
1191 
1192  inline path
1193  path::filename() const
1194  {
1195  if (empty())
1196  return {};
1197  else if (_M_type() == _Type::_Filename)
1198  return *this;
1199  else if (_M_type() == _Type::_Multi)
1200  {
1201  if (_M_pathname.back() == preferred_separator)
1202  return {};
1203  auto& __last = *--end();
1204  if (__last._M_type() == _Type::_Filename)
1205  return __last;
1206  }
1207  return {};
1208  }
1209 
1210  inline path
1211  path::stem() const
1212  {
1213  auto ext = _M_find_extension();
1214  if (ext.first && ext.second != 0)
1215  return path{ext.first->substr(0, ext.second)};
1216  return {};
1217  }
1218 
1219  inline path
1220  path::extension() const
1221  {
1222  auto ext = _M_find_extension();
1223  if (ext.first && ext.second != string_type::npos)
1224  return path{ext.first->substr(ext.second)};
1225  return {};
1226  }
1227 
1228  inline bool
1229  path::has_stem() const noexcept
1230  {
1231  auto ext = _M_find_extension();
1232  return ext.first && ext.second != 0;
1233  }
1234 
1235  inline bool
1236  path::has_extension() const noexcept
1237  {
1238  auto ext = _M_find_extension();
1239  return ext.first && ext.second != string_type::npos;
1240  }
1241 
1242  inline bool
1243  path::is_absolute() const noexcept
1244  {
1245 #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
1246  return has_root_name() && has_root_directory();
1247 #else
1248  return has_root_directory();
1249 #endif
1250  }
1251 
1252  inline path::iterator
1253  path::begin() const
1254  {
1255  if (_M_type() == _Type::_Multi)
1256  return iterator(this, _M_cmpts.begin());
1257  return iterator(this, empty());
1258  }
1259 
1260  inline path::iterator
1261  path::end() const
1262  {
1263  if (_M_type() == _Type::_Multi)
1264  return iterator(this, _M_cmpts.end());
1265  return iterator(this, true);
1266  }
1267 
1268  inline path::iterator&
1269  path::iterator::operator++()
1270  {
1271  __glibcxx_assert(_M_path != nullptr);
1272  if (_M_path->_M_type() == _Type::_Multi)
1273  {
1274  __glibcxx_assert(_M_cur != _M_path->_M_cmpts.end());
1275  ++_M_cur;
1276  }
1277  else
1278  {
1279  __glibcxx_assert(!_M_at_end);
1280  _M_at_end = true;
1281  }
1282  return *this;
1283  }
1284 
1285  inline path::iterator&
1286  path::iterator::operator--()
1287  {
1288  __glibcxx_assert(_M_path != nullptr);
1289  if (_M_path->_M_type() == _Type::_Multi)
1290  {
1291  __glibcxx_assert(_M_cur != _M_path->_M_cmpts.begin());
1292  --_M_cur;
1293  }
1294  else
1295  {
1296  __glibcxx_assert(_M_at_end);
1297  _M_at_end = false;
1298  }
1299  return *this;
1300  }
1301 
1302  inline path::iterator::reference
1303  path::iterator::operator*() const
1304  {
1305  __glibcxx_assert(_M_path != nullptr);
1306  if (_M_path->_M_type() == _Type::_Multi)
1307  {
1308  __glibcxx_assert(_M_cur != _M_path->_M_cmpts.end());
1309  return *_M_cur;
1310  }
1311  return *_M_path;
1312  }
1313 
1314  inline bool
1315  path::iterator::_M_equals(iterator __rhs) const
1316  {
1317  if (_M_path != __rhs._M_path)
1318  return false;
1319  if (_M_path == nullptr)
1320  return true;
1321  if (_M_path->_M_type() == path::_Type::_Multi)
1322  return _M_cur == __rhs._M_cur;
1323  return _M_at_end == __rhs._M_at_end;
1324  }
1325 
1326  // @} group filesystem
1327 _GLIBCXX_END_NAMESPACE_CXX11
1328 } // namespace filesystem
1329 
1330 inline ptrdiff_t
1331 distance(filesystem::path::iterator __first, filesystem::path::iterator __last)
1332 { return __path_iter_distance(__first, __last); }
1333 
1334 template<typename _InputIterator, typename _Distance>
1335  void
1336  advance(filesystem::path::iterator& __i, _Distance __n)
1337  { __path_iter_advance(__i, static_cast<ptrdiff_t>(__n)); }
1338 
1339 extern template class __shared_ptr<const filesystem::filesystem_error::_Impl>;
1340 
1341 _GLIBCXX_END_NAMESPACE_VERSION
1342 } // namespace std
1343 
1344 #endif // C++17
1345 
1346 #endif // _GLIBCXX_FS_PATH_H
std::basic_istream
Template class basic_istream.
Definition: istream:59
std::basic_string< value_type >::npos
static const size_type npos
Value returned by various member functions when they fail.
Definition: basic_string.h:3360
std::unique_ptr< _Impl, _Impl_deleter >
std::basic_string::empty
bool empty() const noexcept
Definition: basic_string.h:4047
iosfwd
system_error
std::remove_reference_t
typename remove_reference< _Tp >::type remove_reference_t
Alias template for remove_reference.
Definition: type_traits:1595
std::quoted
auto quoted(const _CharT *__string, _CharT __delim=_CharT('"'), _CharT __escape = _CharT('\\'))
Manipulator for quoted strings.
Definition: iomanip:461
locale
unique_ptr.h
std::codecvt
Primary class template codecvt.
Definition: codecvt.h:276
iomanip
std
ISO C++ entities toplevel namespace is std.
operator->
element_type * operator->() const
Smart pointer dereferencing.
Definition: auto_ptr.h:105
std::iterator_traits
Traits class for iterators.
Definition: stl_iterator_base_types.h:178
stl_algobase.h
std::distance
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
Definition: stl_iterator_base_funcs.h:138
std::basic_string::clear
void clear() noexcept
Definition: basic_string.h:4025
std::locale
Container class for localization functionality.
Definition: locale_classes.h:63
std::__addressof
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
Definition: move.h:49
std::system_error
An exception type that includes an error_code value.
Definition: system_error:431
std::filesystem::path::operator<<
friend std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const path &__p)
Write a path to a stream.
Definition: bits/fs_path.h:513
std::size
constexpr auto size(const _Container &__cont) noexcept(noexcept(__cont.size())) -> decltype(__cont.size())
Return the size of a container.
Definition: range_access.h:244
utility
std::basic_ostream
Template class basic_ostream.
Definition: ostream:59
std::error_code
Definition: system_error:181
std::filesystem::path::operator>>
friend std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, path &__p)
Read a path from a stream.
Definition: bits/fs_path.h:522
std::end
_Tp * end(valarray< _Tp > &__va)
Return an iterator pointing to one past the last element of the valarray.
Definition: valarray:1234
std::move
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
Definition: move.h:101
std::replace
constexpr void replace(_ForwardIterator __first, _ForwardIterator __last, const _Tp &__old_value, const _Tp &__new_value)
Replace each occurrence of one value in a sequence with another value.
Definition: stl_algo.h:4356
operator=
auto_ptr & operator=(auto_ptr &__a)
auto_ptr assignment operator.
Definition: auto_ptr.h:47
std::filesystem::path::operator<=
friend bool operator<=(const path &__lhs, const path &__rhs) noexcept
Compare paths.
Definition: bits/fs_path.h:551
std::empty
constexpr auto empty(const _Container &__cont) noexcept(noexcept(__cont.empty())) -> decltype(__cont.empty())
Return whether a container is empty.
Definition: range_access.h:262
std::filesystem::path::u8path
path u8path(_InputIterator __first, _InputIterator __last)
Definition: bits/fs_path.h:755
std::filesystem::path::format
format
path::format is ignored in this implementation
Definition: bits/fs_path.h:281
std::swap
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
Definition: any:412
concurrence.h
std::basic_string::c_str
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
Definition: basic_string.h:5228
locale_conv.h
std::basic_string::reserve
void reserve(size_type __res_arg)
Attempt to preallocate enough memory for specified number of characters.
Definition: basic_string.tcc:928
std::filesystem::path::iterator
An iterator for the components of a path.
Definition: bits/fs_path.h:859
std::filesystem::path::operator>=
friend bool operator>=(const path &__lhs, const path &__rhs) noexcept
Compare paths.
Definition: bits/fs_path.h:559
std::filesystem::path::operator/
friend path operator/(const path &__lhs, const path &__rhs)
Append one path to another.
Definition: bits/fs_path.h:564
std::basic_string::assign
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
Definition: basic_string.tcc:669
std::filesystem::path
A filesystem path.
Definition: bits/fs_path.h:264
std::bidirectional_iterator_tag
Bidirectional iterators support a superset of forward iterator operations.
Definition: stl_iterator_base_types.h:103
std::filesystem::filesystem_error::what
const char * what() const noexcept
std::filesystem::path::operator<
friend bool operator<(const path &__lhs, const path &__rhs) noexcept
Compare paths.
Definition: bits/fs_path.h:547
std::filesystem::path::u8path
path u8path(const _Source &__source)
Definition: bits/fs_path.h:777
string_view
std::filesystem::path::operator!=
friend bool operator!=(const path &__lhs, const path &__rhs) noexcept
Compare paths.
Definition: bits/fs_path.h:543
std::operator*
constexpr complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
Definition: complex:392
std::enable_if_t
typename enable_if< _Cond, _Tp >::type enable_if_t
Alias template for enable_if.
Definition: type_traits:2514
std::filesystem::filesystem_error
Exception type thrown by the Filesystem library.
Definition: bits/fs_path.h:719
std::filesystem::path::operator==
friend bool operator==(const path &__lhs, const path &__rhs) noexcept
Compare paths.
Definition: bits/fs_path.h:533
std::basic_string::data
const _CharT * data() const noexcept
Return const pointer to contents.
Definition: basic_string.h:5240
std::begin
_Tp * begin(valarray< _Tp > &__va)
Return an iterator pointing to the first element of the valarray.
Definition: valarray:1214
std::data
constexpr auto data(_Container &__cont) noexcept(noexcept(__cont.data())) -> decltype(__cont.data())
Return the data pointer of a container.
Definition: range_access.h:289
std::false_type
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.
Definition: type_traits:78
compare
codecvt
type_traits
std::basic_string
Managing sequences of characters and character-like objects.
Definition: basic_string.h:3147
std::filesystem::path::operator>
friend bool operator>(const path &__lhs, const path &__rhs) noexcept
Compare paths.
Definition: bits/fs_path.h:555
std::basic_string_view
A non-owning reference to a string.
Definition: string_view:96
std::void_t
void void_t
A metafunction that always yields void, used for detecting valid types.
Definition: type_traits:2536