last_spec
last_spec (월의 마지막 날 지정자)
"어떤 월의 마지막 날"을 나타내는 날짜 지정(type)이에요. <chrono> 헤더, C++20부터.
출처: cppreference
본문
std::chrono::last_spec는 "월의 마지막 날"을 나타내는 태그 타입이에요.
struct last_spec {
explicit last_spec() = default;
};
inline constexpr last_spec last{};
last 상수 객체와 std::chrono::month를 결합해서 해당 월의 마지막 날짜를 만들 수 있어요.
using namespace std::chrono;
auto last_day = February / last; // 2월의 마지막 날 지정
month_day_last 타입과 함께 쓰여, 예를 들어 "2월의 마지막 날"처럼 월별로 끝나는 날이 다른 경우를 타입 안전하게 표현해요. 2월은 28/29일, 4월은 30일 등으로 해석되는 데 도움을 줘요.
실제 날짜가 아니라 "지정자(specifier)"만 담는 가벼운 타입이고, 날짜 계산 단위(month, day, year 등)들과 결합해 year_month_day_last 같은 복합 타입을 만들 때 사용돼요.