std::chrono::weekday_last::ok
来自 cppreference.com
< cpp | chrono | weekday last
constexpr bool ok() const noexcept; |
(自 C++20 起) | |
检查存储在 *this 中的星期几对象是否有效。
[编辑] 返回值
weekday().ok()
[编辑] 示例
运行此代码
#include <chrono> #include <iostream> int main() { std::cout << std::boolalpha; auto wdl{std::chrono::Tuesday[std::chrono::last]}; std::cout << (wdl.ok()) << ' '; wdl = {std::chrono::weekday(42)[std::chrono::last]}; std::cout << (wdl.ok()) << '\n'; }
输出
true false