• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <chrono>

    std::chrono::year_month::year

    constexpr chrono::year year() const noexcept; // (1) C++20
    

    概要

    年要素を取得する。

    戻り値

    コンストラクタで設定されて保持している年オブジェクトを返す。

    #include <cassert>
    #include <chrono>
    
    namespace chrono = std::chrono;
    using namespace std::chrono_literals;
    
    int main()
    {
      chrono::year_month date = 2020y/3;
      chrono::year y = date.year();
      assert(y == 2020y);
    }
    

    出力

    バージョン

    言語

    • C++20

    処理系