std::chrono::month_weekday::ok
来自cppreference.com
< cpp | chrono | month weekday
constexpr bool ok() const noexcept; |
(C++20 起) | |
检查所含的 month 和 weekday_indexed 对象是否均合法。
返回值
month().ok() && weekday_indexed().ok()
示例
运行此代码
#include <cassert> #include <chrono> int main() { auto mwdi{std::chrono::March/std::chrono::Friday[1]}; assert(mwdi.ok()); mwdi = {std::chrono::month(17)/std::chrono::Friday[1]}; assert(not mwdi.ok()); mwdi = {std::chrono::March/std::chrono::Friday[-4]}; assert(not mwdi.ok()); }