From c99a40b8469996a7963c85ea0ef5b6d329ce2e89 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Sat, 1 Aug 2015 19:16:33 -0400 Subject: [PATCH] Add year_month += and -= operators. --- date.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/date.h b/date.h index 6b771f2..f7bd09e 100644 --- a/date.h +++ b/date.h @@ -382,6 +382,11 @@ public: CONSTCD11 date::year year() const noexcept; CONSTCD11 date::month month() const noexcept; + year_month& operator+=(const months& dm) noexcept; + year_month& operator-=(const months& dm) noexcept; + year_month& operator+=(const years& dy) noexcept; + year_month& operator-=(const years& dy) noexcept; + CONSTCD11 bool ok() const noexcept; }; @@ -1537,6 +1542,38 @@ CONSTCD11 inline year year_month::year() const noexcept {return y_;} CONSTCD11 inline month year_month::month() const noexcept {return m_;} CONSTCD11 inline bool year_month::ok() const noexcept {return y_.ok() && m_.ok();} +inline +year_month& +year_month::operator+=(const months& dm) noexcept +{ + *this = *this + dm; + return *this; +} + +inline +year_month& +year_month::operator-=(const months& dm) noexcept +{ + *this = *this - dm; + return *this; +} + +inline +year_month& +year_month::operator+=(const years& dy) noexcept +{ + *this = *this + dy; + return *this; +} + +inline +year_month& +year_month::operator-=(const years& dy) noexcept +{ + *this = *this - dy; + return *this; +} + CONSTCD11 inline bool