首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::filesystem::path::root_path

path root_path() const;

?

(since C++17)

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

实际上,返回以下内容:root_name() / root_directory()...

参数

%280%29

返回值

路径的根路径。

例外

%280%29

二次

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

二次

可能的产出:

二次

代码语言:javascript
复制
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)

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com