Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::chrono::weekday::operator[]

      From cppreference.com
      <cpp‎ |chrono‎ |weekday
       
       
      Date and time library
       
       
      constexprstd::chrono::weekday_indexed
          operator[](unsigned index)constnoexcept;
      (1)(since C++20)
      constexprstd::chrono::weekday_last
          operator[](std::chrono::last_spec)constnoexcept;
      (2)(since C++20)
      1) Constructs aweekday_indexed from*this andindex. The result represents theindex-th weekday in some yet-to-be-specified month. Ifindex is not in the range[07] or if!ok() the values (an underlying weekday and an index) held in the result are unspecified.
      2) Constructs aweekday_last from*this. The result represents the last weekday in some yet-to-be-specified month.

      [edit]Return value

      1)std::chrono::weekday_indexed(*this, index)
      2)std::chrono::weekday_last(*this)

      [edit]Example

      Run this code
      #include <chrono>#include <iostream>usingnamespace std::chrono; int main(){constexprauto second_tuesday_in_October_2019=        year_month_day{Tuesday[2]/ October/ 2019y}; constexprauto last_tuesday_in_October_2019=        year_month_day{Tuesday[last]/ October/ 2019y}; std::cout<< second_tuesday_in_October_2019<<'\n'<< last_tuesday_in_October_2019<<'\n';}

      Possible output:

      2019-10-082019-10-29
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/chrono/weekday/operator_at&oldid=172164"

      [8]ページ先頭

      ©2009-2026 Movatter.jp