std::chrono::year_month_weekday::ok
Von cppreference.com
< cpp | chrono | year month weekday
| constexpr bool ok() const noexcept; |
(seit C++20) | |
Prüft, ob dieses year_month_weekday Objekt ein gültiges Datum darstellt.
[bearbeiten] Rückgabewert
true, wenn dieses year_month_weekday Objekt ein gültiges Datum darstellt, d.h. year().ok() && month().ok() && weekday_indexed().ok() true ist und es im angegebenen Jahr und Monat mindestens index() weekday()s gibt. Andernfalls false.
[bearbeiten] Beispiel
Führen Sie diesen Code aus
#include <cassert> #include <chrono> int main() { auto ymwdi{std::chrono::Wednesday[1]/1/2021}; assert(ymwdi.ok()); ymwdi = std::chrono::year(2021)/std::chrono::month(1)/std::chrono::Wednesday[42]; assert(!ymwdi.ok()); }