Namespaces
Variants

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

From cppreference.net

constexpr std:: chrono :: year_month_day_last &
operator + = ( const std:: chrono :: years & dy ) const noexcept ;
(1) (C++20부터)
constexpr std:: chrono :: year_month_day_last &
operator + = ( const std:: chrono :: months & dm ) const noexcept ;
(2) (C++20부터)
constexpr std:: chrono :: year_month_day_last &
operator - = ( const std:: chrono :: years & dy ) const noexcept ;
(3) (C++20부터)
constexpr std:: chrono :: year_month_day_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 모두로 변환 가능한 duration의 경우, 호출이 모호해질 수 있는 상황에서는 years 오버로드 (1,3) 가 우선적으로 선택됩니다.

예제

#include <cassert>
#include <chrono>
int main()
{
    auto ymdl{11/std::chrono::last/2020};
    ymdl += std::chrono::years(15);
    assert(ymdl.day() == std::chrono::day(30));
    assert(ymdl.month() == std::chrono::November);
    assert(ymdl.year() == std::chrono::year(2035));
    ymdl -= std::chrono::months(6);
    assert(ymdl.day() == std::chrono::day(31));
    assert(ymdl.month() == std::chrono::May);
    assert(ymdl.year() == std::chrono::year(2035));
}

참고 항목

year_month_day_last 에 연수나 월수를 더하거나 뺌
(함수)