std::chrono::weekday:: operator[]
From cppreference.net
C++
Date and time library
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::chrono::weekday
| Member functions | ||||
|
weekday::operator[]
|
||||
| Nonmember functions | ||||
| Helper classes | ||||
|
(C++26)
|
|
constexpr
std::
chrono
::
weekday_indexed
operator [ ] ( unsigned index ) const noexcept ; |
(1) | (C++20以降) |
|
constexpr
std::
chrono
::
weekday_last
operator [ ] ( std:: chrono :: last_spec ) const noexcept ; |
(2) | (C++20以降) |
1)
weekday_indexed
を
*
this
と
index
から構築する。結果は未指定の月における
index
番目の曜日を表す。
index
が範囲
[
0
,
7
]
内にない場合、または
!
ok
(
)
の場合、結果に保持される値(基底のweekdayとindex)は未指定となる。
2)
weekday_last
を
*
this
から構築します。結果は、未指定の月における最後の平日を表します。
戻り値
1)
std::
chrono
::
weekday_indexed
(
*
this, index
)
2)
std::
chrono
::
weekday_last
(
*
this
)
例
このコードを実行
#include <chrono> #include <iostream> using namespace std::chrono; int main() { constexpr auto second_tuesday_in_October_2019 = year_month_day{Tuesday[2] / October / 2019y}; constexpr auto 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'; }
出力例:
2019-10-08 2019-10-29