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) | (depuis C++20) |
|
constexpr
weekday_indexed
(
const
std::
chrono
::
weekday
&
wd,
unsigned
index
)
noexcept
;
|
(2) | (depuis C++20) |
Construit un
weekday_indexed
.
1)
Le constructeur par défaut laisse à la fois le
std::chrono::weekday
et la valeur d'index non initialisés.
2)
Construit un
weekday_indexed
stockant le jour de la semaine
wd
et l'index
index
. Les valeurs conservées sont non spécifiées si
!
wd.
ok
(
)
||
index
>
7
.
Notes
Une manière plus pratique de construire un weekday_indexed est d'utiliser l' weekday avec son operator [ ] , c'est-à-dire wd [ index ] .
Exemple
Exécuter ce code
#include <chrono> #include <iostream> using namespace std::chrono; int main() { constexpr auto third_friday = weekday_indexed(Friday, 3); // utilise le constructeur (2) static_assert(third_friday == Friday[3]); weekday_indexed wdi = Tuesday[2]; // représente le 2ème mardi std::cout << year_month_day{ wdi / October / 2019y } << '\n'; }
Sortie possible :
2019-10-08
Voir aussi
syntaxe pratique pour construire un
weekday_indexed
ou un
weekday_last
à partir de ce
weekday
(fonction membre publique de
std::chrono::weekday
)
|