multiset_operator_cmp
multiset_operator_cmp (std::multiset::operator==,<,... — 비교 연산자)
두 std::multiset을 사전식(lexicographically)으로 비교하는 비멤버 연산자 함수들이에요.
출처: cppreference
본문
시그니처는 다음과 같아요.
template< class Key, class Compare, class Alloc >
bool operator==( const std::multiset<Key, Compare, Alloc>& lhs,
const std::multiset<Key, Compare, Alloc>& rhs ); // (1)
template< class Key, class Compare, class Alloc >
bool operator!=( ... ); // (until C++20)
template< class Key, class Compare, class Alloc >
bool operator<( ... ); // (until C++20)
template< class Key, class Compare, class Alloc >
bool operator<=>( const std::multiset<Key, Compare, Alloc>& lhs,
const std::multiset<Key, Compare, Alloc>& rhs ); // (since C++20)
두 컨테이너의 내용을 사전식으로 비교해요.
operator==: 두 컨테이너의 원소 개수가 같고 각 위치의 원소가 같으면true.- C++20부터는
operator!=,<,<=,>,>=가operator<=>(삼중 비교)와operator==에서 파생돼요.
반환값
- (1)
lhs의 원소들이rhs와 같으면true. - 그 외 각 연산자에 해당하는 비교 결과.
복잡도
두 컨테이너 크기가 다르면 operator==는 상수, 그 외에는 컨테이너 크기에 선형.
예제
#include <iostream>
#include <set>
int main()
{
std::multiset<int> a{1, 2, 2};
std::multiset<int> b{1, 2, 2};
std::cout << std::boolalpha << (a == b) << '\n'; // true
}