Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
std::experi...e_extension(3)  C++ Standard Libary std::experi...e_extension(3)

NAME
       std::experimental::filesystem::path::replace_extension  -  std::experi-
       mental::filesystem::path::replace_extension

Synopsis
	  path&	replace_extension( const path& replacement  =  path()  );  (1)
       (filesystem TS)

	  Replaces  the	 extension with	replacement or removes it when the de-
       fault value of
	  replacement is used.

	  Firstly, if this path	has an extension(), it is removed.

	  Then,	a dot character	is appended if replacement  is	not  empty  or
       does not	begin with
	  a dot	character.

	  Then replacement is appended to the path.

Parameters
	  replacement -	the extension to replace with

Return value
	  *this

Exceptions
	  May throw implementation-defined exceptions.

Example
       // Run this code

	#include <iostream>
	#include <experimental/filesystem>
	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';
	}

Output:
	Was: "/foo/bar.jpeg"
	Now: "/foo/bar.jpg"

See also
	  extension	returns	the file extension path	component
			(public	member function)
	  filename	returns	the filename path component
			(public	member function)
	  stem		returns	the stem path component
			(public	member function)
	  has_extension	checks if the corresponding path element is not	empty
			(public	member function)

http://cppreference.com		  2022.07.31	  std::experi...e_extension(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::experimental::filesystem::path::replace_extension&sektion=3&manpath=FreeBSD+Ports+15.0>

home | help