std::filesystem::path::relative_path
| path relative_path() const; |  | (since C++17) | 
|---|
相对于根路径.如果*this是空路径,则返回空路径。
参数
%280%29
返回值
相对于根路径...
例外
%280%29
实例
二次
#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;
 
int main()
{
    fs::path p = fs::current_path();
 
    std::cout << "The current path " << p << " decomposes into:\n"
              << "root-path " << p.root_path() << '\n'
              << "relative path " << p.relative_path() << '\n';
}二次
可能的产出:
二次
The current path "C:\Users\abcdef\Local Settings\temp" decomposes into:
root-path "C:\"
relative path "Users\abcdef\Local Settings\temp"二次
另见
| 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) | 
| root_path | returns the root path of the path, if present (public member function) | 
 © cppreference.com在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

