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

履歴 編集

function
<any>

std::any::has_value(C++17)

bool has_value() const noexcept;

概要

有効な値を保持しているかを判定する。

効果

有効値を保持している場合にtrueを返し、そうでなければfalseを返す。

#include <cassert>
#include <any>

int main()
{
  std::any x = 3;
  assert(x.has_value() == true);

  std::any y;
  assert(y.has_value() == false);
}

出力

バージョン

言語

  • C++17

処理系