constexpr bool ok() const noexcept; | (since C++20) |
Checks if the weekday value stored in *this
is in the valid range, i.e., [0, 6].
true
if the weekday value stored in *this
is in the range [0, 6]. Otherwise false
.
#include <iostream> #include <chrono> int main() { for (const unsigned u : {0, 1, 6, 7, 8, 9}) { const std::chrono::weekday wd{u}; std::cout << "u = " << u << ", wd = " << wd.c_encoding() // Monday is 1 << (wd.ok() ? " is a valid weekday.\n" : " is an invalid weekday!\n"); } }
Output:
retrieves the stored weekday value retrieves ISO 8601 weekday value (public member function) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/chrono/weekday/ok