std::chrono::last_spec, std::chrono::last
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Date and time library
(C++11)
(C++20)
(C++20)
(C++11)
(C++11)
(C++11)
(C++20)
(C++20)
(C++20)
(C++11)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)
(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
last_speclast
(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
Defined in header
<chrono>
struct last_spec
(since C++20)
{
explicit last_spec() = default;
inline constexpr last_spec last{};
(since C++20)
last_spec
is an empty tag type that is used in conjunction with other calendar types to indicate the last thing in a sequence. Depending on context, it may indicate the last day of a month (as in 2018y/February/last, for last day of February 2018, i.e., 2018年02月28日) or the last day of the week in a month (as in 2018/February/Sunday[last], for last Sunday of February 2018, i.e., 2018年02月25日).
[edit] Example
Run this code
#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))); }