std::chrono::last_spec, std::chrono::last
From cppreference.com
| ヘッダー <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))); }