• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <chrono>

    std::chrono::month_day::ok

    constexpr bool ok() const noexcept; // (1) C++20
    

    概要

    month_dayオブジェクトの値が有効な月日の範囲内かを判定する。

    戻り値

    以下の全ての条件を満たす場合にこの関数はtrueを返し、そうでなければfalseを返す:

    #include <cassert>
    #include <chrono>
    
    namespace chrono = std::chrono;
    
    int main()
    {
      assert((chrono::March/1).ok()  == true);
      assert((chrono::March/31).ok() == true);
      assert((chrono::March/0).ok()  == false);
      assert((chrono::April/31).ok() == false);
    
      assert((chrono::February/28).ok() == true);
      assert((chrono::February/29).ok() == true);
    }
    

    出力

    バージョン

    言語

    • C++20

    処理系