std::chrono:: last_spec, std::chrono:: last
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
定义于头文件
<chrono>
|
||
|
struct
last_spec
{
|
(C++20 起) | |
|
inline
constexpr
last_spec last
{
}
;
|
(C++20 起) | |
last_spec
是一种空标签类型,需与其他日历类型配合使用以表示序列中的最后一项。根据上下文不同,它可能表示某个月的最后一天(例如
2018y
/
February
/
last
表示2018年2月的最后一天,即2018-02-28),也可能表示某个月中周的最后一天(例如
2018
/
February
/
Sunday
[
last
]
表示2018年2月的最后一个星期日,即2018-02-25)。
示例
#include <chrono> int main() { using namespace std::chrono; constexpr auto mdl {June/last}; static_assert(mdl == month_day_last(month(6))); constexpr auto ymwdl {year(2023)/December/Tuesday[last]}; static_assert(ymwdl == year_month_weekday_last(year(2023), month(12), weekday_last(Tuesday))); }