最終更新日時(UTC):
が更新

履歴 編集

function template
<map>

std::operator!=

namespace std {
  // operator==により、以下の演算子が使用可能になる (C++20)
  template <class Key, class T, class Compare, class Allocator>
  bool
    operator!=(const multimap<Key,T,Compare,Allocator>& x,
               const multimap<Key,T,Compare,Allocator>& y); // (1) C++03
}

概要

xy が等しくないかどうかの判定を行う。

パラメータ

  • x, y
    比較するコンテナ。

戻り値

二つのコンテナが等しくない場合に true, そうでない場合に false

計算量

size() に対して線形時間。ただし、xyのサイズが異なる場合は定数時間。

#include <iostream>
#include <map>

int main()
{
  std::multimap<int, char> m1, m2;
  m1.insert(std::make_pair(1, 'a'));
  m1.insert(std::make_pair(2, 'b'));
  m1.insert(std::make_pair(3, 'c'));
  m2 = m1;

  std::cout << (m1 != m2) << std::endl;

  m2.insert(std::make_pair(4, 'd'));

  std::cout << (m1 != m2) << std::endl;

  return 0;
}

出力

0
1

処理系

参照