From 0e64070a33fa2d1e227a693c405a0ca368909e5e Mon Sep 17 00:00:00 2001 From: Ivan Pizhenko Date: Thu, 12 Feb 2015 16:22:00 +0200 Subject: [PATCH] Correction after code review --- tz.cpp | 9 ++------- tz_private.h | 19 +++++++++---------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/tz.cpp b/tz.cpp index 2562750..c910292 100644 --- a/tz.cpp +++ b/tz.cpp @@ -768,11 +768,7 @@ operator>>(std::istream& is, MonthDayTime& x) throw std::runtime_error(std::string("bad operator: ") + c + c2 + std::to_string(d)); x.type_ = c == '<' ? MonthDayTime::lteq : MonthDayTime::gteq; -#if !defined(_MSC_VER) || (_MSC_VER >= 1900) - x.u = {date::month(m)/d, date::weekday(dow)}; -#else - x.u = MonthDayTime::U(date::month(m)/d, date::weekday(dow)); -#endif + x.u = MonthDayTime::pair{ date::month(m) / d, date::weekday(dow) }; } else throw std::runtime_error(std::string("bad operator: ") + c); @@ -1370,8 +1366,7 @@ find_previous_rule(const Rule* r, date::year y) // [first, last) all have the same name static std::pair -find_next_rule(const Rule* first_rule, const Rule* last_rule, const Rule* r, - date::year y) +find_next_rule(const Rule* first_rule, const Rule* last_rule, const Rule* r, date::year y) { using namespace date; if (y == r->ending_year()) diff --git a/tz_private.h b/tz_private.h index c334892..60265ac 100644 --- a/tz_private.h +++ b/tz_private.h @@ -35,7 +35,11 @@ private: { #if defined(_MSC_VER) && (_MSC_VER < 1900) pair() : month_day_(date::jan / 1), weekday_(0U) {} + + pair(const date::month_day& month_day, const date::weekday& weekday) + : month_day_(month_day), weekday_(weekday) {} #endif + date::month_day month_day_; date::weekday weekday_; }; @@ -44,17 +48,17 @@ private: Type type_{month_day}; -#if defined(_MSC_VER) && (_MSC_VER < 1900) - struct U -#else +#if !defined(_MSC_VER) || (_MSC_VER > 1900) union U +#else + struct U #endif { date::month_day month_day_; date::month_weekday_last month_weekday_last_; pair month_day_weekday_; -#if !defined(_MSC_VER) && (_MSC_VER >= 1900) +#if !defined(_MSC_VER) || (_MSC_VER >= 1900) U() : month_day_{date::jan/1} {} #else U() : @@ -62,12 +66,7 @@ private: month_weekday_last_(date::month(0U), date::weekday_last(date::weekday(0U))) {} - U(const date::month_day& month_day, - const date::weekday& weekday) : - month_day_(month_day), - month_weekday_last_(date::month(0U), date::weekday_last(weekday)) - {} -#endif // !defined(_MSC_VER) && (_MSC_VER >= 1900) +#endif // !defined(_MSC_VER) || (_MSC_VER >= 1900) U& operator=(const date::month_day& x); U& operator=(const date::month_weekday_last& x);