From 2d115a8022ef5ac4d4ad6331dde39d1432c4caa7 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Sat, 8 Aug 2015 13:38:12 -0400 Subject: [PATCH] Add to_duration() to time_of_day: * This is a synonym for static_cast(*this). * This variation can be easier to spell when the precision is not conveniently available. --- date.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/date.h b/date.h index 61364ba..30117eb 100644 --- a/date.h +++ b/date.h @@ -3096,6 +3096,11 @@ public: return to24hr(); } + CONSTCD14 precision to_duration() const noexcept + { + return static_cast(*this); + } + CONSTCD14 time_of_day_storage& make24() noexcept {base::make24(); return *this;} CONSTCD14 time_of_day_storage& make12() noexcept {base::make12(); return *this;} @@ -3157,6 +3162,11 @@ public: return to24hr() + m_; } + CONSTCD14 precision to_duration() const noexcept + { + return static_cast(*this); + } + CONSTCD14 time_of_day_storage& make24() noexcept {base::make24(); return *this;} CONSTCD14 time_of_day_storage& make12() noexcept {base::make12(); return *this;} @@ -3223,6 +3233,11 @@ public: return to24hr() + m_ + s_; } + CONSTCD14 precision to_duration() const noexcept + { + return static_cast(*this); + } + CONSTCD14 time_of_day_storage& make24() noexcept {base::make24(); return *this;} CONSTCD14 time_of_day_storage& make12() noexcept {base::make12(); return *this;} @@ -3298,6 +3313,11 @@ public: return to24hr() + m_ + s_ + sub_s_; } + CONSTCD14 precision to_duration() const noexcept + { + return static_cast(*this); + } + CONSTCD14 time_of_day_storage& make24() noexcept {base::make24(); return *this;} CONSTCD14 time_of_day_storage& make12() noexcept {base::make12(); return *this;}