operator==, operator<=>(std::basic_stacktrace)

出自cppreference.com


 
 
 
 
template< class Allocator2 >

friend bool operator==( const basic_stacktrace& lhs,

                        const basic_stacktrace<Allocator2>& rhs ) noexcept;
(1) (C++23 起)
template< class Allocator2 >

friend std::strong_ordering
    operator<=>( const basic_stacktrace& lhs,

                 const basic_stacktrace<Allocator2>& rhs ) noexcept;
(2) (C++23 起)
1) 檢查 lhsrhs 的內容是否相等,即它們擁有相同元素個數且 lhs 中的每個元素比較都等於 rhs 中相同位置的元素。
等價於 return std::equal(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
2) 返回 lhsrhs 中的棧蹤跡條目個數的相對順序,若它們不相等。否則(若 lhsrhs 的元素個數相等),則返回 lhsrhs 的元素的字典順序。
等價於
if (auto cmp = lhs.size() <=> rhs.size(); cmp != 0)

    return cmp;
else
    return std::lexicographical_compare_three_way(lhs.begin(), lhs.end(),

                                                  rhs.begin(), rhs.end());

這些函數模板對常規的無限定有限定查找不可見,而只能在 std::basic_stacktrace<Allocator> 為實參的關聯類時由實參依賴查找找到。

<<=>>=!= 運算符分別從 operator<=>operator== 合成

目錄

[編輯] 參數

lhs, rhs - 要比較內容的 basic_stacktrace

[編輯] 返回值

1)lhsrhs 的內容相等則為 true,否則為 false
2) lhs.size() <=> rhs.size(),若其結果不是 std::strong_order::equal,否則為 lhsrhs 的元素的字典順序。

[編輯] 複雜度

1,2)lhsrhs 大小不同則為常數,否則與 lhs 的大小成線性。

[編輯] 示例