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 起) |
按字典序比较两个路径。
这些函数对普通的 非限定查找 或 限定查找 不可见,仅当 std::filesystem::path 作为参数的关联类时,才能通过 实参依赖查找 被发现。这可以防止在存在 using namespace std :: filesystem ; using 指令 时发生不期望的类型转换。
|
|
(since C++20) |
目录 |
参数
| lhs, rhs | - | 要比较的路径 |
返回值
注释
路径相等性和等价性具有不同的语义。
在相等性判断中,如通过
operator==
所确定的,仅比较词法表示。因此,
path
(
"a"
)
==
path
(
"b"
)
永远不会为
true
。
在等价情况下,通过 std::filesystem::equivalent() 判定时,会检查两个路径是否 解析 为同一文件系统对象。因此当路径解析为同一文件时, equivalent ( "a" , "b" ) 将返回 true 。
示例
|
本节内容不完整
原因:缺少示例 |
缺陷报告
以下行为变更缺陷报告被追溯应用于先前发布的C++标准。
| 缺陷报告 | 适用范围 | 发布时行为 | 正确行为 |
|---|---|---|---|
| LWG 3065 | C++17 |
在存在
using-directive
的情况下允许所有可转换为
path
类型的比较操作
|
改为隐藏友元 |
参见
|
按字典序比较两个路径的词法表示
(公开成员函数) |
|
|
(C++17)
|
检查两个路径是否指向同一文件系统对象
(函数) |