std::experimental::filesystem::path::replace_extension

Replaces the extension with replacement or removes it when the default value of replacement is used.

# Declarations

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

(filesystem TS)

# Parameters

# Return value

*this

# Example

#include <experimental/filesystem>
#include <iostream>
namespace fs = std::experimental::filesystem;
 
int main()
{
    fs::path p = "/foo/bar.jpeg";
    std::cout << "Was: " << p << '\n';
    p.replace_extension(".jpg");
    std::cout << "Now: " << p << '\n';
}

# See also