c++ - 为什么 path::root_name() 有不同的行为和
问题描述
在过去的几天里,我一直在尝试一些函数filesystem
和experimental/filesystem
库的行为。
注意:我在https://godbolt.org/上运行了代码
下面是带有输出的代码片段
1. 实验/文件系统
#include <iostream>
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
int main()
{
auto p = fs::path("//net");
std::cout<<"p = " << p
<<"\np.root_name= "<< p.root_name()
<<"\nand p.root_Dir= "<< p.root_directory()
<<"\np.is_absolute= "<<p.is_absolute()<<std::endl;
}
输出:
p = "//net"
p.root_name= "//net"
and p.root_Dir= ""
p.is_absolute= 0
#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;
int main()
{
auto p = fs::path("//net");
std::cout<<"p = " << p
<<"\np.root_name= "<< p.root_name()
<<"\nand p.root_Dir= "<< p.root_directory()
<<"\np.is_absolute= "<<p.is_absolute()<<std::endl;
}
输出:
p = "//net"
p.root_name= ""
and p.root_Dir= "/"
p.is_absolute= 1
有没有办法研究这些功能的实现?
解决方案
推荐阅读
- python - 即使在 python 中满足条件,Lambda 也无法工作
- android - 模拟器以异常代码开始:每次启动时 0xc0000005
- php - Laravel Spatie Query Builder - 为过滤器创建 OR 条件
- python - 带有 Flask 的 python 和 html 中的计时器
- c# - 如何将图像背景作为水印添加到 pdf 文件中?
- sql - Oracle中的替换功能问题
- javascript - 当用户单击按钮时,使用多个 api 调用(本地后端)动态更新 Mapbox 中的图层数据 - React js
- github - Flux V2 没有将新的镜像版本推送到 git repo
- git - 如何在 Google Colab 中只克隆一次 git 存储库
- mysql - mySQL在触发器中比较两个不同的列值