std::experimental::filesystem::path:: parent_path
| 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 |
| Classes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| File types | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
| Path decomposition | ||||
| Non-member functions | ||||
|
path parent_path
(
)
const
;
|
(文件系统 TS) | |
返回父目录的路径。若路径为空或仅包含单个元素( begin ( ) == -- end ( ) )则返回空路径。
生成的路径是通过将区间
[
begin
(
)
,
--
end
(
)
)
内的所有元素追加到空路径而构建的。
目录 |
参数
(无)
返回值
指向父目录的路径。
异常
可能抛出实现定义的异常。
示例
#include <experimental/filesystem> #include <iostream> namespace fs = std::experimental::filesystem; int main() { for (fs::path p : {"/var/tmp/example.txt", "/", "/var/tmp/."}) std::cout << "The parent path of " << p << " is " << p.parent_path() << '\n'; }
可能的输出:
The parent path of "/var/tmp/example.txt" is "/var/tmp" The parent path of "/" is "" The parent path of "/var/tmp/." is "/var/tmp"
参见
| 此章节内容不完整 |