std::chrono::year_month_day_last:: ok
From cppreference.net
<
cpp
|
chrono
|
year month day last
C++
Date and time library
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::chrono::year_month_day_last
| Member functions | ||||
|
year_month_day_last::ok
|
||||
| Nonmember functions | ||||
| Helper classes | ||||
|
constexpr
bool
ok
(
)
const
noexcept
;
|
(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()); }