forked from HowardHinnant/date
Add year_month += and -= operators.
This commit is contained in:
37
date.h
37
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
|
||||
|
Reference in New Issue
Block a user