Add year_month += and -= operators.

This commit is contained in:
Howard Hinnant
2015-08-01 19:16:33 -04:00
parent 2e715844bb
commit c99a40b846

37
date.h
View File

@@ -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