Skip to content

Latest commit

 

History

History
52 lines (39 loc) · 916 Bytes

File metadata and controls

52 lines (39 loc) · 916 Bytes

has_value

  • optional[meta header]
  • std[meta namespace]
  • optional[meta class]
  • function[meta id-type]
  • cpp17[meta cpp]
constexpr bool has_value() const noexcept;

概要

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

効果

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

#include <cassert>
#include <optional>

int main()
{
  std::optional<int> p1 = 3;
  assert(p1.has_value() == true);

  std::optional<int> p2;
  assert(p2.has_value() == false);
}
  • has_value()[color ff0000]

出力

バージョン

言語

  • C++17

処理系

関連項目