- set[meta header]
- std[meta namespace]
- function template[meta id-type]
namespace std {
// operator==により、以下の演算子が使用可能になる (C++20)
template <class Key, class Compare, class Allocator>
bool
operator!=(const set<Key,Compare,Allocator>& x,
const set<Key,Compare,Allocator>& y); // (1) C++03
}
x
と y
が等しくないかどうかの判定を行う。
x
,y
比較するコンテナ。
二つのコンテナが等しくない場合に true
, そうでない場合に false
。
size()
に対して線形時間。ただし、x
とy
のサイズが異なる場合は定数時間。
#include <iostream>
#include <set>
int main()
{
std::set<int> s1, s2;
s1.insert(10);
s1.insert(20);
s1.insert(30);
s2 = s1;
std::cout << (s1 != s2) << std::endl;
s2.insert(40);
std::cout << (s1 != s2) << std::endl;
}
- !=[color ff0000]
- insert[link insert.md]
0
1
- P1614R2 The Mothership has Landed
- C++20での三方比較演算子の追加と、関連する演算子の自動導出