std::chrono::year_month_weekday_last
std::chrono::year_month_weekday_last (연·월 마지막 요일 클래스)
특정 연도와 월의 마지막 요일을 나타내는 클래스예요. 필드 기반 시점 타입이고 분해능은 std::chrono::days예요. 다만 연·월의 마지막 요일을 가리키는 것으로 제한돼요. C++20의 chrono 달력 시스템에서 "마지막 금요일" 같은 날짜를 표현해요.
출처: cppreference
본문
<chrono> 헤더에 정의돼 있고, 특정 연도와 월의 마지막 요일을 나타내요.
class year_month_weekday_last;
필드 기반 시점 타입이고 분해능은 std::chrono::days예요. 다만 연·월의 마지막 요일을 가리키는 것으로 제한돼요. std::chrono::years·std::chrono::months 중심 산술이 직접 지원되고, std::chrono::sys_days로의 암시적 변환 덕분에 std::chrono::days 중심 산술도 효율적으로 수행할 수 있어요. year_month_weekday_last는 TriviallyCopyable한 StandardLayoutType이에요.
멤버 함수:
- 생성자:
year_month_weekday_last를 만들 수 있어요. operator+=,operator-=: 시점을 몇 달 또는 몇 년만큼 수정해요.year(),month(),weekday(),weekday_last(): 이 객체의 필드들에 접근해요.operator sys_days,operator local_days:std::chrono::time_point로 변환해요.ok: 이 객체가 유효한 날짜를 나타내는지 확인해요.
비멤버 함수:
operator==(C++20): 두year_month_weekday_last값을 비교해요.operator+,operator-(C++20):year_month_weekday_last에 몇 년 또는 몇 달을 더하거나 빼요.operator<<(C++20):year_month_weekday_last를 스트림에 출력해요.
헬퍼 클래스:
std::formatter<std::chrono::year_month_weekday_last>(C++20):year_month_weekday_last포맷 지원.std::hash<std::chrono::year_month_weekday_last>(C++26): 해시 지원.
weekday_last는 "마지막 무슨 요일"을 나타내므로, 이 클래스는 예를 들어 "2023년 9월 마지막 금요일" 같은 날짜를 표현하는 데 쓰여요. operator sys_days로 변환하면 실제 날짜를 얻을 수 있어요.