Namespaces
Variants

std::chrono::month_weekday_last:: month, std::chrono::month_weekday_last:: weekday_last

From cppreference.net
constexpr std:: chrono :: month month ( ) const noexcept ;
(1) (seit C++20)
constexpr std:: chrono :: weekday_last weekday_last ( ) const noexcept ;
(2) (seit C++20)

Ruft eine Kopie der in * this gespeicherten month - und weekday_last -Objekte ab.

Rückgabewert

1) Eine Kopie des in std::chrono::month gespeicherten Objekts * this .
2) Eine Kopie des in std::chrono::weekday_last gespeicherten Objekts * this .

Beispiel

#include <chrono>
#include <iostream>
using namespace std::chrono;
int main()
{
    std::cout << std::boolalpha;
    auto mwdl{March/Friday[last]}; // Letzter Freitag in einem März
    auto ywdl{year(2024)/mwdl};
    std::cout << (year_month_day{ywdl} == 
                  year_month_day{March/29/2024}) << ' ';
    // Letzter Freitag des nächsten Monats, in 2024
    mwdl = {(mwdl.month() + months(1))/mwdl.weekday_last()};
    ywdl = {year(2024)/mwdl}; 
    std::cout << (year_month_day{ywdl} == 
                  year_month_day{April/26/2024}) << '\n';
}

Ausgabe:

true true