std::filesystem::path::root_path
| path root_path() const; |  | (since C++17) | 
|---|
返回路径的根路径。如果路径不包括根路径,则返回path()...
实际上,返回以下内容:root_name() / root_directory()...
参数
%280%29
返回值
路径的根路径。
例外
%280%29
例
二次
#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;
 
int main()
{
    std::cout << "Current root path is: " << fs::current_path().root_path() << '\n';
}二次
可能的产出:
二次
Current root path is: "C:\"二次
另见
| root_name | returns the root-name of the path, if present (public member function) | 
|---|---|
| root_directory | returns the root directory of the path, if present (public member function) | 
 © cppreference.com在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

