std::chrono::weekday:: operator[]
From de.cppreference.net
|
constexpr
std::
chrono
::
weekday_indexed
operator [ ] ( unsigned index ) const noexcept ; |
(1) | (seit C++20) |
|
constexpr
std::
chrono
::
weekday_last
operator [ ] ( std:: chrono :: last_spec ) const noexcept ; |
(2) | (seit C++20) |
1)
Konstruiert einen
weekday_indexed
aus
*
this
und
index
. Das Ergebnis repräsentiert den
index
-ten Wochentag in einem noch nicht spezifizierten Monat. Wenn
index
nicht im Bereich
[
0
,
7
]
liegt oder wenn
!
ok
(
)
, sind die Werte (ein zugrundeliegender Wochentag und ein Index) im Ergebnis nicht spezifiziert.
2)
Konstruiert einen
weekday_last
aus
*
this
. Das Ergebnis repräsentiert den letzten Wochentag in einem noch nicht spezifizierten Monat.
Rückgabewert
1)
std::
chrono
::
weekday_indexed
(
*
this, Index
)
2)
std::
chrono
::
weekday_last
(
*
this
)
Beispiel
Diesen Code ausführen
#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'; }
Mögliche Ausgabe:
2019-10-08 2019-10-29