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

履歴 編集

function template
<expected>

std::unexpected::operator!=(C++23)

// operator==により、下記オーバーロードが使用可能になる
template<class E2>
friend constexpr bool operator!=(const unexpected& x, const unexpected<E2>& y);

概要

unexpectedオブジェクト同士の非等値比較を行う。

適格要件

x.error() == y.error()適格であり、その結果をboolへ変換可能であること。

戻り値

!(x == y)

#include <cassert>
#include <expected>

int main()
{
  std::unexpected<long>  x{1};
  std::unexpected<short> y{2};
  assert(x != y);
}

出力

バージョン

言語

  • C++23

処理系

参照