std::filesy...ve_filename(3)
πΈ NAME πΈ
std::filesystem::path::remove_filename β and the NAME line is literally std::filesystem::path::remove_filename to std::filesystem::path::remove_filename (repetition ate, no notes π
). This page is from the C++ Standard Libary manual, and the header shows the very truncated title std::filesy...ve_filename(3) exactly like that. Manual name folded in near the top like a little name tag, bestie. π
β¨ Synopsis β¨
Hereβs the signature, and yes itβs giving main character energy since C++17:
path& remove_filename(); (since C++17)
remove_filename() removes a single generic-format filename component β the thing filename returns β from the given generic-format path.
After this function completes, has_filename returns false. Periodt. π
π«Ά Parameters π«Ά
- (none) β no params, no stress, she takes nothing. π
π Return value π
*this β thatβs it, thatβs the return value. π«Ά
π Exceptions π
May throw implementation-defined exceptions. (Not me reading βimplementation-definedβ and side-eyeing the standard π.)
π Example π
// Run this code
#include <filesystem>
#include <iostream>
namespace fs = std::filesystem;
int main()
{
fs::path p;
std::cout << std::boolalpha
<< (p = "foo/bar").remove_filename() << '\t' <<
p.has_filename() << '\n'
<< (p = "foo/").remove_filename() << '\t' <<
p.has_filename() << '\n'
<< (p = "/foo").remove_filename() << '\t' <<
p.has_filename() << '\n'
<< (p = "/").remove_filename() << '\t' <<
p.has_filename() << '\n'
<< (p = "").remove_filename() << '\t' << p.has_filename()
<< '\n';
}
π Output π
"foo/" false
"foo/" false
"/" false
"/" false
"" false
π¦ See also π¦
filenameβ returns the filename path component (public member function). πreplace_filenameβ replaces the last path component with another path (public member function). πhas_filenameβ checks if the corresponding path element is not empty (public member function). β¨
made with π from http://cppreference.com, dated 2024.06.10 β source/version + date, bestie, and thatβs the whole footer. bye! π
π¦ 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