std::chrono::year_month_weekday_last::operator+=, (3) - Linux Manuals

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

NAME

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

Synopsis


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


Modifies the time point *this represents by the duration dy or dm.


1) Equivalent to *this *this dy;
2) Equivalent to *this *this dm;
3) Equivalent to *this *this - dy;
4) Equivalent to *this *this - dm;

Notes


Durations that are convertible to std::chrono::months, but not std::chrono::years,
can be directly added to or subtracted from a year_month_weekday_last. Durations
convertible to std::chrono::years cannot because such durations are also convertible
to std::chrono::months, resulting in an ambiguity:


 using namespace std::chrono;


 using decades duration<int, std::ratio_multiply<std::ratio<10>, years::period>>;
 using kilomonths duration<int, std::ratio_multiply<std::kilo, months::period>>;


 auto ymwdl 2001y/April/Sunday[last];
 ymwdl += decades{1}; // error, ambiguous
 ymwdl += kilomonths{1}; // OK

See also


operator+ adds or subtracts a year_month_weekday_last and some number of years or
operator- months
 (function)