std::chrono::year_month_weekday:: year, std::chrono::year_month_weekday:: month, std::chrono::year_month_weekday:: weekday, std::chrono::year_month_weekday:: index, std::chrono::year_month_weekday:: weekday_indexed
From cppreference.net
<
cpp
|
chrono
|
year month weekday
C++
Date and time library
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::chrono::year_month_weekday
| Member functions | ||||
|
year_month_weekday::year
year_month_weekday::month
year_month_weekday::weekday
year_month_weekday::index
year_month_weekday::weekday_indexed
|
||||
| Nonmember functions | ||||
| Helper classes | ||||
|
constexpr
std::
chrono
::
year
year
(
)
const
noexcept
;
|
(1) | (depuis C++20) |
|
constexpr
std::
chrono
::
month
month
(
)
const
noexcept
;
|
(2) | (depuis C++20) |
|
constexpr
std::
chrono
::
weekday
weekday
(
)
const
noexcept
;
|
(3) | (depuis C++20) |
|
constexpr
unsigned
index
(
)
const
noexcept
;
|
(4) | (depuis C++20) |
|
constexpr
std::
chrono
::
weekday_indexed
weekday_indexed
(
)
const
noexcept
;
|
(5) | (depuis C++20) |
Récupère les valeurs de champ stockées dans cet
year_month_weekday
objet.
Valeur de retour
1)
Retourne la valeur stockée
std::chrono::year
.
2)
Retourne la valeur stockée
std::chrono::month
.
3)
Retourne la valeur stockée
std::chrono::weekday
.
4)
Retourne l'indice du jour de la semaine stocké.
5)
weekday
(
)
[
index
(
)
]
Exemple
Exécuter ce code
#include <cassert> #include <chrono> int main() { constexpr auto ym{std::chrono::year(2021)/std::chrono::January}; constexpr auto wdi{std::chrono::Wednesday[1]}; auto ymwdi{ym/wdi}; const auto index{ymwdi.index() + 1}; auto weekday{ymwdi.weekday() + std::chrono::days(1)}; ymwdi = {ymwdi.year()/ymwdi.month()/weekday[index]}; // Deuxième jeudi de janvier 2021 assert(std::chrono::year_month_day{ymwdi} == std::chrono::January/14/2021); }
` - Termes spécifiques C++ (comme `constexpr`, `auto`, `assert`, etc.) - Noms de classes et fonctions de la bibliothèque chrono - Formatage et structure HTML d'origine