std::chrono::month_weekday_last::ok

来自cppreference.com
 
 
 
 
constexpr bool ok() const noexcept;
(C++20 起)

检查所含的 monthweekday_last 对象是否均合法。

返回值

month().ok() && weekday_last().ok()

示例

#include <chrono>
#include <iostream>
 
int main()
{
    std::cout << std::boolalpha;
 
    auto mwdl{std::chrono::March/std::chrono::Wednesday[std::chrono::last]};
    std::cout << (mwdl.ok()) << ' ';
    mwdl = {std::chrono::month(3)/std::chrono::weekday(42)[std::chrono::last]}; 
    std::cout << (mwdl.ok()) << '\n';
}

输出:

true false