Skip to content

Latest commit

 

History

History
70 lines (52 loc) · 1.32 KB

op_equal.md

File metadata and controls

70 lines (52 loc) · 1.32 KB

operator==

  • functional[meta header]
  • std[meta namespace]
  • function template[meta id-type]
  • cpp11[meta cpp]
namespace std {
  template <class R, class... ArgTypes>
  bool operator==(const function<R(ArgTypes...)>& f, nullptr_t) noexcept; // (1) C++11

  // (1)により、以下のオーバーロードが使用可能になる (C++20)
  template <class R, class... ArgTypes>
  bool operator==(nullptr_t, const function<R(ArgTypes...)>& f) noexcept; // (2) C++20
}
  • nullptr_t[link /reference/cstddef/nullptr_t.md]

概要

等値比較する。

戻り値

!f

#include <iostream>
#include <functional>

int ident(int x) { return x; }

int main()
{
  std::function<int(int)> f;

  if (f == nullptr) {
    std::cout << "empty" << std::endl;
  }

  f = ident;
  if (f == nullptr) {}
  else {
    std::cout << "not empty" << std::endl;
  }
}

出力

empty
not empty

バージョン

言語

  • C++11

処理系

参照