From 9f7a438f7df629d0f1e4bdf5742911a0c2a556b5 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Wed, 19 Oct 2016 12:01:26 -0400 Subject: [PATCH] Add unary operators + and - to year --- date.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/date.h b/date.h index b2d28f2..80e866d 100644 --- a/date.h +++ b/date.h @@ -318,6 +318,9 @@ public: CONSTCD14 year& operator+=(const years& y) NOEXCEPT; CONSTCD14 year& operator-=(const years& y) NOEXCEPT; + CONSTCD11 year operator-() const NOEXCEPT; + CONSTCD11 year operator+() const NOEXCEPT; + CONSTCD11 bool is_leap() const NOEXCEPT; CONSTCD11 explicit operator int() const NOEXCEPT; @@ -1377,6 +1380,8 @@ CONSTCD14 inline year& year::operator--() NOEXCEPT {--y_; return *this;} CONSTCD14 inline year year::operator--(int) NOEXCEPT {auto tmp(*this); --(*this); return tmp;} CONSTCD14 inline year& year::operator+=(const years& y) NOEXCEPT {*this = *this + y; return *this;} CONSTCD14 inline year& year::operator-=(const years& y) NOEXCEPT {*this = *this - y; return *this;} +CONSTCD11 inline year year::operator-() const NOEXCEPT {return year{-y_};} +CONSTCD11 inline year year::operator+() const NOEXCEPT {return *this;} CONSTCD11 inline