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
Run this code
Output:
/bar bar
[edit] See also
|    replaces the extension  (public member function)  |