Namespaces
Variants

std::chrono::year_month_weekday_last:: ok

From cppreference.net
constexpr bool ok ( ) const noexcept ;
(seit C++20)

Prüft, ob dieses Objekt ein gültiges Datum repräsentiert. Da ein year_month_weekday_last den letzten Wochentag eines bestimmten Monats repräsentiert, ist es gültig, solange Jahr, Monat und Wochentag gültig sind.

Rückgabewert

year ( ) . ok ( ) && month ( ) . ok ( ) && weekday ( ) . ok ( )

Beispiel

#include <cassert>
#include <chrono>
using namespace std::chrono;
int main()
{
    auto ymwdl{Tuesday[last]/11/2020};
    assert(ymwdl.ok());
    ymwdl = Tuesday[last]/-2/2021;
    assert(!ymwdl.ok());
    ymwdl += months(0); // Monat normalisieren
    assert(ymwdl.ok());
}