operator==,!=,<,<=,>,>=,<=>(std::filesystem::path)
类 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
函数 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
文件类型 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
常量 | |||||||||||||||||||||
成员函数 | |||||||||||||||||||||
|
|||||||||||||||||||||
路径分解 | |||||||||||||||||||||
非成员函数 | |||||||||||||||||||||
|
|||||||||||||||||||||
辅助类 | |||||||||||||||||||||
friend
bool
operator==(
const
path&
lhs, const
path&
rhs )
noexcept;
|
(1) | (C++17 起) |
friend
bool
operator!=(
const
path&
lhs, const
path&
rhs )
noexcept;
|
(2) | (C++17
起) (C++20 前) |
friend
bool
operator<(
const
path&
lhs, const
path&
rhs )
noexcept;
|
(3) | (C++17
起) (C++20 前) |
friend
bool
operator<=(
const
path&
lhs, const
path&
rhs )
noexcept;
|
(4) | (C++17
起) (C++20 前) |
friend
bool
operator>(
const
path&
lhs, const
path&
rhs )
noexcept;
|
(5) | (C++17
起) (C++20 前) |
friend
bool
operator>=(
const
path&
lhs, const
path&
rhs )
noexcept;
|
(6) | (C++17
起) (C++20 前) |
friend
std::strong_ordering
operator<=>( const path& lhs, const path& rhs ) noexcept; |
(7) | (C++20 起) |
以字典序比较二个path
。
lhs
与
rhs
是否相等。等价于 !(lhs < rhs) && !(rhs < lhs) 。lhs
与
rhs
是否不相等,等价于 !(lhs == rhs) 。lhs
是否小于
rhs
。等价于 lhs.compare(rhs) < 0 。lhs
是否小于或等于
rhs
。等价于 !(rhs < lhs) 。lhs
是否大于
rhs
。等价于 rhs < lhs 。
lhs
是否大于或等于
rhs
。等价于 !(lhs < rhs) 。lhs
与
rhs
的三路比较结果。等价于 lhs.compare(rhs) <=> 0 。这些函数对通常无限定或有限定查找不可见,而只能在
std::filesystem::path
为参数的关联类时由实参依赖查找找到。这阻止 using namespace std::filesystem; using
指令存在的情况下的不想要的转换。
|
(C++20 起) |
参数
lhs, rhs | - | 要比较的路径 |
返回值
lhs
小于
rhs
则为 std::strong_ordering::less ,否则若
rhs
小于 lhs
则为 std::strong_ordering::greater ,否则为
std::string_ordering::equal 。注解
路径相等与等价有不同语义。
相等情况下,以 operator==
确定,只比较字典表示。从而 path("a")
== path("b") 决不可能为 true 。
等价情况下,以 std::filesystem::equivalent() 确定,检查二个路径是否解析到同一文件系统对象。从而若路径解析到同一文件,则 equivalent("a", "b") 将返回 true 。
示例
本节未完成 原因:暂无示例 |
缺陷报告
下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。
缺陷报告 | 应用于 | 出版时的行为 | 正确行为 |
---|---|---|---|
LWG 3065 | C++17 | 允许 using 指令存在的情况下比较任何能转换成 path 的类型
|
使之为隐藏的友元 |
参阅
以字典序比较二个路径的字典表示 (公开成员函数) |
|
(C++17)
|
检查两个路径是否指代同一文件系统对象 (函数) |