std::filesystem::path(3)

πŸ’– std::filesystem::path(3) πŸ’–

from the Library Functions Manual, bestie! πŸ’… This is the whole tea on std::filesystem::path, and we're gonna spill it all. No cap.


🌸 NAME 🌸

std::filesystem::path β€” a filesystem path. That's it. That's the vibe. She's literally a path to a file. Periodt. πŸ¦‹


πŸŽ€ SYNOPSIS πŸŽ€

First things first, you gotta include the header:

#include <filesystem>

Then you're in. Let's get into the good stuff.

πŸ¦‹ Classes πŸ¦‹

  • class iterator β€” an iterator for the components of a path. So you can walk through each piece of the path like a little fashion show. ✨

πŸ’– Public Types πŸ’–

  • using const_iterator β€” a const iterator, for when you're just looking, not touching. πŸ‘€
  • enum format : unsigned char { native_format, generic_format, auto_format } β€” path::format is ignored in this implementation. So don't stress about picking one, bestie, it literally doesn't matter here. πŸ’€
  • using string_type β€” the string type she uses.
  • using value_type β€” the value type, iconic.

✨ Public Member Functions ✨

Okay, this is the main character energy right here. She's got a whole roster of member functions, and we're listing every single one. No skips. Here's the full lineup, exactly as it appears, because we keep it real:

       template<typename _InputIterator, typename _Require =
           __detail::_Path2<_InputIterator>, typename _Req2 =
           __detail::__value_type_is_char<_InputIterator>> path (_InputIterator
           __first, _InputIterator __last, const locale &__loc,
           format=auto_format)
       template<typename _InputIterator, typename _Require =
           __detail::_Path2<_InputIterator>> path (_InputIterator __first,
           _InputIterator __last, format=auto_format)
       template<typename _Source, typename _Require = __detail::_Path<_Source>>
           path (_Source const &__source, format=auto_format)
       template<typename _Source, typename _Require = __detail::_Path<_Source>,
           typename _Require2 = __detail::__value_type_is_char<_Source>> path
           (_Source const &__src, const locale &__loc, format=auto_format)
       path (const path &__p)=default
       path (path &&__p) noexcept
       path (string_type &&__source, format=auto_format)
       template<typename _InputIterator> __detail::_Path2< _InputIterator > &
           append (_InputIterator __first, _InputIterator __last)
       template<typename _Source> __detail::_Path< _Source > & append (_Source
           const &__source)
       template<typename _InputIterator> __detail::_Path2< _InputIterator > &
           assign (_InputIterator __first, _InputIterator __last)
       template<typename _Source> __detail::_Path< _Source > & assign (_Source
           const &__source)
       path & assign (string_type &&__source)
       iterator begin () const noexcept
       const value_type * c_str () const noexcept
       void clear () noexcept
       int compare (basic_string_view< value_type > __s) const noexcept
       int compare (const path &__p) const noexcept
       int compare (const string_type &__s) const noexcept
       int compare (const value_type *__s) const noexcept
       template<typename _InputIterator> __detail::_Path2< _InputIterator > &
           concat (_InputIterator __first, _InputIterator __last)
       template<typename _Source> __detail::_Path< _Source > & concat (_Source
           const &__x)
       bool empty () const noexcept
       iterator end () const noexcept
       path extension () const
       path filename () const
       std::string generic_string () const
       template<typename _CharT, typename _Traits = std::char_traits<_CharT>,
           typename _Allocator = std::allocator<_CharT>> std::basic_string<
           _CharT, _Traits, _Allocator > generic_string (const _Allocator
           &__a=_Allocator()) const
       std::u16string generic_u16string () const
       std::u32string generic_u32string () const
       std::string generic_u8string () const
       std::wstring generic_wstring () const
       bool has_extension () const noexcept
       bool has_filename () const noexcept
       bool has_parent_path () const noexcept
       bool has_relative_path () const noexcept
       bool has_root_directory () const noexcept
       bool has_root_name () const noexcept
       bool has_root_path () const noexcept
       bool has_stem () const noexcept
       bool is_absolute () const noexcept
       bool is_relative () const noexcept
       path lexically_normal () const
       path lexically_proximate (const path &base) const
       path lexically_relative (const path &base) const
       path & make_preferred ()
       const string_type & native () const noexcept
       operator string_type () const
       template<typename _CharT> __detail::_Path2< _CharT * > & operator+=
           (_CharT __x)
       template<typename _Source> __detail::_Path< _Source > & operator+=
           (_Source const &__x)
       path & operator+= (basic_string_view< value_type > __x)
       path & operator+= (const path &__x)
       path & operator+= (const string_type &__x)
       path & operator+= (const value_type *__x)
       path & operator+= (value_type __x)
       template<typename _Source> __detail::_Path< _Source > & operator/=
           (_Source const &__source)
       path & operator/= (const path &__p)
       template<typename _Source> __detail::_Path< _Source > & operator=
           (_Source const &__source)
       path & operator= (const path &)
       path & operator= (path &&) noexcept
       path & operator= (string_type &&__source)
       path parent_path () const
       path relative_path () const
       path & remove_filename ()
       path & replace_extension (const path &__replacement=path())
       path & replace_filename (const path &__replacement)
       path root_directory () const
       path root_name () const
       path root_path () const
       path stem () const
       std::string string () const
       template<typename _CharT, typename _Traits, typename _Allocator>
           basic_string< _CharT, _Traits, _Allocator > string (const _Allocator
           &__a) const
       template<typename _CharT, typename _Traits = std::char_traits<_CharT>,
           typename _Allocator = std::allocator<_CharT>> std::basic_string<
           _CharT, _Traits, _Allocator > string (const _Allocator
           &__a=_Allocator()) const
       void swap (path &__rhs) noexcept
       std::u16string u16string () const
       std::u32string u32string () const
       std::string u8string () const
       std::wstring wstring () const

