std::chrono::weekday_indexed::ok
Von cppreference.com
< cpp | chrono | weekday indexed
| constexpr bool ok() const noexcept; |
(seit C++20) | |
Prüft, ob das Wochentagsobjekt und der im Objekt gespeicherte Index beide gültig sind.
[bearbeiten] Rückgabewert
true, wenn weekday().ok() == true und index() im Bereich [1, 5] liegt. Andernfalls false.
[bearbeiten] Beispiel
Führen Sie diesen Code aus
#include <chrono> #include <iostream> int main() { std::cout << std::boolalpha; std::chrono::weekday_indexed wdi{std::chrono::Tuesday[2]}; std::cout << (wdi.ok()) << ' '; wdi = {std::chrono::weekday(42)[2]}; std::cout << (wdi.ok()) << ' '; wdi = {std::chrono::Tuesday[-4]}; std::cout << (wdi.ok()) << '\n'; }
Ausgabe
true false false