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()); }