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

