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