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 и некоторое количество лет или месяцев
(функция)