std::chrono::year_month_day_last::ok
来自cppreference.com
| |
(C++20 起) | |
检查 *this 是否表示合法日期。因为 year_month_day_last 表示特定月的最后一日,故只要年和月合法它就表示合法日期。
返回值
year().ok() && month().ok()
示例
运行此代码
#include <cassert>
#include <chrono>
int main()
{
auto ymdl{std::chrono::last/11/2020};
assert(ymdl.ok());
ymdl = std::chrono::year(2020)/std::chrono::month(13)/std::chrono::last;
assert(not ymdl.ok());
}