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

履歴 編集

function template
<regex>

std::match_results::operator!=(C++11)

namespace std {
  // operator==により、以下の演算子が使用可能になる (C++20)
  template <class BidirectinalIterator, class Allocator>
  bool operator!=(const match_results<BidirectionalIterator, Allocator>& m1,
                  const match_results<BidirectionalIterator, Allocator>& m2); // (1) C++11
}

概要

match_results オブジェクトを非等値比較する。

戻り値

  • !(m1 == m2)

#include <iostream>
#include <regex>

int main()
{
  const char s[] = "abc 012 def";

  const std::regex re1(R"((\w+)\s+(\d+)\s+(\w+))");
  std::cmatch m1;
  std::regex_search(s, m1, re1);
  for (auto&& sub : m1) {
    std::cout << sub << std::endl;
  }
  std::cout << std::endl;

  const std::regex re2(R"((\w*) (\w*) (\w*))");
  std::cmatch m2;
  std::regex_search(s, m2, re2);
  for (auto&& sub : m2) {
    std::cout << sub << std::endl;
  }
  std::cout << std::endl;

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

出力

abc 012 def
abc
012
def

abc 012 def
abc
012
def

false

バージョン

言語

  • C++11

処理系

参照