Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::chrono::year::operator int

      From cppreference.com
      <cpp‎ |chrono‎ |year
       
       
      Date and time library
       
       
      constexprexplicit operatorint()constnoexcept;
      (since C++20)

      Returns the year value stored in*this.

      [edit]Return value

      The year value stored in*this.

      [edit]Example

      Run this code
      #include <chrono>#include <iostream>usingnamespace std::chrono; int main(){constexprstd::chrono::year y{2020};std::cout<<"The year is: "<<static_cast<int>(y)<<'\n'; const year_month_day ymd{floor<days>(system_clock::now())};conststd::chrono::year this_year{ymd.year()};std::cout<<"This year is: "<<int(this_year)<<'\n';}

      Possible output:

      The year is: 2020This year is: 2023
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/chrono/year/operator_int&oldid=157537"

      [8]ページ先頭

      ©2009-2025 Movatter.jp