---
name: "std::filesystem::path"
section: "3"
platform: "linux"
package: "gcc"
version: "16.2.1+r23+gd564253eb6c8-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/std::filesystem::path"
---

# std::filesystem::path(3)

A filesystem path.

## NAME

std::filesystem::path - A filesystem path.

## SYNOPSIS

\#include \<filesystem\>

### Classes

class **iterator**\
 An iterator for the components of a path.

### Public Types

using **const\_iterator**\
 enum **format** : unsigned char { **native\_format**, **generic\_format**, **auto\_format** }\
 path::format is ignored in this implementation  using **string\_type**\
 using **value\_type**\

### Public Member Functions

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\

### Static Public Attributes

static constexpr value\_type **preferred\_separator**\

### Friends

path **operator/** (const path &\_\_lhs, const path &\_\_rhs)\
 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)\
 Write a path to a stream.  strong\_ordering **operator\<=\>** (const path &\_\_lhs, const path &\_\_rhs) noexcept\
 Compare paths.  bool **operator==** (const path &\_\_lhs, const path &\_\_rhs) noexcept\
 Compare paths.  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.

### Related Symbols

(Note that these are not member symbols.)  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.

**Since**

C++17

## Member Enumeration Documentation

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

path::format is ignored in this implementation

## Friends And Related Symbol Documentation

### 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.

References **std::move()**.

## Author

Generated automatically by Doxygen for libstdc++ from the source code.
