std::chrono::weekday_indexed:: weekday_indexed
From cppreference.net
<
cpp
|
chrono
|
weekday indexed
C++
Date and time library
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::chrono::weekday_indexed
| Member functions | ||||
|
weekday_indexed::weekday_indexed
|
||||
| Nonmember functions | ||||
| Helper classes | ||||
|
weekday_indexed
(
)
=
default
;
|
(1) | (seit C++20) |
|
constexpr
weekday_indexed
(
const
std::
chrono
::
weekday
&
wd,
unsigned
index
)
noexcept
;
|
(2) | (seit C++20) |
Konstruiert einen
weekday_indexed
.
1)
Standardkonstruktor lässt sowohl den
std::chrono::weekday
als auch den Indexwert uninitialisiert.
2)
Konstruiert einen
weekday_indexed
, der den Wochentag
wd
und den Index
index
speichert. Die gespeicherten Werte sind nicht spezifiziert, falls
!
wd.
ok
(
)
||
index
>
7
.
Hinweise
Eine bequemere Möglichkeit, einen weekday_indexed zu konstruieren, bietet der weekday 's operator [ ] , d.h., wd [ index ] .
Beispiel
Diesen Code ausführen
#include <chrono> #include <iostream> using namespace std::chrono; int main() { constexpr auto third_friday = weekday_indexed(Friday, 3); // verwendet Konstruktor (2) static_assert(third_friday == Friday[3]); weekday_indexed wdi = Tuesday[2]; // repräsentiert den 2. Dienstag std::cout << year_month_day{ wdi / October / 2019y } << '\n'; }
Mögliche Ausgabe:
2019-10-08
Siehe auch
Praktische Syntax zur Konstruktion eines
weekday_indexed
oder
weekday_last
aus diesem
weekday
(öffentliche Elementfunktion von
std::chrono::weekday
)
|