operator==, operator<=>(std::basic_stacktrace)
来自 cppreference.cn
< cpp | utility | basic stacktrace
template< class Allocator2 > friend bool operator==( const basic_stacktrace& lhs, |
(1) | (since C++23) |
template< class Allocator2 > friend std::strong_ordering |
(2) | (since C++23) |
1) 检查 lhs 和 rhs 的内容是否相等,即它们是否具有相同数量的元素,并且 lhs 中的每个元素与 rhs 中相同位置的元素比较相等。
等价于 return std::equal(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());。
2) 如果 lhs 和 rhs 中的栈回溯条目数量不相等,则返回它们数量的相对顺序。否则(如果 lhs 和 rhs 的元素数量相等),返回 lhs 和 rhs 元素的字典序。
等价于
if (auto cmp = lhs.size() <=> rhs.size(); cmp != 0)
if (auto cmp = lhs.size() <=> rhs.size(); cmp != 0)
return cmp;
else
return std::lexicographical_compare_three_way(lhs.begin(), lhs.end(),
这些函数模板对于普通的非限定查找或限定查找是不可见的,并且只有当 std::basic_stacktrace<Allocator> 是参数的关联类时,才能通过实参依赖查找找到它们。
<
、 <=
、 >
、 >=
和 !=
运算符分别从 operator<=> 和 operator== 合成而来。
内容 |
[edit] 参数
lhs, rhs | - | 要比较其内容的 basic_stacktrace |
[edit] 返回值
1) 如果 lhs 和 rhs 的内容相等,则为 true,否则为 false。
2) 如果结果不是 std::strong_order::equal,则为 lhs.size() <=> rhs.size(),否则为 lhs 和 rhs 元素的字典序。
[edit] 复杂度
1,2) 如果 lhs 和 rhs 的大小不同,则为常数时间,否则与 lhs 的大小呈线性关系。
[edit] 示例
本节内容不完整 原因:没有示例 |