命名空间
变体
操作

std::filesystem::path::root_path

来自 cppreference.cn
< cpp‎ | filesystem‎ | path
 
 
 
 
path root_path() const;
(since C++17)

返回路径的根路径。如果路径不包含根路径,则返回 path()

有效地返回 root_name() / root_directory()

目录

[edit] 参数

(无)

[edit] 返回值

路径的根路径。

[edit] 异常

可能抛出实现定义的异常。

[edit] 示例

#include <filesystem>
#include <iostream>
namespace fs = std::filesystem;
 
int main()
{
    std::cout << "Current root path is: " << fs::current_path().root_path() << '\n';
}

可能的输出

Current root path is: "C:\"

[edit] 参见

返回路径的根名(如果存在)
(公共成员函数) [编辑]
返回路径的根目录(如果存在)
(公共成员函数) [编辑]