std::experimental::filesystem::path:: replace_filename
From cppreference.net
<
cpp
|
experimental
|
fs
|
path
C++
Experimental
| Technical Specification | ||||
| Filesystem library (filesystem TS) | ||||
| Library fundamentals (library fundamentals TS) | ||||
| Library fundamentals 2 (library fundamentals TS v2) | ||||
| Library fundamentals 3 (library fundamentals TS v3) | ||||
| Extensions for parallelism (parallelism TS) | ||||
| Extensions for parallelism 2 (parallelism TS v2) | ||||
| Extensions for concurrency (concurrency TS) | ||||
| Extensions for concurrency 2 (concurrency TS v2) | ||||
| Concepts (concepts TS) | ||||
| Ranges (ranges TS) | ||||
| Reflection (reflection TS) | ||||
| Mathematical special functions (special functions TR) | ||||
| Experimental Non-TS | ||||
| Pattern Matching | ||||
| Linear Algebra | ||||
| std::execution | ||||
| Contracts | ||||
| 2D Graphics |
Filesystem library
| Classes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| File types | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
path
| Member functions | ||||
| Path decomposition | ||||
| Non-member functions | ||||
|
path
&
replace_filename
(
const
path
&
replacement
)
;
|
(文件系统 TS) | |
将单个文件名组件替换为 replacement 。
相当于以下内容:
remove_filename(); operator/=(replacement);
若路径没有文件名组件( has_filename 返回 false ),则行为未定义。
目录 |
参数
(无)
返回值
* this
异常
可能抛出实现定义的异常。
示例
运行此代码
#include <experimental/filesystem> #include <iostream> namespace fs = std::experimental::filesystem; int main() { std::cout << fs::path("/foo").replace_filename("bar") << '\n' << fs::path("/").replace_filename("bar") << '\n'; }
输出:
"/bar" "bar"
参见
|
替换扩展名
(公开成员函数) |
|
|
返回文件名路径组件
(公开成员函数) |
|
|
移除文件名路径组件
(公开成员函数) |
|
|
检查对应的路径元素是否非空
(公开成员函数) |