Namespaces
Variants

std::chrono::year_month_weekday_last:: operator+=, std::chrono::year_month_weekday_last:: operator-=

From cppreference.net

constexpr std:: chrono :: year_month_weekday_last &
operator + = ( const std:: chrono :: years & dy ) const noexcept ;
(1) (C++20부터)
constexpr std:: chrono :: year_month_weekday_last &
operator + = ( const std:: chrono :: months & dm ) const noexcept ;
(2) (C++20부터)
constexpr std:: chrono :: year_month_weekday_last &
operator - = ( const std:: chrono :: years & dy ) const noexcept ;
(3) (C++20부터)
constexpr std:: chrono :: year_month_weekday_last &
operator - = ( const std:: chrono :: months & dm ) const noexcept ;
(4) (C++20부터)

시간점을 * this 이 나타내는 값을 지속 시간 dy 또는 dm 만큼 수정합니다.

1) 다음과 동일함 * this = * this + dy ; .
2) 다음과 동일함 * this = * this + dm ; .
3) 다음과 동일함: * this = * this - dy ; .
4) 다음과 동일함 * this = * this - dm ; .

std::chrono::years std::chrono::months 모두로 변환 가능한 지속 시간의 경우, 호출이 모호해질 수 있는 상황에서는 years 오버로드 (1,3) 가 우선적으로 선택됩니다.

예제

#include <chrono>
#include <iostream>
using namespace std::chrono;
int main()
{
    auto ymwdl{August/Friday[last]/2022};
    std::cout << year_month_day{ymwdl} << '\n';
    ymwdl += months(2);
    std::cout << year_month_day{ymwdl} << '\n';
    ymwdl -= years(1); 
    std::cout << year_month_day{ymwdl} << '\n';
}

출력:

2022-08-26
2022-10-28
2021-10-29

참고 항목

year_month_weekday_last 와 연수 또는 월수를 더하거나 뺌
(함수)