std::experi...e_extension(3)
π std::experi...e_extension(3) π
okay so this page is from the C++ Standard Libary manual, and itβs all about std::experimental::filesystem::path::replace_extension. bestie, itβs giving filesystem TS realness, and weβre gonna get into it. β¨
πΈ NAME πΈ
std::experimental::filesystem::path::replace_extensionβ yep,std::experimental::filesystem::path::replace_extension(the page repeats its own name, iconic)
β¨ Synopsis β¨
path& replace_extension( const path& replacement = path() ); (1)
(filesystem TS)
It replaces the extension with replacement, or removes it when the default value of replacement is used. π
Hereβs the order of operations, no cap:
- Firstly, if this path has an
extension(), it is removed. - Then, a dot character is appended if
replacementis not empty or does not begin with a dot character. - Then
replacementis appended to the path.
π Parameters π
replacementβ the extension to replace with
π Return value π
*thisβ thatβs the whole return, bestie. No extra packaging. π«Ά
π₯ Exceptions π₯
May throw implementation-defined exceptions. π
π¦ Example π¦
// Run this code
#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';
}
π 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)
π Category π
* Noindexed pages
mwah π source is http://cppreference.com, version/date is 2024.06.10, and the footer name is std::experi...e_extension(3). periodt. π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms