std::chrono::operator+,std::chrono::operator-(std::chrono::year_month_day) (3) - Linux Man Pages

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

NAME

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

Synopsis


Defined in header <chrono>
constexpr std::chrono::year_month_day operator+(const std::chrono::year_month_day& ymd, (since C++20)
const std::chrono::months& dm) noexcept;
constexpr std::chrono::year_month_day operator+(const std::chrono::months& dm, (since C++20)
const std::chrono::year_month_day& ymd) noexcept;
constexpr std::chrono::year_month_day operator+(const std::chrono::year_month_day& ymd, (since C++20)
const std::chrono::years& dy) noexcept;
constexpr std::chrono::year_month_day operator+(const std::chrono::years& dy, (since C++20)
const std::chrono::year_month_day& ymd) noexcept;
constexpr std::chrono::year_month_day operator-(const std::chrono::year_month_day& ymd, (since C++20)
const std::chrono::months& dm) noexcept;
constexpr std::chrono::year_month_day operator-(const std::chrono::year_month_day& ymd, (since C++20)
const std::chrono::years& dy) noexcept;


1-2) Adds dm.count() months to the date represented by ymd. The result has the same day() as ymd and the same year() and month() as std::chrono::year_month(ymd.year(), ymd.month()) + dm.
3-4) Adds dy.count() years to the date represented by ymd. The result is equivalent to std::chrono::year_month_day(ymd.year() + dy, ymd.month(), ymd.day().
5) Subtracts dm.count() months from the date represented by ymd. Equivalent to ymd + -dm.
6) Subtracts dy.count() years from the date represented by ymd. Equivalent to ymd + -dy.

Notes


Even if ymd.ok() is true, the resulting year_month_day may not represent a valid date if ymd.day() is 29, 30, or 31.