From 543315b70096120436d5e9907946385a23718cce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kami=C5=84ski?= Date: Sat, 25 Nov 2017 22:14:51 +0100 Subject: [PATCH] Reversed order of arguments to clock_time_conversion. Now the order of argument matches the clock_cast function. The test only is_clock_castable trait still matches is_convertible order of arguments. --- include/date/tz.h | 46 +++++++++---------- test/clock_cast_test/custom_clock.pass.cpp | 18 ++++---- test/clock_cast_test/deprecated.pass.cpp | 4 +- test/clock_cast_test/noncastable.pass.cpp | 18 ++++---- test/clock_cast_test/normal_clocks.pass.cpp | 6 +-- .../to_sys_return_int.fail.cpp | 4 +- .../to_sys_return_reference.fail.cpp | 2 +- .../to_sys_return_utc_time.fail.cpp | 4 +- 8 files changed, 51 insertions(+), 51 deletions(-) diff --git a/include/date/tz.h b/include/date/tz.h index abcd2aa..040c122 100644 --- a/include/date/tz.h +++ b/include/date/tz.h @@ -1839,7 +1839,7 @@ public: static time_point now(); template - static + static std::chrono::time_point::type> to_sys(const std::chrono::time_point&); @@ -1990,7 +1990,7 @@ public: static time_point now() NOEXCEPT; template - static + static std::chrono::time_point::type> to_utc(const std::chrono::time_point&) NOEXCEPT; @@ -2100,7 +2100,7 @@ public: static time_point now() NOEXCEPT; template - static + static std::chrono::time_point::type> to_utc(const std::chrono::time_point&) NOEXCEPT; @@ -2197,7 +2197,7 @@ from_stream(std::basic_istream& is, const CharT* fmt, return is; } -template +template struct clock_time_conversion {}; @@ -2207,7 +2207,7 @@ struct clock_time_conversion auto operator()(const sys_time& st) const -> sys_time - { + { return st; } }; @@ -2218,13 +2218,13 @@ struct clock_time_conversion template auto operator()(const utc_time& ut) const -> utc_time - { + { return ut; } }; template<> -struct clock_time_conversion +struct clock_time_conversion { template utc_time::type> @@ -2235,7 +2235,7 @@ struct clock_time_conversion }; template<> -struct clock_time_conversion +struct clock_time_conversion { template sys_time::type> @@ -2251,14 +2251,14 @@ struct clock_time_conversion template auto operator()(const std::chrono::time_point& tp) const -> std::chrono::time_point - { + { return tp; } }; namespace ctc_detail { - //Check if TimePoint is time for given clock, + //Check if TimePoint is time for given clock, //if not emits hard error template struct return_clock_time @@ -2271,7 +2271,7 @@ namespace ctc_detail // Check if Clock has to_sys method accepting TimePoint with given duration const& and returning sys_time // If so has nested type member equal to return type to_sys. template - struct return_to_sys + struct return_to_sys {}; template @@ -2281,7 +2281,7 @@ namespace ctc_detail // Similiar to above template - struct return_from_sys + struct return_from_sys {}; template @@ -2291,7 +2291,7 @@ namespace ctc_detail // Similiar to above template - struct return_to_utc + struct return_to_utc {}; template @@ -2301,7 +2301,7 @@ namespace ctc_detail // Similiar to above template - struct return_from_utc + struct return_from_utc {}; template @@ -2311,7 +2311,7 @@ namespace ctc_detail } template -struct clock_time_conversion +struct clock_time_conversion { template auto operator()(const std::chrono::time_point& tp) const @@ -2322,7 +2322,7 @@ struct clock_time_conversion }; template -struct clock_time_conversion +struct clock_time_conversion { template auto operator()(const sys_time& st) const @@ -2333,7 +2333,7 @@ struct clock_time_conversion }; template -struct clock_time_conversion +struct clock_time_conversion { template auto operator()(const std::chrono::time_point& tp) const @@ -2344,7 +2344,7 @@ struct clock_time_conversion }; template -struct clock_time_conversion +struct clock_time_conversion { template auto operator()(const utc_time& ut) const @@ -2358,12 +2358,12 @@ namespace clock_cast_detail { template auto conv_clock(const std::chrono::time_point& st) - -> decltype(std::declval>()(st)) + -> decltype(std::declval>()(st)) { - return clock_time_conversion{}(st); + return clock_time_conversion{}(st); } - //direct triat conversion, 2nd candidate + //direct triat conversion, 2nd candidate template auto cc_impl(const std::chrono::time_point& st, const std::chrono::time_point* /* 1st */) @@ -2412,8 +2412,8 @@ namespace clock_cast_detail template auto clock_cast(const std::chrono::time_point& st) -> decltype(clock_cast_detail::cc_impl(st, &st)) -{ - return clock_cast_detail::cc_impl(st, &st); +{ + return clock_cast_detail::cc_impl(st, &st); } // Deprecated API diff --git a/test/clock_cast_test/custom_clock.pass.cpp b/test/clock_cast_test/custom_clock.pass.cpp index fd6853a..d9c9d8b 100644 --- a/test/clock_cast_test/custom_clock.pass.cpp +++ b/test/clock_cast_test/custom_clock.pass.cpp @@ -39,7 +39,7 @@ struct mil_clock template static - std::chrono::time_point> + std::chrono::time_point> to_sys(std::chrono::time_point const& tp) { ++conversions; @@ -66,7 +66,7 @@ struct mil_clock date::sys_days const mil_clock::epoch; // traits example -struct s2s_clock +struct s2s_clock { using duration = std::chrono::system_clock::duration; using rep = duration::rep; @@ -75,7 +75,7 @@ struct s2s_clock template static - std::chrono::time_point + std::chrono::time_point to_sys(std::chrono::time_point const& tp) { ++conversions; @@ -84,7 +84,7 @@ struct s2s_clock template static - std::chrono::time_point + std::chrono::time_point from_sys(std::chrono::time_point const& tp) { ++conversions; @@ -100,7 +100,7 @@ struct s2s_clock namespace date { template<> - struct clock_time_conversion + struct clock_time_conversion { template std::chrono::time_point> @@ -123,7 +123,7 @@ main() { sys_days st(1997_y/dec/12); auto mt = mil_clock::from_sys(st); - + assert(clock_cast(mt) == mt); } @@ -133,7 +133,7 @@ main() auto mt = mil_clock::from_sys(st); assert(clock_cast(st) == mt); - assert(clock_cast(mt) == st); + assert(clock_cast(mt) == st); } // mil <-> utc @@ -143,7 +143,7 @@ main() auto ut = utc_clock::from_sys(st); assert(clock_cast(ut) == mt); - assert(clock_cast(mt) == ut); + assert(clock_cast(mt) == ut); } // mil <-> tai @@ -179,7 +179,7 @@ main() assert(clock_cast(s2t) == mt); assert(conversions == 1); - //uses sys_clock + //uses sys_clock conversions = 0; assert(clock_cast(mt) == s2t); assert(conversions == 2); diff --git a/test/clock_cast_test/deprecated.pass.cpp b/test/clock_cast_test/deprecated.pass.cpp index b6de6b9..74d246e 100644 --- a/test/clock_cast_test/deprecated.pass.cpp +++ b/test/clock_cast_test/deprecated.pass.cpp @@ -34,7 +34,7 @@ main() auto ut = utc_clock::from_sys(st); assert(to_utc_time(st) == ut); - assert(to_sys_time(ut) == st); + assert(to_sys_time(ut) == st); } // tai <-> utc @@ -77,7 +77,7 @@ main() assert(to_sys_time(gt) == st); } - // tai <-> gps + // tai <-> gps { sys_days st(1997_y/dec/12); auto ut = utc_clock::from_sys(st); diff --git a/test/clock_cast_test/noncastable.pass.cpp b/test/clock_cast_test/noncastable.pass.cpp index a59e1d0..b81139e 100644 --- a/test/clock_cast_test/noncastable.pass.cpp +++ b/test/clock_cast_test/noncastable.pass.cpp @@ -25,7 +25,7 @@ #include template -struct is_clock_castable +struct is_clock_castable : std::false_type {}; @@ -36,7 +36,7 @@ struct is_clock_castable - struct clock_time_conversion + struct clock_time_conversion { template std::chrono::time_point @@ -66,7 +66,7 @@ namespace date }; template<> - struct clock_time_conversion + struct clock_time_conversion { template std::chrono::time_point @@ -78,7 +78,7 @@ namespace date }; } -//Ambigous clocks both providing to/from_sys and to/from_utc +//Ambigous clocks both providing to/from_sys and to/from_utc //They are mock_ups just returning zero time_point struct amb1_clock { @@ -87,7 +87,7 @@ struct amb1_clock using period = duration::period; using time_point = std::chrono::time_point; - static time_point now() + static time_point now() { return {}; } @@ -132,7 +132,7 @@ struct amb2_clock using period = duration::period; using time_point = std::chrono::time_point; - static time_point now() + static time_point now() { return {}; } @@ -174,7 +174,7 @@ namespace date { //Disambiguates that sys_clock is preffered template<> - struct clock_time_conversion + struct clock_time_conversion { template std::chrono::time_point @@ -214,7 +214,7 @@ main() { auto s1 = steady_clock::time_point(steady_clock::duration(200)); auto s2 = steady_based_clock::time_point(steady_based_clock::duration(200)); - + assert(clock_cast(s1) == s2); assert(clock_cast(s2) == s1); } diff --git a/test/clock_cast_test/normal_clocks.pass.cpp b/test/clock_cast_test/normal_clocks.pass.cpp index b2f427b..525bc02 100644 --- a/test/clock_cast_test/normal_clocks.pass.cpp +++ b/test/clock_cast_test/normal_clocks.pass.cpp @@ -34,7 +34,7 @@ main() sys_days st(1997_y/dec/12); auto ut = utc_clock::from_sys(st); auto tt = tai_clock::from_utc(ut); - + assert(clock_cast(st) == st); assert(clock_cast(ut) == ut); assert(clock_cast(tt) == tt); @@ -46,7 +46,7 @@ main() auto ut = utc_clock::from_sys(st); assert(clock_cast(st) == ut); - assert(clock_cast(ut) == st); + assert(clock_cast(ut) == st); } // tai <-> utc @@ -89,7 +89,7 @@ main() assert(clock_cast(gt) == st); } - // tai <-> gps + // tai <-> gps { sys_days st(1997_y/dec/12); auto ut = utc_clock::from_sys(st); diff --git a/test/clock_cast_test/to_sys_return_int.fail.cpp b/test/clock_cast_test/to_sys_return_int.fail.cpp index 76c8551..370c682 100644 --- a/test/clock_cast_test/to_sys_return_int.fail.cpp +++ b/test/clock_cast_test/to_sys_return_int.fail.cpp @@ -22,7 +22,7 @@ #include "tz.h" -struct bad_clock +struct bad_clock { using duration = std::chrono::system_clock::duration; using rep = duration::rep; @@ -31,7 +31,7 @@ struct bad_clock template static - int + int to_sys(std::chrono::time_point const& tp) { return tp.time_since_epoch().count(); diff --git a/test/clock_cast_test/to_sys_return_reference.fail.cpp b/test/clock_cast_test/to_sys_return_reference.fail.cpp index 1f8527f..5fae165 100644 --- a/test/clock_cast_test/to_sys_return_reference.fail.cpp +++ b/test/clock_cast_test/to_sys_return_reference.fail.cpp @@ -22,7 +22,7 @@ #include "tz.h" -struct bad_clock +struct bad_clock { using duration = std::chrono::system_clock::duration; using rep = duration::rep; diff --git a/test/clock_cast_test/to_sys_return_utc_time.fail.cpp b/test/clock_cast_test/to_sys_return_utc_time.fail.cpp index 352b983..d5364ce 100644 --- a/test/clock_cast_test/to_sys_return_utc_time.fail.cpp +++ b/test/clock_cast_test/to_sys_return_utc_time.fail.cpp @@ -22,7 +22,7 @@ #include "tz.h" -struct bad_clock +struct bad_clock { using duration = std::chrono::system_clock::duration; using rep = duration::rep; @@ -31,7 +31,7 @@ struct bad_clock template static - date::utc_time + date::utc_time to_sys(std::chrono::time_point const& tp) { return utc_time(tp.time_since_epoch());