std::experimental::filesystem::path:: replace_extension
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_extension
(
const
path
&
replacement
=
path
(
)
)
;
|
(1) | (文件系统 TS) |
将扩展名替换为 replacement ,或当使用 replacement 的默认值时移除扩展名。
首先,若该路径存在 extension() ,则将其移除。
然后,如果 replacement 非空或不以点字符开头,则会追加一个点字符。
随后将 replacement 追加到路径中。
目录 |
参数
| replacement | - | 要替换的扩展名 |
返回值
* this
异常
可能抛出实现定义的异常。
示例
运行此代码
输出:
Was: "/foo/bar.jpeg" Now: "/foo/bar.jpg"
参见
|
返回文件扩展名路径组件
(公开成员函数) |
|
|
返回文件名路径组件
(公开成员函数) |
|
|
返回主干路径组件
(公开成员函数) |
|
|
检查对应的路径元素是否非空
(公开成员函数) |