She ate that, no crumbs. πŸ’…

πŸ”₯ Static Public Attributes πŸ”₯

  • static constexpr value_type preferred_separator β€” the preferred separator, a static constexpr vibe. She's always there. πŸ‘‘

πŸ‘‘ Friends πŸ‘‘

These are the friends of the class, and they're all about that path life:

  • path operator/ (const path &__lhs, const path &__rhs) β€” append one path to another. Like adding a folder to your path, periodt. 🫢
  • template<typename _CharT, typename _Traits> std::basic_ostream< _CharT, _Traits > & operator<< (std::basic_ostream< _CharT, _Traits > &__os, const path &__p) β€” write a path to a stream. So you can just std::cout << my_path, iconic. ✨
  • strong_ordering operator<=> (const path &__lhs, const path &__rhs) noexcept β€” compare paths. Spaceship operator, slay. πŸš€
  • bool operator== (const path &__lhs, const path &__rhs) noexcept β€” compare paths. Are they the same? The tea. β˜•
  • template<typename _CharT, typename _Traits> std::basic_istream< _CharT, _Traits > & operator>> (std::basic_istream< _CharT, _Traits > &__is, path &__p) β€” read a path from a stream. So you can std::cin >> my_path, periodt. πŸ’…

(Note that these are not member symbols.) But they're still part of the squad, bestie:

  • void swap (path &__lhs, path &__rhs) noexcept
  • template<typename _InputIterator, typename _Require = __detail::_Path2<_InputIterator>, typename _CharT = __detail::__value_type_is_char_or_char8_t<_InputIterator>> path u8path (_InputIterator __first, _InputIterator __last)
  • template<typename _Source, typename _Require = __detail::_Path<_Source>, typename _CharT = __detail::__value_type_is_char_or_char8_t<_Source>> path u8path (const _Source &__source)

πŸ’œ Detailed Description πŸ’œ

A filesystem path. That's the whole description, bestie. She's a path. To a file. On a filesystem. Iconic.

Since: C++17

So she's been around since C++17, but she's still relevant. No cap. πŸ¦‹


🧚 Member Enumeration Documentation 🧚

enum std::filesystem::path::format : unsigned char

path::format is ignored in this implementation. So literally don't worry about it. It's giving "I'm here but I don't do anything". πŸ’€


Okay, here's the friend zone, but make it detailed:

  • path operator/ (const path & __lhs, const path & __rhs) [friend] β€” append one path to another. 🫢
  • template<typename _CharT, typename _Traits> std::basic_ostream< _CharT, _Traits > & operator<< (std::basic_ostream< _CharT, _Traits > & __os, const path & __p) [friend] β€” write a path to a stream. ✨
  • strong_ordering operator<=> (const path & __lhs, const path & __rhs) [friend] β€” compare paths. πŸš€
  • bool operator== (const path & __lhs, const path & __rhs) [friend] β€” compare paths. β˜•
  • template<typename _CharT, typename _Traits> std::basic_istream< _CharT, _Traits > & operator>> (std::basic_istream< _CharT, _Traits > & __is, path & __p) [friend] β€” read a path from a stream. And it references std::move(). So it's moving things around, slay. πŸ’…

⭐ Author ⭐

Generated automatically by Doxygen for libstdc++ from the source code. So don't come for the formatting, bestie, it was literally a robot. πŸ€–πŸ’–


And that's the whole page, bestie! This manual page is from the Library Functions Manual, brought to you by libstdc++, and the title is std::filesystem::path(3). No date on this one, but you know it's fresh. Stay iconic, and always keep your paths straight. πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from
  • arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
  • fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • fedora 44: libstdc++-docs 16.2.1-2.fc44
  • fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms