From f66af06870a4719c1b48b2fe0f075f514ecbd8be Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Sat, 8 Oct 2016 15:03:33 -0400 Subject: [PATCH] Simplify implementation details of "chrono_io.h" --- chrono_io.h | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/chrono_io.h b/chrono_io.h index 7916282..d66a4f2 100644 --- a/chrono_io.h +++ b/chrono_io.h @@ -381,34 +381,34 @@ msl(std::exa) noexcept return msl(CharT{'E'}); } -template +template constexpr auto -get_units(const std::chrono::duration&) +get_units(Period p) { - return msl(Period{}) + string_literal{"s"}; + return msl(p) + string_literal{"s"}; } -template +template constexpr auto -get_units(const std::chrono::duration>&) +get_units(std::ratio<1>) { return string_literal{"s"}; } -template +template constexpr auto -get_units(const std::chrono::duration>&) +get_units(std::ratio<60>) { return string_literal{"min"}; } -template +template constexpr auto -get_units(const std::chrono::duration>&) +get_units(std::ratio<3600>) { return string_literal{"h"}; } @@ -620,30 +620,30 @@ msl(std::exa) noexcept return {'E'}; } -template +template std::basic_string -get_units(const std::chrono::duration&) +get_units(Period p) { - return msl(Period{}) + CharT{'s'}; + return msl(p) + CharT{'s'}; } -template +template std::basic_string -get_units(const std::chrono::duration>&) +get_units(std::ratio<1>) { return {'s'}; } -template +template std::basic_string -get_units(const std::chrono::duration>&) +get_units(std::ratio<60>) { return {'m', 'i', 'n'}; } -template +template std::basic_string -get_units(const std::chrono::duration>&) +get_units(std::ratio<3600>) { return {'h'}; } @@ -660,7 +660,7 @@ operator<<(std::basic_ostream& os, { using namespace std::chrono; return os << d.count() - << detail::get_units(duration{}); + << detail::get_units(typename Period::type{}); } } // namespace date