• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <expected>

    std::expected.void::operator*

    // expected<cv void, E>部分特殊化
    constexpr void operator*() const noexcept;
    

    概要

    正常値(void)を取得する。

    事前条件

    has_value() == true

    戻り値

    なし

    例外

    投げない

    #include <expected>
    
    int main()
    {
      std::expected<void, int> x;
      *x;
    
      std::expected<void, int> y = std::unexpected{42};
    //*y;
      // エラー値を保持する y に対する operator* 呼び出しは未定義動作
    }
    

    出力

    バージョン

    言語

    • C++23

    処理系

    関連項目

    参照