constexpr bool ok() const noexcept; | (since C++20) |
Checks if the month
object stored in *this
is valid.
month().ok()
.
#include <iostream> #include <chrono> int main() { std::cout << std::boolalpha; auto mdl {std::chrono::February/std::chrono::last}; std::cout << (mdl.ok()) << ' '; mdl = {std::chrono::month(42)/std::chrono::last}; std::cout << (mdl.ok()) << '\n'; }
Output:
true false
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/chrono/month_day_last/ok