std::filesystem::path::remove_filename
| path& remove_filename() | (1) | (since C++17) | 
|---|
移除单个文件名组件。
如果路径没有文件名组件%28,则行为未定义has_filename回报false29%。
参数
%280%29
返回值
*this...
例外
%280%29
例
二次
#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;
 
int main()
{
 
    std::cout << fs::path("/foo").remove_filename() << '\n'
              << fs::path("/").remove_filename() << '\n';
}二次
产出:
二次
"/"
""二次
另见
| 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 of Template:cpp/filesystempath/title) | 
 © cppreference.com在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

