W3cubDocs

/C++

std::chrono::operator+, std::chrono::operator- (std::chrono::year_month_weekday)

constexpr std::chrono::year_month_weekday 
operator+(const std::chrono::year_month_weekday& ymwd, const std::chrono::months& dm) noexcept;
(1) (since C++20)
constexpr std::chrono::year_month_weekday 
operator+(const std::chrono::months& dm, const std::chrono::year_month_weekday& ymwd) noexcept;
(2) (since C++20)
constexpr std::chrono::year_month_weekday 
operator+(const std::chrono::year_month_weekday& ymwd, const std::chrono::years& dy) noexcept;
(3) (since C++20)
constexpr std::chrono::year_month_weekday 
operator+(const std::chrono::years& dy, const std::chrono::year_month_weekday& ymwd) noexcept;
(4) (since C++20)
constexpr std::chrono::year_month_weekday
operator-(const std::chrono::year_month_weekday& ymwd, const std::chrono::months& dm) noexcept;
(5) (since C++20)
constexpr std::chrono::year_month_weekday 
operator-(const std::chrono::year_month_weekday& ymwd, const std::chrono::years& dy) noexcept;
(6) (since C++20)
1-2) Adds dm.count() months to the date represented by ymwd. The result has the same year() and month() as std::chrono::year_month(ymwd.year(), ymwd.month()) + dm and the same weekday() and index() as ymwd.
3-4) Adds dy.count() years to the date represented by ymwd. The result is equivalent to std::chrono::year_month_weekday(ymwd.year() + dy, ymwd.month(), ymwd.weekday_indexed()).
5) Subtracts dm.count() months from the date represented by ymwd. Equivalent to ymwd + -dm.
6) Subtracts dy.count() years from the date represented by ymwd. Equivalent to ymwd + -dy.

Notes

Even if ymwd.ok() is true, the resulting year_month_weekday may not represent a valid date if ymwd.index() is 5.

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/chrono/year_month_weekday/operator_arith_2