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

std::filesystem::relative

Defined in header <filesystem>

path relative( const std::filesystem::path& p, std::error_code& ec);

(1)

(since C++17)

path relative( const std::filesystem::path& p, const std::filesystem::path& base = std::filesystem::current_path()); path relative( const std::filesystem::path& p, const std::filesystem::path& base, std::error_code& ec);

(2)

(since C++17)

path proximate( const std::filesystem::path& p, std::error_code& ec);

(3)

(since C++17)

path proximate( const std::filesystem::path& p, const std::filesystem::path& base = std::filesystem::current_path()); path proximate( const std::filesystem::path& p, const std::filesystem::path& base, std::error_code& ec);

(4)

(since C++17)

1%29relative(p, current_path(), ec)

2%29p相对于base.解决符号联系并使两者正常化pbase在其他处理之前。有效回报weakly_canonical(p).lexically_relative(weakly_canonical(base))weakly_canonical(p, ec).lexically_relative(weakly_canonical(base, ec)),除错误代码窗体返回外path()在第一次错误发生时,如果有的话。

3%29proximate(p, current_path(), ec)

4%29有效返回weakly_canonical(p).lexically_proximate(weakly_canonical(base))weakly_canonical(p, ec).lexically_proximate(weakly_canonical(base, ec)),除错误代码窗体返回外path()在第一次错误发生时,如果有的话。

参数

p

-

an existing path

base

-

base path, against which p will be made relative/proximate

ec

-

error code to store error status to

返回值

1%,29便士,相对于基础。

2%29便士

例外

不占用std::error_code&参数抛文件系统[医]误差关于基础OS API错误,使用p作为第一个论点,base作为第二个参数,操作系统错误代码作为错误代码参数。std::bad_alloc如果内存分配失败,则可能引发。过载std::error_code&参数,如果OSAPI调用失败,则将其设置为OSAPI错误代码,并执行ec.clear()如果没有错误发生。这个过载

noexcept规格:

noexcept

另见

path (C++17)

represents a path (class)

absolutesystem_complete (C++17)(C++17)

composes an absolute pathconverts a path to an absolute path replicating OS-specific behavior (function)

canonicalweakly_canonical (C++17)

composes a canonical path (function)

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

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

扫码关注腾讯云开发者

领取腾讯云代金券