Namespaces
Variants

std::chrono::weekday_indexed:: weekday

From cppreference.net
constexpr std:: chrono :: weekday weekday ( ) const noexcept ;
(depuis C++20)

Récupère une copie de l'objet std::chrono::weekday stocké dans * this .

Valeur de retour

Une copie de l'objet std::chrono::weekday stocké dans * this .

Exemple

#include <chrono>
#include <iostream>
int main()
{
    std::cout << std::boolalpha;
    // 2ème mardi d'un mois
    std::chrono::weekday_indexed wdi{std::chrono::Tuesday[2]};
    std::cout << (std::chrono::year_month_day{wdi/10/2019} == 
                  std::chrono::year_month_day{std::chrono::October/8/2019}) << ' ';
    // 2ème mardi => 2ème jeudi
    wdi = {wdi.weekday() + std::chrono::days(2), wdi.index()};
    std::cout << (std::chrono::year_month_day{wdi/10/2019} == 
                  std::chrono::year_month_day{std::chrono::October/10/2019}) << '\n';
}

Sortie :

true true

Voir aussi

accéder à l'index stocké
(fonction membre publique)