[fs.path.modifiers] (original) (raw)

31 Input/output library [input.output]

31.12 File systems [filesystems]

31.12.6 Class path [fs.class.path]

31.12.6.5 Members [fs.path.member]

31.12.6.5.5 Modifiers [fs.path.modifiers]

Postconditions: empty() is true.

[Example 1: path p("foo/bar"); std::cout << p << '\n'; p.make_preferred(); std::cout << p << '\n';

On an operating system where preferred-separator is a slash, the output is:"foo/bar" "foo/bar"

On an operating system where preferred-separator is a backslash, the output is:"foo/bar" "foo\bar"

— _end example_]

Effects: Remove the generic format pathname of filename() from the generic format pathname.

Postconditions: !has_filename().

[Example 2: path("foo/bar").remove_filename(); path("foo/").remove_filename(); path("/foo").remove_filename(); path("/").remove_filename(); — _end example_]

path& replace_filename(const path& replacement);

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

[Example 3: path("/foo").replace_filename("bar"); path("/").replace_filename("bar"); — _end example_]

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

Effects:

void swap(path& rhs) noexcept;

Effects: Swaps the contents (in all formats) of the two paths.

Complexity: Constant time.