std::experimental::filesystem::path::replace_filename

From cppreference.com
< cpp‎ | experimental‎ | fs‎ | path
path& replace_filename( const path& replacement );
(1) (filesystem TS)

Replaces a single filename component with replacement. Equivalent to the following:

remove_filename();
operator/=(replacement);

Contents

[edit] Parameters

(none)

[edit] Return value

*this

[edit] Exceptions

(none)

[edit] Example

#include <filesystem>
#include <iostream>
 
int main()
{
    std::cout << std::fs::path("/foo").replace_filename("bar") << '\n';
    std::cout << std::fs::path("/").replace_filename("bar") << '\n';
}

Output:

/bar
bar

[edit] See also

replaces the extension
(public member function)