operator==, operator<=>(std::basic_stacktrace)
来自 cppreference.cn
< cpp | 工具库 | basic_stacktrace
template< class Allocator2 > friend bool operator==( const basic_stacktrace& lhs, |
(1) | (C++23 起) |
template< class Allocator2 > friend std::strong_ordering |
(2) | (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== 合成。
目录 |
[编辑] 参数
lhs, rhs | - | 要比较其内容的 basic_stacktrace |
[编辑] 返回值
1) 如果 lhs 和 rhs 的内容相等,则为 true,否则为 false。
2) 如果结果不是 std::strong_order::equal,则为 lhs.size() <=> rhs.size(),否则为 lhs 和 rhs 元素的字典序。
[编辑] 复杂度
1,2) 如果 lhs 和 rhs 大小不同,则为常数时间;否则,与 lhs 的大小成线性关系。
[编辑] 示例
本节不完整 原因:无示例 |