[fs.path.member]

# 31 Input/output library [[input.output]](./#input.output)

## 31.12 File systems [[filesystems]](filesystems#fs.path.member)

### 31.12.6 Class path [[fs.class.path]](fs.class.path#fs.path.member)

#### 31.12.6.5 Members [fs.path.member]

#### [31.12.6.5.1](#fs.path.construct) Constructors [[fs.path.construct]](fs.path.construct)

[ð](#lib:path,constructor)

`path() noexcept;
`

[1](#fs.path.construct-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14134)

*Postconditions*: empty() is true[.](#fs.path.construct-1.sentence-1)

[ð](#lib:path,constructor_)

`path(const path& p);
path(path&& p) noexcept;
`

[2](#fs.path.construct-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14146)

*Effects*: Constructs an object of class path having the same pathname in the native and generic formats, respectively,
as the original value of p[.](#fs.path.construct-2.sentence-1)

In the second form, p is left in a valid but unspecified state[.](#fs.path.construct-2.sentence-2)

[ð](#lib:path,constructor__)

`path(string_type&& source, format fmt = auto_format);
`

[3](#fs.path.construct-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14160)

*Effects*: Constructs an object of class path for which the pathname in the detected-format of source has the original value of source ([[fs.path.fmt.cvt]](fs.path.fmt.cvt "31.12.6.3.1 Argument format conversions")),
converting format if required ([[fs.path.fmt.cvt]](fs.path.fmt.cvt "31.12.6.3.1 Argument format conversions"))[.](#fs.path.construct-3.sentence-1)

source is left in a valid but unspecified state[.](#fs.path.construct-3.sentence-2)

[ð](#lib:path,constructor___)

`template<class Source>
  path(const Source& source, format fmt = auto_format);
template<class InputIterator>
  path(InputIterator first, InputIterator last, format fmt = auto_format);
`

[4](#fs.path.construct-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14178)

*Effects*: Let s be the effective range of source ([[fs.path.req]](fs.path.req "31.12.6.4 Requirements"))
or the range [first, last), with the encoding converted if required ([[fs.path.cvt]](fs.path.cvt "31.12.6.3 Conversions"))[.](#fs.path.construct-4.sentence-1)

Finds the detected-format of s ([[fs.path.fmt.cvt]](fs.path.fmt.cvt "31.12.6.3.1 Argument format conversions"))
and constructs an object of class path for which the pathname in that format is s[.](#fs.path.construct-4.sentence-2)

[ð](#lib:path,constructor____)

`template<class Source>
  path(const Source& source, const locale& loc, format fmt = auto_format);
template<class InputIterator>
  path(InputIterator first, InputIterator last, const locale& loc, format fmt = auto_format);
`

[5](#fs.path.construct-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14196)

*Mandates*: The value type of Source and InputIterator ischar[.](#fs.path.construct-5.sentence-1)

[6](#fs.path.construct-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14201)

*Effects*: Let s be the effective range of source or the range [first, last),
after converting the encoding as
follows:

- [(6.1)](#fs.path.construct-6.1)

  If value_type is wchar_t, converts to the native
wide encoding ([[fs.path.type.cvt]](fs.path.type.cvt "31.12.6.3.2 Type and encoding conversions")) using the codecvt<​wchar_t, char, mbstate_t> facet of loc[.](#fs.path.construct-6.1.sentence-1)

- [(6.2)](#fs.path.construct-6.2)

  Otherwise a conversion is performed using thecodecvt<wchar_t, char, mbstate_t> facet of loc, and then a second
conversion to the current ordinary encoding[.](#fs.path.construct-6.2.sentence-1)

[7](#fs.path.construct-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14218)

Finds the detected-format of s ([[fs.path.fmt.cvt]](fs.path.fmt.cvt "31.12.6.3.1 Argument format conversions"))
and constructs an object of class path for which the pathname in that format is s[.](#fs.path.construct-7.sentence-1)

[*Example [1](#fs.path.construct-example-1)*:

A string is to be read from a database
that is encoded in ISO/IEC 8859-1, and used to create a directory:namespace fs = std::filesystem;
std::string latin1_string = read_latin1_data();
codecvt_8859_1<wchar_t> latin1_facet;
std::locale latin1_locale(std::locale(), latin1_facet);
fs::create_directory(fs::path(latin1_string, latin1_locale));

For POSIX-based operating systems, the path is constructed by first usinglatin1_facet to convert ISO/IEC 8859-1 encodedlatin1_string to a wide character string in the native wide
encoding ([[fs.path.type.cvt]](fs.path.type.cvt "31.12.6.3.2 Type and encoding conversions"))[.](#fs.path.construct-7.sentence-3)

The resulting wide string is then
converted to an ordinary character
pathname string in the current native ordinary encoding[.](#fs.path.construct-7.sentence-4)

If the
native wide encoding is UTF-16 or UTF-32, and the current native ordinary
encoding is UTF-8, all of the characters in the ISO/IEC 8859-1 character set
will be converted to their Unicode representation, but for other native
ordinary encodings some characters may have no representation[.](#fs.path.construct-7.sentence-5)

For Windows-based operating systems, the path is constructed by
using latin1_facet to convert ISO/IEC 8859-1 encodedlatin1_string to a UTF-16 encoded wide character pathname
string[.](#fs.path.construct-7.sentence-6)

All of the characters in the ISO/IEC 8859-1 character set will be
converted to their Unicode representation[.](#fs.path.construct-7.sentence-7)

â *end example*]

#### [31.12.6.5.2](#fs.path.assign) Assignments [[fs.path.assign]](fs.path.assign)

[ð](#lib:operator=,path)

`path& operator=(const path& p);
`

[1](#fs.path.assign-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14260)

*Effects*: If *this and p are the same
object, has no effect[.](#fs.path.assign-1.sentence-1)

Otherwise,
sets both respective pathnames of *this to the respective pathnames of p[.](#fs.path.assign-1.sentence-2)

[2](#fs.path.assign-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14268)

*Returns*: *this[.](#fs.path.assign-2.sentence-1)

[ð](#lib:operator=,path_)

`path& operator=(path&& p) noexcept;
`

[3](#fs.path.assign-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14279)

*Effects*: If *this and p are the same
object, has no effect[.](#fs.path.assign-3.sentence-1)

Otherwise,
sets both respective pathnames of *this to the respective pathnames of p[.](#fs.path.assign-3.sentence-2)

p is left in a valid but unspecified state[.](#fs.path.assign-3.sentence-3)

[*Note [1](#fs.path.assign-note-1)*:

A valid implementation is swap(p)[.](#fs.path.assign-3.sentence-4)

â *end note*]

[4](#fs.path.assign-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14290)

*Returns*: *this[.](#fs.path.assign-4.sentence-1)

[ð](#lib:operator=,path__)

`path& operator=(string_type&& source);
path& assign(string_type&& source);
`

[5](#fs.path.assign-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14303)

*Effects*: Sets the pathname in the detected-format of source to the original value of source[.](#fs.path.assign-5.sentence-1)

source is left in a valid but unspecified state[.](#fs.path.assign-5.sentence-2)

[6](#fs.path.assign-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14309)

*Returns*: *this[.](#fs.path.assign-6.sentence-1)

[ð](#lib:operator=,path___)

`template<class Source>
  path& operator=(const Source& source);
template<class Source>
  path& assign(const Source& source);
template<class InputIterator>
  path& assign(InputIterator first, InputIterator last);
`

[7](#fs.path.assign-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14326)

*Effects*: Let s be the effective range of source ([[fs.path.req]](fs.path.req "31.12.6.4 Requirements"))
or the range [first, last), with the encoding converted if required ([[fs.path.cvt]](fs.path.cvt "31.12.6.3 Conversions"))[.](#fs.path.assign-7.sentence-1)

Finds the detected-format of s ([[fs.path.fmt.cvt]](fs.path.fmt.cvt "31.12.6.3.1 Argument format conversions"))
and sets the pathname in that format to s[.](#fs.path.assign-7.sentence-2)

[8](#fs.path.assign-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14333)

*Returns*: *this[.](#fs.path.assign-8.sentence-1)

#### [31.12.6.5.3](#fs.path.append) Appends [[fs.path.append]](fs.path.append)

[1](#fs.path.append-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14340)

The append operations use operator/= to denote their semantic effect of appending[*preferred-separator*](fs.path.generic#nt:preferred-separator "31.12.6.2 Generic pathname format [fs.path.generic]") when needed[.](#fs.path.append-1.sentence-1)

[ð](#lib:operator/=,path)

`path& operator/=(const path& p);
`

[2](#fs.path.append-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14350)

*Effects*: If p.is_absolute() || (p.has_root_name() && p.root_name() != root_name()),
then operator=(p)[.](#fs.path.append-2.sentence-1)

[3](#fs.path.append-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14355)

Otherwise, modifies *this as if by these steps:

- [(3.1)](#fs.path.append-3.1)

  If p.has_root_directory(),
 then removes any root directory and relative path
 from the generic format pathname[.](#fs.path.append-3.1.sentence-1)
  Otherwise,
 if !has_root_directory() && is_absolute() is true or if has_filename() is true,
 then appends path​::​preferred_separator to the generic format pathname[.](#fs.path.append-3.1.sentence-2)

- [(3.2)](#fs.path.append-3.2)

  Then appends the native format pathname of p,
 omitting any [*root-name*](fs.path.generic#nt:root-name "31.12.6.2 Generic pathname format [fs.path.generic]") from its generic format pathname,
 to the native format pathname[.](#fs.path.append-3.2.sentence-1)

[4](#fs.path.append-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14370)

[*Example [1](#fs.path.append-example-1)*:

Even if //host is interpreted as a [*root-name*](fs.path.generic#nt:root-name "31.12.6.2 Generic pathname format [fs.path.generic]"),
both of the paths path("//host")/"foo" and path("//host/")/"foo" equal "//host/foo" (although the former might use backslash as the
preferred separator)[.](#fs.path.append-4.sentence-1)

Expression examples:// On POSIX, path("foo") /= path(""); // yields path("foo/") path("foo") /= path("/bar"); // yields path("/bar")// On Windows, path("foo") /= path(""); // yields path("foo\\") path("foo") /= path("/bar"); // yields path("/bar") path("foo") /= path("c:/bar"); // yields path("c:/bar") path("foo") /= path("c:"); // yields path("c:") path("c:") /= path(""); // yields path("c:") path("c:foo") /= path("/bar"); // yields path("c:/bar") path("c:foo") /= path("c:bar"); // yields path("c:foo\\bar")

â *end example*]

[5](#fs.path.append-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14394)

*Returns*: *this[.](#fs.path.append-5.sentence-1)

[ð](#lib:operator/=,path_)

`template<class Source>
  path& operator/=(const Source& source);
template<class Source>
  path& append(const Source& source);
`

[6](#fs.path.append-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14409)

*Effects*: Equivalent to: return operator/=(path(source));

[ð](#lib:operator/=,path__)

`template<class InputIterator>
  path& append(InputIterator first, InputIterator last);
`

[7](#fs.path.append-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14422)

*Effects*: Equivalent to: return operator/=(path(first, last));

#### [31.12.6.5.4](#fs.path.concat) Concatenation [[fs.path.concat]](fs.path.concat)

[ð](#lib:operator+=,path)

`path& operator+=(const path& x);
path& operator+=(const string_type& x);
path& operator+=(basic_string_view<value_type> x);
path& operator+=(const value_type* x);
template<class Source>
  path& operator+=(const Source& x);
template<class Source>
  path& concat(const Source& x);
`

[1](#fs.path.concat-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14443)

*Effects*: Appends path(x).native() to the pathname in the native format[.](#fs.path.concat-1.sentence-1)

[*Note [1](#fs.path.concat-note-1)*:

This directly manipulates the value of native(),
which is not necessarily portable between operating systems[.](#fs.path.concat-1.sentence-2)

â *end note*]

[2](#fs.path.concat-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14451)

*Returns*: *this[.](#fs.path.concat-2.sentence-1)

[ð](#lib:operator+=,path_)

`path& operator+=(value_type x);
template<class EcharT>
  path& operator+=(EcharT x);
`

[3](#fs.path.concat-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14465)

*Effects*: Equivalent to: return *this += basic_string_view(&x, 1);

[ð](#lib:concat,path__)

`template<class InputIterator>
  path& concat(InputIterator first, InputIterator last);
`

[4](#fs.path.concat-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14477)

*Effects*: Equivalent to: return *this += path(first, last);

#### [31.12.6.5.5](#fs.path.modifiers) Modifiers [[fs.path.modifiers]](fs.path.modifiers)

[ð](#lib:clear,path)

`void clear() noexcept;
`

[1](#fs.path.modifiers-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14490)

*Postconditions*: empty() is true[.](#fs.path.modifiers-1.sentence-1)

[ð](#lib:make_preferred,path)

`path& make_preferred();
`

[2](#fs.path.modifiers-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14501)

*Effects*: Each [*directory-separator*](fs.path.generic#nt:directory-separator "31.12.6.2 Generic pathname format [fs.path.generic]") of the pathname in the generic format
is converted to [*preferred-separator*](fs.path.generic#nt:preferred-separator "31.12.6.2 Generic pathname format [fs.path.generic]")[.](#fs.path.modifiers-2.sentence-1)

[3](#fs.path.modifiers-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14507)

*Returns*: *this[.](#fs.path.modifiers-3.sentence-1)

[4](#fs.path.modifiers-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14511)

[*Example [1](#fs.path.modifiers-example-1)*: path p("foo/bar");
std::cout << p << '\n';
p.make_preferred();
std::cout << p << '\n';

On an operating system where [*preferred-separator*](fs.path.generic#nt:preferred-separator "31.12.6.2 Generic pathname format [fs.path.generic]") is a slash,
the output is:"foo/bar""foo/bar"

On an operating system where [*preferred-separator*](fs.path.generic#nt:preferred-separator "31.12.6.2 Generic pathname format [fs.path.generic]") is a backslash, the
output is:"foo/bar""foo\bar"

â *end example*]

[ð](#lib:remove_filename,path)

`path& remove_filename();
`

[5](#fs.path.modifiers-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14540)

*Effects*: Remove the generic format pathname of filename() from the generic format pathname[.](#fs.path.modifiers-5.sentence-1)

[6](#fs.path.modifiers-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14544)

*Postconditions*: !has_filename()[.](#fs.path.modifiers-6.sentence-1)

[7](#fs.path.modifiers-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14548)

*Returns*: *this[.](#fs.path.modifiers-7.sentence-1)

[8](#fs.path.modifiers-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14552)

[*Example [2](#fs.path.modifiers-example-2)*: path("foo/bar").remove_filename(); // yields "foo/" path("foo/").remove_filename(); // yields "foo/" path("/foo").remove_filename(); // yields "/" path("/").remove_filename(); // yields "/" â *end example*]

[ð](#lib:replace_filename,path)

`path& replace_filename(const path& replacement);
`

[9](#fs.path.modifiers-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14569)

*Effects*: Equivalent to:remove_filename();operator/=(replacement);

[10](#fs.path.modifiers-10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14577)

*Returns*: *this[.](#fs.path.modifiers-10.sentence-1)

[11](#fs.path.modifiers-11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14581)

[*Example [3](#fs.path.modifiers-example-3)*: path("/foo").replace_filename("bar"); // yields "/bar" on POSIX path("/").replace_filename("bar"); // yields "/bar" on POSIX â *end example*]

[ð](#lib:replace_extension,path)

`path& replace_extension(const path& replacement = path());
`

[12](#fs.path.modifiers-12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14596)

*Effects*: 

- [(12.1)](#fs.path.modifiers-12.1)

Any existing extension() ([[fs.path.decompose]](#fs.path.decompose "31.12.6.5.9 Decomposition")) is removed from the
 pathname in the generic format,
 then

- [(12.2)](#fs.path.modifiers-12.2)

If replacement is not empty and does not begin with a dot
 character, a dot character is appended to the pathname in the generic format, then

- [(12.3)](#fs.path.modifiers-12.3)

operator+=(replacement);[.](#fs.path.modifiers-12.sentence-1)

[13](#fs.path.modifiers-13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14608)

*Returns*: *this[.](#fs.path.modifiers-13.sentence-1)

[ð](#lib:swap,path)

`void swap(path& rhs) noexcept;
`

[14](#fs.path.modifiers-14)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14619)

*Effects*: Swaps the contents (in all formats) of the two paths[.](#fs.path.modifiers-14.sentence-1)

[15](#fs.path.modifiers-15)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14623)

*Complexity*: Constant time[.](#fs.path.modifiers-15.sentence-1)

#### [31.12.6.5.6](#fs.path.native.obs) Native format observers [[fs.path.native.obs]](fs.path.native.obs)

[1](#fs.path.native.obs-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14630)

The string returned by all native format observers is in the native pathname format ([[fs.class.path]](fs.class.path "31.12.6 Class path"))[.](#fs.path.native.obs-1.sentence-1)

[ð](#lib:native,path)

`const string_type& native() const noexcept;
`

[2](#fs.path.native.obs-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14639)

*Returns*: The pathname in the native format[.](#fs.path.native.obs-2.sentence-1)

[ð](#lib:c_str,path)

`const value_type* c_str() const noexcept;
`

[3](#fs.path.native.obs-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14650)

*Effects*: Equivalent to: return native().c_str();

[ð](#lib:operator_string_type,path)

`operator string_type() const;
`

[4](#fs.path.native.obs-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14661)

*Returns*: native()[.](#fs.path.native.obs-4.sentence-1)

[ð](#lib:string,path)

`template<class EcharT, class traits = char_traits<EcharT>, class Allocator = allocator<EcharT>>
  basic_string<EcharT, traits, Allocator> string(const Allocator& a = Allocator()) const;
`

[5](#fs.path.native.obs-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14673)

*Returns*: native()[.](#fs.path.native.obs-5.sentence-1)

[6](#fs.path.native.obs-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14677)

*Remarks*: All memory allocation, including for the return value, shall
be performed by a[.](#fs.path.native.obs-6.sentence-1)

Conversion, if any, is specified by[[fs.path.cvt]](fs.path.cvt "31.12.6.3 Conversions")[.](#fs.path.native.obs-6.sentence-2)

[ð](#lib:system_encoded_string,path)

`std::string system_encoded_string() const;
std::wstring wstring() const;
std::u8string u8string() const;
std::u16string u16string() const;
std::u32string u32string() const;
`

[7](#fs.path.native.obs-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14698)

*Returns*: native()[.](#fs.path.native.obs-7.sentence-1)

[8](#fs.path.native.obs-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14702)

*Remarks*: Conversion, if any, is performed as specified
by [[fs.path.cvt]](fs.path.cvt "31.12.6.3 Conversions")[.](#fs.path.native.obs-8.sentence-1)

[ð](#lib:display_string,path)

`std::string display_string() const;
`

[9](#fs.path.native.obs-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14714)

*Returns*: format("{}", *this)[.](#fs.path.native.obs-9.sentence-1)

[*Note [1](#fs.path.native.obs-note-1)*:

The returned string is suitable for use with formatting ([[format.functions]](format.functions "28.5.5 Formatting functions"))
and print functions ([[print.fun]](print.fun "31.7.10 Print functions"))[.](#fs.path.native.obs-9.sentence-2)

â *end note*]

#### [31.12.6.5.7](#fs.path.generic.obs) Generic format observers [[fs.path.generic.obs]](fs.path.generic.obs)

[1](#fs.path.generic.obs-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14725)

Generic format observer functions return strings formatted according to the[generic pathname format](fs.path.generic "31.12.6.2 Generic pathname format [fs.path.generic]")[.](#fs.path.generic.obs-1.sentence-1)

A single slash ('/') character is used as
the [*directory-separator*](fs.path.generic#nt:directory-separator "31.12.6.2 Generic pathname format [fs.path.generic]")[.](#fs.path.generic.obs-1.sentence-2)

[2](#fs.path.generic.obs-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14731)

[*Example [1](#fs.path.generic.obs-example-1)*:

On an operating system that uses backslash as
its [*preferred-separator*](fs.path.generic#nt:preferred-separator "31.12.6.2 Generic pathname format [fs.path.generic]"),path("foo\\bar").generic_string() returns "foo/bar"[.](#fs.path.generic.obs-2.sentence-1)

â *end example*]

[ð](#lib:generic_string,path)

`template<class EcharT, class traits = char_traits<EcharT>, class Allocator = allocator<EcharT>>
  basic_string<EcharT, traits, Allocator> generic_string(const Allocator& a = Allocator()) const;
`

[3](#fs.path.generic.obs-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14748)

*Returns*: The pathname in the generic format[.](#fs.path.generic.obs-3.sentence-1)

[4](#fs.path.generic.obs-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14752)

*Remarks*: All memory allocation, including for the return value, shall
be performed by a[.](#fs.path.generic.obs-4.sentence-1)

Conversion, if any, is specified by[[fs.path.cvt]](fs.path.cvt "31.12.6.3 Conversions")[.](#fs.path.generic.obs-4.sentence-2)

[ð](#lib:generic_system_encoded_string,path)

`std::string generic_system_encoded_string() const;
std::wstring generic_wstring() const;
std::u8string generic_u8string() const;
std::u16string generic_u16string() const;
std::u32string generic_u32string() const;
`

[5](#fs.path.generic.obs-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14773)

*Returns*: The pathname in the generic format[.](#fs.path.generic.obs-5.sentence-1)

[6](#fs.path.generic.obs-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14777)

*Remarks*: Conversion, if any, is specified by [[fs.path.cvt]](fs.path.cvt "31.12.6.3 Conversions")[.](#fs.path.generic.obs-6.sentence-1)

[ð](#lib:generic_display_string,path)

`std::string generic_display_string() const;
`

[7](#fs.path.generic.obs-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14788)

*Returns*: format("{:g}", *this)[.](#fs.path.generic.obs-7.sentence-1)

[*Note [1](#fs.path.generic.obs-note-1)*:

The returned string is suitable for use with formatting ([[format.functions]](format.functions "28.5.5 Formatting functions"))
and print functions ([[print.fun]](print.fun "31.7.10 Print functions"))[.](#fs.path.generic.obs-7.sentence-2)

â *end note*]

#### [31.12.6.5.8](#fs.path.compare) Compare [[fs.path.compare]](fs.path.compare)

[ð](#lib:compare,path)

`int compare(const path& p) const noexcept;
`

[1](#fs.path.compare-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14805)

*Returns*: 

- [(1.1)](#fs.path.compare-1.1)

  Let rootNameComparison be the result of this->root_name().native().compare(p.root_name().native())[.](#fs.path.compare-1.1.sentence-1)
  If rootNameComparison is not 0, rootNameComparison[.](#fs.path.compare-1.1.sentence-2)

- [(1.2)](#fs.path.compare-1.2)

  Otherwise, if !this->has_root_directory() and p.has_root_directory(),
 a value less than 0[.](#fs.path.compare-1.2.sentence-1)

- [(1.3)](#fs.path.compare-1.3)

  Otherwise, if this->has_root_directory() and !p.has_root_directory(),
 a value greater than 0[.](#fs.path.compare-1.3.sentence-1)

- [(1.4)](#fs.path.compare-1.4)

  Otherwise, if native() for the elements of this->relative_path() are lexicographically less than native() for the elements of p.relative_path(),
 a value less than 0[.](#fs.path.compare-1.4.sentence-1)

- [(1.5)](#fs.path.compare-1.5)

  Otherwise, if native() for the elements of this->relative_path() are lexicographically greater than native() for the elements of p.relative_path(),
 a value greater than 0[.](#fs.path.compare-1.5.sentence-1)

- [(1.6)](#fs.path.compare-1.6)

  Otherwise, 0[.](#fs.path.compare-1.6.sentence-1)

[ð](#lib:compare,path_)

`int compare(const string_type& s) const;
int compare(basic_string_view<value_type> s) const;
int compare(const value_type* s) const;
`

[2](#fs.path.compare-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14846)

*Effects*: Equivalent to: return compare(path(s));

#### [31.12.6.5.9](#fs.path.decompose) Decomposition [[fs.path.decompose]](fs.path.decompose)

[ð](#lib:root_name,path)

`path root_name() const;
`

[1](#fs.path.decompose-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14859)

*Returns*: [*root-name*](fs.path.generic#nt:root-name "31.12.6.2 Generic pathname format [fs.path.generic]"), if the pathname in the generic format
includes [*root-name*](fs.path.generic#nt:root-name "31.12.6.2 Generic pathname format [fs.path.generic]"), otherwise path()[.](#fs.path.decompose-1.sentence-1)

[ð](#lib:root_directory,path)

`path root_directory() const;
`

[2](#fs.path.decompose-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14871)

*Returns*: [*root-directory*](fs.path.generic#nt:root-directory "31.12.6.2 Generic pathname format [fs.path.generic]"), if the pathname in the generic format
includes [*root-directory*](fs.path.generic#nt:root-directory "31.12.6.2 Generic pathname format [fs.path.generic]"), otherwise path()[.](#fs.path.decompose-2.sentence-1)

[ð](#lib:root_path,path)

`path root_path() const;
`

[3](#fs.path.decompose-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14883)

*Returns*: root_name() / root_directory()[.](#fs.path.decompose-3.sentence-1)

[ð](#lib:relative_path,path)

`path relative_path() const;
`

[4](#fs.path.decompose-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14894)

*Returns*: A path composed from the pathname in the generic format,
if empty() is false, beginning
with the first [*filename*](fs.path.generic#nt:filename "31.12.6.2 Generic pathname format [fs.path.generic]") after root_path()[.](#fs.path.decompose-4.sentence-1)

Otherwise, path()[.](#fs.path.decompose-4.sentence-2)

[ð](#lib:parent_path,path)

`path parent_path() const;
`

[5](#fs.path.decompose-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14907)

*Returns*: *this if has_relative_path() is false,
otherwise a path whose generic format pathname is
the longest prefix of the generic format pathname of *this that produces one fewer element in its iteration[.](#fs.path.decompose-5.sentence-1)

[ð](#lib:filename,path)

`path filename() const;
`

[6](#fs.path.decompose-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14921)

*Returns*: relative_path().empty() ? path() : *--end()[.](#fs.path.decompose-6.sentence-1)

[7](#fs.path.decompose-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14925)

[*Example [1](#fs.path.decompose-example-1)*: path("/foo/bar.txt").filename(); // yields "bar.txt" path("/foo/bar").filename(); // yields "bar" path("/foo/bar/").filename(); // yields "" path("/").filename(); // yields "" path("//host").filename(); // yields "" path(".").filename(); // yields "." path("..").filename(); // yields ".." â *end example*]

[ð](#lib:stem,path)

`path stem() const;
`

[8](#fs.path.decompose-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14945)

*Returns*: Let f be the generic format pathname of filename()[.](#fs.path.decompose-8.sentence-1)

Returns a path whose pathname in the generic format is

- [(8.1)](#fs.path.decompose-8.1)

f, if it contains no periods other than a leading period
or consists solely of one or two periods;

- [(8.2)](#fs.path.decompose-8.2)

otherwise, the prefix of f ending before its last period[.](#fs.path.decompose-8.sentence-2)

[9](#fs.path.decompose-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14955)

[*Example [2](#fs.path.decompose-example-2)*: std::cout << path("/foo/bar.txt").stem(); // outputs "bar" path p = "foo.bar.baz.tar";for (; !p.extension().empty(); p = p.stem()) std::cout << p.extension() << '\n'; // outputs: .tar// .baz// .bar â *end example*]

[ð](#lib:extension,path)

`path extension() const;
`

[10](#fs.path.decompose-10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14975)

*Returns*: A path whose pathname in the generic format is
the suffix of filename() not included in stem()[.](#fs.path.decompose-10.sentence-1)

[11](#fs.path.decompose-11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14980)

[*Example [3](#fs.path.decompose-example-3)*: path("/foo/bar.txt").extension(); // yields ".txt" and stem() is "bar" path("/foo/bar").extension(); // yields "" and stem() is "bar" path("/foo/.profile").extension(); // yields "" and stem() is ".profile" path(".bar").extension(); // yields "" and stem() is ".bar" path("..bar").extension(); // yields ".bar" and stem() is "." â *end example*]

[12](#fs.path.decompose-12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14991)

[*Note [1](#fs.path.decompose-note-1)*:

The period is included in the return value so that it is
 possible to distinguish between no extension and an empty extension[.](#fs.path.decompose-12.sentence-1)

â *end note*]

[13](#fs.path.decompose-13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14997)

[*Note [2](#fs.path.decompose-note-2)*:

On non-POSIX operating systems, for a path p,
it is possible that p.stem() + p.extension() == p.filename() is false,
even though the generic format pathnames are the same[.](#fs.path.decompose-13.sentence-1)

â *end note*]

#### [31.12.6.5.10](#fs.path.query) Query [[fs.path.query]](fs.path.query)

[ð](#lib:empty,path)

`bool empty() const noexcept;
`

[1](#fs.path.query-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15013)

*Returns*: true if the pathname in the generic format is empty, otherwise false[.](#fs.path.query-1.sentence-1)

[ð](#lib:has_root_path,path)

`bool has_root_path() const;
`

[2](#fs.path.query-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15024)

*Returns*: !root_path().empty()[.](#fs.path.query-2.sentence-1)

[ð](#lib:has_root_name,path)

`bool has_root_name() const;
`

[3](#fs.path.query-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15035)

*Returns*: !root_name().empty()[.](#fs.path.query-3.sentence-1)

[ð](#lib:has_root_directory,path)

`bool has_root_directory() const;
`

[4](#fs.path.query-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15046)

*Returns*: !root_directory().empty()[.](#fs.path.query-4.sentence-1)

[ð](#lib:has_relative_path,path)

`bool has_relative_path() const;
`

[5](#fs.path.query-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15057)

*Returns*: !relative_path().empty()[.](#fs.path.query-5.sentence-1)

[ð](#lib:has_parent_path,path)

`bool has_parent_path() const;
`

[6](#fs.path.query-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15068)

*Returns*: !parent_path().empty()[.](#fs.path.query-6.sentence-1)

[ð](#lib:has_filename,path)

`bool has_filename() const;
`

[7](#fs.path.query-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15079)

*Returns*: !filename().empty()[.](#fs.path.query-7.sentence-1)

[ð](#lib:has_stem,path)

`bool has_stem() const;
`

[8](#fs.path.query-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15090)

*Returns*: !stem().empty()[.](#fs.path.query-8.sentence-1)

[ð](#lib:has_extension,path)

`bool has_extension() const;
`

[9](#fs.path.query-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15101)

*Returns*: !extension().empty()[.](#fs.path.query-9.sentence-1)

[ð](#lib:is_absolute,path)

`bool is_absolute() const;
`

[10](#fs.path.query-10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15112)

*Returns*: true if the pathname in the native format
 contains an absolute path ([[fs.class.path]](fs.class.path "31.12.6 Class path")), otherwise false[.](#fs.path.query-10.sentence-1)

[11](#fs.path.query-11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15117)

[*Example [1](#fs.path.query-example-1)*:

path("/").is_absolute() is true for POSIX-based operating systems, and false for Windows-based
operating systems[.](#fs.path.query-11.sentence-1)

â *end example*]

[ð](#lib:is_relative,path)

`bool is_relative() const;
`

[12](#fs.path.query-12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15131)

*Returns*: !is_absolute()[.](#fs.path.query-12.sentence-1)

#### [31.12.6.5.11](#fs.path.gen) Generation [[fs.path.gen]](fs.path.gen)

[ð](#lib:lexically_normal,path)

`path lexically_normal() const;
`

[1](#fs.path.gen-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15144)

*Returns*: A path whose pathname in the generic format is
the normal form ([[fs.path.generic]](fs.path.generic "31.12.6.2 Generic pathname format")) of the pathname
in the generic format of *this[.](#fs.path.gen-1.sentence-1)

[2](#fs.path.gen-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15150)

[*Example [1](#fs.path.gen-example-1)*: assert(path("foo/./bar/..").lexically_normal() == "foo/");
assert(path("foo/.///bar/../").lexically_normal() == "foo/");

The above assertions will succeed[.](#fs.path.gen-2.sentence-1)

On Windows, the returned path's [*directory-separator*](fs.path.generic#nt:directory-separator "31.12.6.2 Generic pathname format [fs.path.generic]") characters
will be backslashes rather than slashes,
but that does not affect path equality[.](#fs.path.gen-2.sentence-2)

â *end example*]

[ð](#lib:lexically_relative,path)

`path lexically_relative(const path& base) const;
`

[3](#fs.path.gen-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15169)

*Effects*: If:

- [(3.1)](#fs.path.gen-3.1)

root_name() != base.root_name() is true, or

- [(3.2)](#fs.path.gen-3.2)

is_absolute() != base.is_absolute() is true, or

- [(3.3)](#fs.path.gen-3.3)

!has_root_directory() && base.has_root_directory() is true, or

- [(3.4)](#fs.path.gen-3.4)

any [*filename*](fs.path.generic#nt:filename "31.12.6.2 Generic pathname format [fs.path.generic]") inrelative_path() or base.relative_path() can be interpreted as a [*root-name*](fs.path.generic#nt:root-name "31.12.6.2 Generic pathname format [fs.path.generic]"),

returns path()[.](#fs.path.gen-3.sentence-1)

[*Note [1](#fs.path.gen-note-1)*:

On a POSIX implementation, no [*filename*](fs.path.generic#nt:filename "31.12.6.2 Generic pathname format [fs.path.generic]") in a [*relative-path*](fs.path.generic#nt:relative-path "31.12.6.2 Generic pathname format [fs.path.generic]") is acceptable as a [*root-name*](fs.path.generic#nt:root-name "31.12.6.2 Generic pathname format [fs.path.generic]")[.](#fs.path.gen-3.sentence-2)

â *end note*]

Determines the first mismatched element of *this and base as if by:auto [a, b] = mismatch(begin(), end(), base.begin(), base.end());

Then,

- [(3.5)](#fs.path.gen-3.5)

  if a == end() and b == base.end(), returns path("."); otherwise

- [(3.6)](#fs.path.gen-3.6)

  let n be the number of [*filename*](fs.path.generic#nt:filename "31.12.6.2 Generic pathname format [fs.path.generic]") elements in [b, base.end())
 that are not dot or dot-dot or empty, minus the number that are dot-dot[.](#fs.path.gen-3.6.sentence-1)
  If n<0, returns path(); otherwise

- [(3.7)](#fs.path.gen-3.7)

  if n == 0 and (a == end() || a->empty()),
 returns path("."); otherwise

- [(3.8)](#fs.path.gen-3.8)

  returns an object of class path that is default-constructed, followed by
  * [(3.8.1)](#fs.path.gen-3.8.1)

application of operator/=(path(".."))n times, and then

  * [(3.8.2)](#fs.path.gen-3.8.2)

application of operator/= for each element in [a, end())[.](#fs.path.gen-3.8.sentence-1)

[4](#fs.path.gen-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15215)

*Returns*: *this made relative to base[.](#fs.path.gen-4.sentence-1)

Does not resolve ([[fs.class.path]](fs.class.path "31.12.6 Class path")) symlinks[.](#fs.path.gen-4.sentence-2)

Does not first normalize ([[fs.path.generic]](fs.path.generic "31.12.6.2 Generic pathname format")) *this or base[.](#fs.path.gen-4.sentence-3)

[5](#fs.path.gen-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15221)

[*Example [2](#fs.path.gen-example-2)*: assert(path("/a/d").lexically_relative("/a/b/c") == "../../d");
assert(path("/a/b/c").lexically_relative("/a/d") == "../b/c");
assert(path("a/b/c").lexically_relative("a") == "b/c");
assert(path("a/b/c").lexically_relative("a/b/c/x/y") == "../..");
assert(path("a/b/c").lexically_relative("a/b/c") == ".");
assert(path("a/b").lexically_relative("c/d") == "../../a/b");

The above assertions will succeed[.](#fs.path.gen-5.sentence-1)

On Windows, the returned path's [*directory-separator*](fs.path.generic#nt:directory-separator "31.12.6.2 Generic pathname format [fs.path.generic]") characters
will be backslashes rather than slashes,
but that does not affect path equality[.](#fs.path.gen-5.sentence-2)

â *end example*]

[6](#fs.path.gen-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15237)

[*Note [2](#fs.path.gen-note-2)*:

If symlink following semantics are desired,
 use the operational function relative()[.](#fs.path.gen-6.sentence-1)

â *end note*]

[7](#fs.path.gen-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15243)

[*Note [3](#fs.path.gen-note-3)*:

If normalization ([[fs.path.generic]](fs.path.generic "31.12.6.2 Generic pathname format")) is needed
 to ensure consistent matching of elements,
 apply lexically_normal() to *this, base, or both[.](#fs.path.gen-7.sentence-1)

â *end note*]

[ð](#lib:lexically_proximate,path)

`path lexically_proximate(const path& base) const;
`

[8](#fs.path.gen-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15258)

*Returns*: If the value of lexically_relative(base) is not an empty path,
 return it[.](#fs.path.gen-8.sentence-1)

Otherwise return *this[.](#fs.path.gen-8.sentence-2)

[9](#fs.path.gen-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15263)

[*Note [4](#fs.path.gen-note-4)*:

If symlink following semantics are desired,
 use the operational function proximate()[.](#fs.path.gen-9.sentence-1)

â *end note*]

[10](#fs.path.gen-10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L15269)

[*Note [5](#fs.path.gen-note-5)*:

If normalization ([[fs.path.generic]](fs.path.generic "31.12.6.2 Generic pathname format")) is needed
 to ensure consistent matching of elements,
 apply lexically_normal() to *this, base, or both[.](#fs.path.gen-10.sentence-1)

â *end note*]
