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
57namespace std _GLIBCXX_VISIBILITY(default)
58{
59_GLIBCXX_BEGIN_NAMESPACE_VERSION
60
61namespace filesystem
62{
63_GLIBCXX_BEGIN_NAMESPACE_CXX11
64
65 class path;
66
67 /// @cond undocumented
68namespace __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 template<typename _EcharT> struct _Codecvt;
735 };
736
737 /// @{
738 /// @relates std::filesystem::path
739
740 inline void swap(path& __lhs, path& __rhs) noexcept { __lhs.swap(__rhs); }
741
742 size_t hash_value(const path& __p) noexcept;
743
744 /// @}
745
746 /// Exception type thrown by the Filesystem library
748 {
749 public:
750 filesystem_error(const string& __what_arg, error_code __ec);
751
752 filesystem_error(const string& __what_arg, const path& __p1,
753 error_code __ec);
754
755 filesystem_error(const string& __what_arg, const path& __p1,
756 const path& __p2, error_code __ec);
757
758 filesystem_error(const filesystem_error&) = default;
759 filesystem_error& operator=(const filesystem_error&) = default;
760
761 // No move constructor or assignment operator.
762 // Copy rvalues instead, so that _M_impl is not left empty.
763
765
766 const path& path1() const noexcept;
767 const path& path2() const noexcept;
768 const char* what() const noexcept;
769
770 private:
771 struct _Impl;
772 std::__shared_ptr<const _Impl> _M_impl;
773 };
774
775 /// @cond undocumented
776namespace __detail
777{
778 [[noreturn]] inline void
779 __throw_conversion_error()
780 {
781 _GLIBCXX_THROW_OR_ABORT(filesystem_error(
782 "Cannot convert character sequence",
783 std::make_error_code(errc::illegal_byte_sequence)));
784 }
785
786#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
787 template<typename _Tp>
788 inline std::wstring
789 __wstr_from_utf8(const _Tp& __str)
790 {
791 static_assert(std::is_same_v<typename _Tp::value_type, char>);
792 std::wstring __wstr;
793 // XXX This assumes native wide encoding is UTF-16.
794 std::codecvt_utf8_utf16<wchar_t> __wcvt;
795 const auto __p = __str.data();
796 if (!__str_codecvt_in_all(__p, __p + __str.size(), __wstr, __wcvt))
797 __detail::__throw_conversion_error();
798 return __wstr;
799 }
800#endif
801
802} // namespace __detail
803 /// @endcond
804
805
806 /** Create a path from a UTF-8-encoded sequence of char
807 *
808 * @relates std::filesystem::path
809 */
810 template<typename _InputIterator,
811 typename _Require = __detail::_Path2<_InputIterator>,
812 typename _CharT
813 = __detail::__value_type_is_char_or_char8_t<_InputIterator>>
814 inline path
815 u8path(_InputIterator __first, _InputIterator __last)
816 {
817#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
818 if constexpr (is_same_v<_CharT, char>)
819 return path{ __detail::__wstr_from_utf8(
820 __detail::__string_from_range(__first, __last)) };
821 else
822 return path{ __first, __last }; // constructor handles char8_t
823#else
824 // This assumes native normal encoding is UTF-8.
825 return path{ __first, __last };
826#endif
827 }
828
829 /** Create a path from a UTF-8-encoded sequence of char
830 *
831 * @relates std::filesystem::path
832 */
833 template<typename _Source,
834 typename _Require = __detail::_Path<_Source>,
835 typename _CharT = __detail::__value_type_is_char_or_char8_t<_Source>>
836 inline path
837 u8path(const _Source& __source)
838 {
839#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
840 if constexpr (is_same_v<_CharT, char>)
841 return path{ __detail::__wstr_from_utf8(
842 __detail::__effective_range(__source)) };
843 else
844 return path{ __source }; // constructor handles char8_t
845#else
846 // This assumes native normal encoding is UTF-8.
847 return path{ __source };
848#endif
849 }
850
851 /// @cond undocumented
852
853 struct path::_Cmpt : path
854 {
855 _Cmpt(basic_string_view<value_type> __s, _Type __t, size_t __pos)
856 : path(__s, __t), _M_pos(__pos) { }
857
858 _Cmpt() : _M_pos(-1) { }
859
860 size_t _M_pos;
861 };
862
863 // path::_Codecvt<C> Performs conversions between C and path::string_type.
864 // The native encoding of char strings is the OS-dependent current
865 // encoding for pathnames. FIXME: We assume this is UTF-8 everywhere,
866 // but should use a Windows API to query it.
867
868 // Converts between native pathname encoding and char16_t or char32_t.
869 template<typename _EcharT>
870 struct path::_Codecvt
871 // Need derived class here because std::codecvt has protected destructor.
872 : std::codecvt<_EcharT, char, mbstate_t>
873 { };
874
875 // Converts between native pathname encoding and native wide encoding.
876 // The native encoding for wide strings is the execution wide-character
877 // set encoding. FIXME: We assume that this is either UTF-32 or UTF-16
878 // (depending on the width of wchar_t). That matches GCC's default,
879 // but can be changed with -fwide-exec-charset.
880 // We need a custom codecvt converting the native pathname encoding
881 // to/from the native wide encoding.
882 template<>
883 struct path::_Codecvt<wchar_t>
884 : __conditional_t<sizeof(wchar_t) == sizeof(char32_t),
885 std::codecvt_utf8<wchar_t>, // UTF-8 <-> UTF-32
886 std::codecvt_utf8_utf16<wchar_t>> // UTF-8 <-> UTF-16
887 { };
888
889 template<typename _EcharT>
890 auto
891 path::_S_convert(const _EcharT* __f, const _EcharT* __l)
892 {
893 static_assert(__detail::__is_encoded_char<_EcharT>);
894
895#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
896# define _GLIBCXX_CONV_FROM_UTF8(S) __detail::__wstr_from_utf8(S)
897#else
898# define _GLIBCXX_CONV_FROM_UTF8(S) S
899#endif
900
901 if constexpr (is_same_v<_EcharT, value_type>)
902 return basic_string_view<value_type>(__f, __l - __f);
903#ifdef _GLIBCXX_USE_CHAR8_T
904 else if constexpr (is_same_v<_EcharT, char8_t>)
905 {
906 string_view __str(reinterpret_cast<const char*>(__f), __l - __f);
907 return _GLIBCXX_CONV_FROM_UTF8(__str);
908 }
909#endif
910#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
911 else if constexpr (is_same_v<_EcharT, char>)
912 {
913 std::wstring __wstr;
914 path::_Codecvt<wchar_t> __cvt;
915 if (__str_codecvt_in_all(__f, __l, __wstr, __cvt))
916 return __wstr;
917 }
918#endif
919 else
920 {
921 path::_Codecvt<_EcharT> __cvt;
922 std::string __str;
923 if (__str_codecvt_out_all(__f, __l, __str, __cvt))
924 return _GLIBCXX_CONV_FROM_UTF8(__str);
925 }
926 __detail::__throw_conversion_error();
927 }
928#undef _GLIBCXX_CONV_FROM_UTF8
929
930 /// @endcond
931
932 /// An iterator for the components of a path
934 {
935 public:
936 using difference_type = std::ptrdiff_t;
937 using value_type = path;
938 using reference = const path&;
939 using pointer = const path*;
941
942 iterator() noexcept : _M_path(nullptr), _M_cur(), _M_at_end() { }
943
944 iterator(const iterator&) = default;
945 iterator& operator=(const iterator&) = default;
946
947 reference operator*() const noexcept;
948 pointer operator->() const noexcept { return std::__addressof(**this); }
949
950 iterator& operator++() noexcept;
951
952 iterator operator++(int) noexcept
953 { auto __tmp = *this; ++*this; return __tmp; }
954
955 iterator& operator--() noexcept;
956
957 iterator operator--(int) noexcept
958 { auto __tmp = *this; --*this; return __tmp; }
959
960 friend bool
961 operator==(const iterator& __lhs, const iterator& __rhs) noexcept
962 { return __lhs._M_equals(__rhs); }
963
964 friend bool
965 operator!=(const iterator& __lhs, const iterator& __rhs) noexcept
966 { return !__lhs._M_equals(__rhs); }
967
968 private:
969 friend class path;
970
971 bool
972 _M_is_multi() const noexcept
973 { return _M_path->_M_type() == _Type::_Multi; }
974
975 friend difference_type
976 __path_iter_distance(const iterator& __first, const iterator& __last)
977 noexcept
978 {
979 __glibcxx_assert(__first._M_path != nullptr);
980 __glibcxx_assert(__first._M_path == __last._M_path);
981 if (__first._M_is_multi())
982 return std::distance(__first._M_cur, __last._M_cur);
983 else if (__first._M_at_end == __last._M_at_end)
984 return 0;
985 else
986 return __first._M_at_end ? -1 : 1;
987 }
988
989 friend void
990 __path_iter_advance(iterator& __i, difference_type __n) noexcept
991 {
992 if (__n == 1)
993 ++__i;
994 else if (__n == -1)
995 --__i;
996 else if (__n != 0)
997 {
998 __glibcxx_assert(__i._M_path != nullptr);
999 __glibcxx_assert(__i._M_is_multi());
1000 // __glibcxx_assert(__i._M_path->_M_cmpts.end() - __i._M_cur >= __n);
1001 __i._M_cur += __n;
1002 }
1003 }
1004
1005 iterator(const path* __path, path::_List::const_iterator __iter) noexcept
1006 : _M_path(__path), _M_cur(__iter), _M_at_end()
1007 { }
1008
1009 iterator(const path* __path, bool __at_end) noexcept
1010 : _M_path(__path), _M_cur(), _M_at_end(__at_end)
1011 { }
1012
1013 bool _M_equals(iterator) const noexcept;
1014
1015 const path* _M_path;
1016 path::_List::const_iterator _M_cur;
1017 bool _M_at_end; // only used when type != _Multi
1018 };
1019
1020
1021 inline path&
1022 path::operator=(path&& __p) noexcept
1023 {
1024 if (&__p == this) [[__unlikely__]]
1025 return *this;
1026
1027 _M_pathname = std::move(__p._M_pathname);
1028 _M_cmpts = std::move(__p._M_cmpts);
1029 __p.clear();
1030 return *this;
1031 }
1032
1033 inline path&
1034 path::operator=(string_type&& __source)
1035 { return *this = path(std::move(__source)); }
1036
1037 inline path&
1038 path::assign(string_type&& __source)
1039 { return *this = path(std::move(__source)); }
1040
1041 inline path&
1042 path::operator+=(const string_type& __x)
1043 {
1044 _M_concat(__x);
1045 return *this;
1046 }
1047
1048 inline path&
1049 path::operator+=(const value_type* __x)
1050 {
1051 _M_concat(__x);
1052 return *this;
1053 }
1054
1055 inline path&
1056 path::operator+=(value_type __x)
1057 {
1058 _M_concat(basic_string_view<value_type>(&__x, 1));
1059 return *this;
1060 }
1061
1062 inline path&
1063 path::operator+=(basic_string_view<value_type> __x)
1064 {
1065 _M_concat(__x);
1066 return *this;
1067 }
1068
1069 template<typename _CharT>
1070 inline __detail::_Path2<_CharT*>&
1071 path::operator+=(const _CharT __x)
1072 {
1073 _M_concat(_S_convert(&__x, &__x + 1));
1074 return *this;
1075 }
1076
1077 inline path&
1078 path::make_preferred()
1079 {
1080#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
1081 auto __pos = _M_pathname.find(L'/');
1082 while (__pos != _M_pathname.npos)
1083 {
1084 _M_pathname[__pos] = preferred_separator;
1085 __pos = _M_pathname.find(L'/', __pos);
1086 }
1087#endif
1088 return *this;
1089 }
1090
1091 inline void path::swap(path& __rhs) noexcept
1092 {
1093 _M_pathname.swap(__rhs._M_pathname);
1094 _M_cmpts.swap(__rhs._M_cmpts);
1095 }
1096
1097 /// @cond undocumented
1098 template<typename _CharT, typename _Traits, typename _Allocator>
1100 path::_S_str_convert(basic_string_view<value_type> __str,
1101 const _Allocator& __a)
1102 {
1103 static_assert(!is_same_v<_CharT, value_type>);
1104
1105 using _WString = basic_string<_CharT, _Traits, _Allocator>;
1106
1107 if (__str.size() == 0)
1108 return _WString(__a);
1109
1110#ifndef _GLIBCXX_FILESYSTEM_IS_WINDOWS
1111 string_view __u8str = __str;
1112#else
1113 // First convert native string from UTF-16 to to UTF-8.
1114 // XXX This assumes that the execution wide-character set is UTF-16.
1115 std::codecvt_utf8_utf16<value_type> __cvt;
1116
1117 using _CharAlloc = __alloc_rebind<_Allocator, char>;
1118 using _String = basic_string<char, char_traits<char>, _CharAlloc>;
1119 _String __u8str{_CharAlloc{__a}};
1120 const value_type* __wfirst = __str.data();
1121 const value_type* __wlast = __wfirst + __str.size();
1122 if (!__str_codecvt_out_all(__wfirst, __wlast, __u8str, __cvt))
1123 __detail::__throw_conversion_error();
1124 if constexpr (is_same_v<_CharT, char>)
1125 return __u8str; // XXX assumes native ordinary encoding is UTF-8.
1126 else
1127#endif
1128 {
1129 const char* __first = __u8str.data();
1130 const char* __last = __first + __u8str.size();
1131
1132 // Convert UTF-8 string to requested format.
1133#ifdef _GLIBCXX_USE_CHAR8_T
1134 if constexpr (is_same_v<_CharT, char8_t>)
1135 return _WString(__first, __last, __a);
1136 else
1137#endif
1138 {
1139 // Convert UTF-8 to wide string.
1140 _WString __wstr(__a);
1141 path::_Codecvt<_CharT> __cvt;
1142 if (__str_codecvt_in_all(__first, __last, __wstr, __cvt))
1143 return __wstr;
1144 }
1145 }
1146 __detail::__throw_conversion_error();
1147 }
1148 /// @endcond
1149
1150 template<typename _CharT, typename _Traits, typename _Allocator>
1151 inline basic_string<_CharT, _Traits, _Allocator>
1152 path::string(const _Allocator& __a) const
1153 {
1154 if constexpr (is_same_v<_CharT, value_type>)
1155 return { _M_pathname.c_str(), _M_pathname.length(), __a };
1156 else
1157 return _S_str_convert<_CharT, _Traits>(_M_pathname, __a);
1158 }
1159
1160 inline std::string
1161 path::string() const { return string<char>(); }
1162
1163#if _GLIBCXX_USE_WCHAR_T
1164 inline std::wstring
1165 path::wstring() const { return string<wchar_t>(); }
1166#endif
1167
1168#ifdef _GLIBCXX_USE_CHAR8_T
1169 inline std::u8string
1170 path::u8string() const { return string<char8_t>(); }
1171#else
1172 inline std::string
1173 path::u8string() const
1174 {
1175#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
1176 std::string __str;
1177 // convert from native wide encoding (assumed to be UTF-16) to UTF-8
1178 std::codecvt_utf8_utf16<value_type> __cvt;
1179 const value_type* __first = _M_pathname.data();
1180 const value_type* __last = __first + _M_pathname.size();
1181 if (__str_codecvt_out_all(__first, __last, __str, __cvt))
1182 return __str;
1183 __detail::__throw_conversion_error();
1184#else
1185 return _M_pathname;
1186#endif
1187 }
1188#endif // _GLIBCXX_USE_CHAR8_T
1189
1190 inline std::u16string
1191 path::u16string() const { return string<char16_t>(); }
1192
1193 inline std::u32string
1194 path::u32string() const { return string<char32_t>(); }
1195
1196 template<typename _CharT, typename _Traits, typename _Allocator>
1198 path::generic_string(const _Allocator& __a) const
1199 {
1200#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
1201 const value_type __slash = L'/';
1202#else
1203 const value_type __slash = '/';
1204#endif
1205 using _Alloc2 = typename allocator_traits<_Allocator>::template
1206 rebind_alloc<value_type>;
1207 basic_string<value_type, char_traits<value_type>, _Alloc2> __str(__a);
1208
1209 if (_M_type() == _Type::_Root_dir)
1210 __str.assign(1, __slash);
1211 else
1212 {
1213 __str.reserve(_M_pathname.size());
1214 bool __add_slash = false;
1215 for (auto& __elem : *this)
1216 {
1217#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
1218 if (__elem._M_type() == _Type::_Root_dir)
1219 {
1220 __str += __slash;
1221 continue;
1222 }
1223#endif
1224 if (__add_slash)
1225 __str += __slash;
1226 __str += basic_string_view<value_type>(__elem._M_pathname);
1227 __add_slash = __elem._M_type() == _Type::_Filename;
1228 }
1229 }
1230
1231 if constexpr (is_same_v<_CharT, value_type>)
1232 return __str;
1233 else
1234 return _S_str_convert<_CharT, _Traits>(__str, __a);
1235 }
1236
1237 inline std::string
1238 path::generic_string() const
1239 { return generic_string<char>(); }
1240
1241#if _GLIBCXX_USE_WCHAR_T
1242 inline std::wstring
1243 path::generic_wstring() const
1244 { return generic_string<wchar_t>(); }
1245#endif
1246
1247#ifdef _GLIBCXX_USE_CHAR8_T
1248 inline std::u8string
1249 path::generic_u8string() const
1250 { return generic_string<char8_t>(); }
1251#else
1252 inline std::string
1253 path::generic_u8string() const
1254 { return generic_string(); }
1255#endif
1256
1257 inline std::u16string
1258 path::generic_u16string() const
1259 { return generic_string<char16_t>(); }
1260
1261 inline std::u32string
1262 path::generic_u32string() const
1263 { return generic_string<char32_t>(); }
1264
1265 inline int
1266 path::compare(const string_type& __s) const noexcept
1267 { return compare(basic_string_view<value_type>(__s)); }
1268
1269 inline int
1270 path::compare(const value_type* __s) const noexcept
1271 { return compare(basic_string_view<value_type>(__s)); }
1272
1273 inline path
1274 path::filename() const
1275 {
1276 if (empty())
1277 return {};
1278 else if (_M_type() == _Type::_Filename)
1279 return *this;
1280 else if (_M_type() == _Type::_Multi)
1281 {
1282 if (_M_pathname.back() == preferred_separator)
1283 return {};
1284 auto& __last = *--end();
1285 if (__last._M_type() == _Type::_Filename)
1286 return __last;
1287 }
1288 return {};
1289 }
1290
1291 inline path
1292 path::stem() const
1293 {
1294 auto ext = _M_find_extension();
1295 if (ext.first && ext.second != 0)
1296 return path{ext.first->substr(0, ext.second)};
1297 return {};
1298 }
1299
1300 inline path
1301 path::extension() const
1302 {
1303 auto ext = _M_find_extension();
1304 if (ext.first && ext.second != string_type::npos)
1305 return path{ext.first->substr(ext.second)};
1306 return {};
1307 }
1308
1309 inline bool
1310 path::has_stem() const noexcept
1311 {
1312 auto ext = _M_find_extension();
1313 return ext.first && ext.second != 0;
1314 }
1315
1316 inline bool
1317 path::has_extension() const noexcept
1318 {
1319 auto ext = _M_find_extension();
1320 return ext.first && ext.second != string_type::npos;
1321 }
1322
1323 inline bool
1324 path::is_absolute() const noexcept
1325 {
1326#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
1327 return has_root_name() && has_root_directory();
1328#else
1329 return has_root_directory();
1330#endif
1331 }
1332
1333 inline path::iterator
1334 path::begin() const noexcept
1335 {
1336 if (_M_type() == _Type::_Multi)
1337 return iterator(this, _M_cmpts.begin());
1338 return iterator(this, empty());
1339 }
1340
1341 inline path::iterator
1342 path::end() const noexcept
1343 {
1344 if (_M_type() == _Type::_Multi)
1345 return iterator(this, _M_cmpts.end());
1346 return iterator(this, true);
1347 }
1348
1349 inline path::iterator&
1350 path::iterator::operator++() noexcept
1351 {
1352 __glibcxx_assert(_M_path != nullptr);
1353 if (_M_is_multi())
1354 {
1355 __glibcxx_assert(_M_cur != _M_path->_M_cmpts.end());
1356 ++_M_cur;
1357 }
1358 else
1359 {
1360 __glibcxx_assert(!_M_at_end);
1361 _M_at_end = true;
1362 }
1363 return *this;
1364 }
1365
1366 inline path::iterator&
1367 path::iterator::operator--() noexcept
1368 {
1369 __glibcxx_assert(_M_path != nullptr);
1370 if (_M_is_multi())
1371 {
1372 __glibcxx_assert(_M_cur != _M_path->_M_cmpts.begin());
1373 --_M_cur;
1374 }
1375 else
1376 {
1377 __glibcxx_assert(_M_at_end);
1378 _M_at_end = false;
1379 }
1380 return *this;
1381 }
1382
1383 inline path::iterator::reference
1384 path::iterator::operator*() const noexcept
1385 {
1386 __glibcxx_assert(_M_path != nullptr);
1387 if (_M_is_multi())
1388 {
1389 __glibcxx_assert(_M_cur != _M_path->_M_cmpts.end());
1390 return *_M_cur;
1391 }
1392 return *_M_path;
1393 }
1394
1395 inline bool
1396 path::iterator::_M_equals(iterator __rhs) const noexcept
1397 {
1398 if (_M_path != __rhs._M_path)
1399 return false;
1400 if (_M_path == nullptr)
1401 return true;
1402 if (_M_is_multi())
1403 return _M_cur == __rhs._M_cur;
1404 return _M_at_end == __rhs._M_at_end;
1405 }
1406
1407 // Define this now that path and path::iterator are complete.
1408 // It needs to consider the string_view(Range&&) constructor during
1409 // overload resolution, which depends on whether range<path> is satisfied,
1410 // which depends on whether path::iterator is complete.
1411 inline int
1412 path::_S_compare(const path& __lhs, const path& __rhs) noexcept
1413 { return __lhs.compare(__rhs); }
1414
1415 /// @} group filesystem
1416_GLIBCXX_END_NAMESPACE_CXX11
1417} // namespace filesystem
1418
1419/// @cond undocumented
1420
1421inline ptrdiff_t
1422distance(filesystem::path::iterator __first, filesystem::path::iterator __last)
1423noexcept
1424{ return __path_iter_distance(__first, __last); }
1425
1426template<typename _Distance>
1427 inline void
1428 advance(filesystem::path::iterator& __i, _Distance __n) noexcept
1429 { __path_iter_advance(__i, static_cast<ptrdiff_t>(__n)); }
1430
1431extern template class __shared_ptr<const filesystem::filesystem_error::_Impl>;
1432
1433/// @endcond
1434
1435// _GLIBCXX_RESOLVE_LIB_DEFECTS
1436// 3657. std::hash<std::filesystem::path> is not enabled
1437template<>
1438 struct hash<filesystem::path>
1439 {
1440 size_t
1441 operator()(const filesystem::path& __p) const noexcept
1442 { return filesystem::hash_value(__p); }
1443 };
1444
1445_GLIBCXX_END_NAMESPACE_VERSION
1446} // namespace std
1447
1448#endif // C++17
1449
1450#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:815
path u8path(const _Source &__source)
Definition: bits/fs_path.h:837
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 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
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
Definition: move.h:49
_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 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 * data() const noexcept
Return const pointer to contents.
Definition: cow_string.h:2218
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
void clear() noexcept
Definition: cow_string.h:1004
bool empty() const noexcept
Definition: cow_string.h:1026
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
Definition: cow_string.h:2206
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 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:573
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:748
const char * what() const noexcept
An iterator for the components of a path.
Definition: bits/fs_path.h:934
Container class for localization functionality.
Bidirectional iterators support a superset of forward iterator operations.