operator==,<=> (std::inplace_vector)
|
constexpr
friend
bool
operator
==
(
const
std::
inplace_vector
<
T, N
>
&
lhs,
const std:: inplace_vector < T, N > & rhs ) ; |
(1) | (自 C++26 起) |
|
constexpr
friend
synth
-
three
-
way
-
result
<
T
>
operator
<=>
(
const
std::
inplace_vector
<
T, N
>
&
lhs,
|
(2) | (自 C++26 起) |
比较两个 std::inplace_vector 的内容。
std:: lexicographical_compare_three_way ( lhs. begin ( ) , lhs. end ( ) ,
rhs. begin ( ) , rhs. end ( ) , synth - three - way ) ; 实现。
-
T满足three_way_comparable概念。 -
为(可能 const 限定的)
T类型值定义了<运算符,且<构成全序关系。
<
、
<=
、
>
、
>=
和
!=
运算符分别由
operator
<=>
和
operator
==
合成。
目录 |
参数
| lhs, rhs | - | 待比较内容的 std::inplace_vector 对象 |
-
T
必须满足
EqualityComparable
要求才能使用重载 (1)
|
||
返回值
复杂度
注释
关系运算符基于 synth-three-way 定义,该函数在可能时使用 operator <=> ,否则使用 operator < 。
值得注意的是,如果元素本身未提供 operator <=> ,但可隐式转换为支持三路比较的类型,则将使用该转换而非 operator < 。
示例
#include <inplace_vector> int main() { constexpr std::inplace_vector<int, 4> a{1, 2, 3}, b{1, 2, 3}, c{7, 8, 9, 10}; static_assert ("" "比较相等容器:" && (a != b) == false && (a == b) == true && (a < b) == false && (a <= b) == true && (a > b) == false && (a >= b) == true && (a <=> b) >= 0 && (a <=> b) <= 0 && (a <=> b) == 0 && "比较不相等容器:" && (a != c) == true && (a == c) == false && (a < c) == true && (a <= c) == true && (a > c) == false && (a >= c) == false && (a <=> c) < 0 && (a <=> c) != 0 && (a <=> c) <= 0 && ""); }