---
name: "std::filesystem_path"
section: "3cxx"
platform: "linux"
package: "libstdc++-11-doc"
version: "11.3.0-12"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/std::filesystem_path"
---

# std::filesystem\_path(3cxx)

A filesystem path.

## NAME

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

## SYNOPSIS

`#include <fs_path.h>`

### Classes

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

### Public Types

using **const\_iterator** = **iterator**\
 enum **format** : unsigned char { **native\_format**, **generic\_format**, **auto\_format** }\
 path::format is ignored in this implementation  using **string\_type** = **std::basic\_string**\< value\_type \>\
 using **value\_type** = char\

### 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\
 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\
 **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

bool **operator!=** (const **path** &\_\_lhs, const **path** &\_\_rhs) noexcept\
 Compare paths.  **path** **operator/** (const **path** &\_\_lhs, const **path** &\_\_rhs)\
 Append one path to another.  bool **operator\<** (const **path** &\_\_lhs, const **path** &\_\_rhs) noexcept\
 Compare paths.  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.  bool **operator\<=** (const **path** &\_\_lhs, const **path** &\_\_rhs) noexcept\
 Compare paths.  bool **operator==** (const **path** &\_\_lhs, const **path** &\_\_rhs) noexcept\
 Compare paths.  bool **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 Functions

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

Definition at line **248** of file **bits/fs\_path.h**.

## Member Typedef Documentation

### using std::filesystem::path::const\_iterator = iterator

Definition at line **490** of file **bits/fs\_path.h**.

### using std::filesystem::path::string\_type = std::basic\_string\<value\_type\>

Definition at line **263** of file **bits/fs\_path.h**.

### using std::filesystem::path::value\_type = char

Definition at line **259** of file **bits/fs\_path.h**.

## Member Enumeration Documentation

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

path::format is ignored in this implementation

Definition at line **266** of file **bits/fs\_path.h**.

## Constructor & Destructor Documentation

### std::filesystem::path::path ()` [inline]`, ` [noexcept]`

Definition at line **270** of file **bits/fs\_path.h**.

### std::filesystem::path::path (path && \_\_p)` [inline]`, ` [noexcept]`

Definition at line **274** of file **bits/fs\_path.h**.

### std::filesystem::path::path (string\_type && \_\_source, format = `auto_format`)` [inline]`

Definition at line **282** of file **bits/fs\_path.h**.

### template\<typename \_Source , typename \_Require = \_\_detail::\_Path\<\_Source\>\> std::filesystem::path::path (\_Source const & \_\_source, format = `auto_format`)` [inline]`

Definition at line **288** of file **bits/fs\_path.h**.

### template\<typename \_InputIterator , typename \_Require = \_\_detail::\_Path2\<\_InputIterator\>\> std::filesystem::path::path (\_InputIterator \_\_first, \_InputIterator \_\_last, format = `auto_format`)` [inline]`

Definition at line **294** of file **bits/fs\_path.h**.

### template\<typename \_Source , typename \_Require = \_\_detail::\_Path\<\_Source\>, typename \_Require2 = \_\_detail::\_\_value\_type\_is\_char\<\_Source\>\> std::filesystem::path::path (\_Source const & \_\_src, const locale & \_\_loc, format = `auto_format`)` [inline]`

Definition at line **301** of file **bits/fs\_path.h**.

### template\<typename \_InputIterator , typename \_Require = \_\_detail::\_Path2\<\_InputIterator\>, typename \_Req2 = \_\_detail::\_\_value\_type\_is\_char\<\_InputIterator\>\> std::filesystem::path::path (\_InputIterator \_\_first, \_InputIterator \_\_last, const locale & \_\_loc, format = `auto_format`)` [inline]`

Definition at line **308** of file **bits/fs\_path.h**.

## Member Function Documentation

### template\<typename \_InputIterator \> \_\_detail::\_Path2\< \_InputIterator \> & std::filesystem::path::append (\_InputIterator \_\_first, \_InputIterator \_\_last)` [inline]`

Definition at line **359** of file **bits/fs\_path.h**.

### template\<typename \_Source \> \_\_detail::\_Path\< \_Source \> & std::filesystem::path::append (\_Source const & \_\_source)` [inline]`

Definition at line **351** of file **bits/fs\_path.h**.

### template\<typename \_InputIterator \> \_\_detail::\_Path2\< \_InputIterator \> & std::filesystem::path::assign (\_InputIterator \_\_first, \_InputIterator \_\_last)` [inline]`

Definition at line **334** of file **bits/fs\_path.h**.

### template\<typename \_Source \> \_\_detail::\_Path\< \_Source \> & std::filesystem::path::assign (\_Source const & \_\_source)` [inline]`

Definition at line **329** of file **bits/fs\_path.h**.

### const value\_type \* std::filesystem::path::c\_str () const` [inline]`, ` [noexcept]`

Definition at line **411** of file **bits/fs\_path.h**.

### void std::filesystem::path::clear ()` [inline]`, ` [noexcept]`

Definition at line **399** of file **bits/fs\_path.h**.

### template\<typename \_InputIterator \> \_\_detail::\_Path2\< \_InputIterator \> & std::filesystem::path::concat (\_InputIterator \_\_first, \_InputIterator \_\_last)` [inline]`

Definition at line **391** of file **bits/fs\_path.h**.

### template\<typename \_Source \> \_\_detail::\_Path\< \_Source \> & std::filesystem::path::concat (\_Source const & \_\_x)` [inline]`

Definition at line **383** of file **bits/fs\_path.h**.

### bool std::filesystem::path::empty () const` [inline]`, ` [noexcept]`

Definition at line **471** of file **bits/fs\_path.h**.

### bool std::filesystem::path::is\_relative () const` [inline]`, ` [noexcept]`

Definition at line **481** of file **bits/fs\_path.h**.

### const string\_type & std::filesystem::path::native () const` [inline]`, ` [noexcept]`

Definition at line **410** of file **bits/fs\_path.h**.

### std::filesystem::path::operator string\_type () const` [inline]`

Definition at line **412** of file **bits/fs\_path.h**.

### template\<typename \_Source \> \_\_detail::\_Path\< \_Source \> & std::filesystem::path::operator+= (\_Source const & \_\_x)` [inline]`

Definition at line **375** of file **bits/fs\_path.h**.

### template\<typename \_Source \> \_\_detail::\_Path\< \_Source \> & std::filesystem::path::operator/= (\_Source const & \_\_source)` [inline]`

Definition at line **343** of file **bits/fs\_path.h**.

### template\<typename \_Source \> \_\_detail::\_Path\< \_Source \> & std::filesystem::path::operator= (\_Source const & \_\_source)` [inline]`

Definition at line **324** of file **bits/fs\_path.h**.

## Friends And Related Function Documentation

### bool operator!= (const path & \_\_lhs, const path & \_\_rhs)` [friend]`

Compare paths.

Definition at line **528** of file **bits/fs\_path.h**.

### path operator/ (const path & \_\_lhs, const path & \_\_rhs)` [friend]`

Append one path to another.

Definition at line **549** of file **bits/fs\_path.h**.

### bool operator\< (const path & \_\_lhs, const path & \_\_rhs)` [friend]`

Compare paths.

Definition at line **532** of file **bits/fs\_path.h**.

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

Definition at line **497** of file **bits/fs\_path.h**.

### bool operator\<= (const path & \_\_lhs, const path & \_\_rhs)` [friend]`

Compare paths.

Definition at line **536** of file **bits/fs\_path.h**.

### bool operator== (const path & \_\_lhs, const path & \_\_rhs)` [friend]`

Compare paths.

Definition at line **518** of file **bits/fs\_path.h**.

### bool operator\> (const path & \_\_lhs, const path & \_\_rhs)` [friend]`

Compare paths.

Definition at line **540** of file **bits/fs\_path.h**.

### bool operator\>= (const path & \_\_lhs, const path & \_\_rhs)` [friend]`

Compare paths.

Definition at line **544** of file **bits/fs\_path.h**.

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

Definition at line **507** of file **bits/fs\_path.h**.

## Member Data Documentation

### constexpr value\_type std::filesystem::path::preferred\_separator` [static]`, ` [constexpr]`

Definition at line **261** of file **bits/fs\_path.h**.

## Author

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