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

履歴 編集

function
<memory>

std::indirect::valueless_after_move(C++26)

constexpr bool valueless_after_move() const noexcept;

概要

*thisが無効値状態かどうかを判定する。indirectはムーブされたあとにのみ無効値状態となりうる。

戻り値

*thisが無効値状態であればtrue、そうでなければfalse

例外

投げない。

#include <cassert>
#include <memory>

int main()
{
  std::indirect<int> a{42};
  assert(!a.valueless_after_move());

  std::indirect<int> b = std::move(a);
  assert(a.valueless_after_move());  // ムーブ後は無効値状態
  assert(!b.valueless_after_move());
}

出力

バージョン

言語

  • C++26

処理系

関連項目

参照