@@ -99,43 +99,46 @@ struct Parser<R, W, std::chrono::duration<Rep, Period>, ProcessorsType> {
9999 }
100100 }
101101
102+ template <typename OtherDuration>
103+ inline static constexpr bool samePeriodAs =
104+ std::is_same_v<typename DurationType::period,
105+ typename OtherDuration::period>;
106+
102107 static auto make_unit () noexcept {
103- if constexpr (std::is_same_v<DurationType, std::chrono::nanoseconds>) {
108+ if constexpr (samePeriodAs< std::chrono::nanoseconds>) {
104109 return Unit::make<" nanoseconds" >();
105110
106- } else if constexpr (std::is_same_v<DurationType,
107- std::chrono::microseconds>) {
111+ } else if constexpr (samePeriodAs<std::chrono::microseconds>) {
108112 return Unit::make<" microseconds" >();
109113
110- } else if constexpr (std::is_same_v<DurationType,
111- std::chrono::milliseconds>) {
114+ } else if constexpr (samePeriodAs<std::chrono::milliseconds>) {
112115 return Unit::make<" milliseconds" >();
113116
114- } else if constexpr (std::is_same_v<DurationType, std::chrono::seconds>) {
117+ } else if constexpr (samePeriodAs< std::chrono::seconds>) {
115118 return Unit::make<" seconds" >();
116119
117- } else if constexpr (std::is_same_v<DurationType, std::chrono::minutes>) {
120+ } else if constexpr (samePeriodAs< std::chrono::minutes>) {
118121 return Unit::make<" minutes" >();
119122
120- } else if constexpr (std::is_same_v<DurationType, std::chrono::hours>) {
123+ } else if constexpr (samePeriodAs< std::chrono::hours>) {
121124 return Unit::make<" hours" >();
122125
123- } else if constexpr (std::is_same_v<DurationType, std::chrono::days>) {
126+ } else if constexpr (samePeriodAs< std::chrono::days>) {
124127 return Unit::make<" days" >();
125128
126- } else if constexpr (std::is_same_v<DurationType, std::chrono::weeks>) {
129+ } else if constexpr (samePeriodAs< std::chrono::weeks>) {
127130 return Unit::make<" weeks" >();
128131
129- } else if constexpr (std::is_same_v<DurationType, std::chrono::months>) {
132+ } else if constexpr (samePeriodAs< std::chrono::months>) {
130133 return Unit::make<" months" >();
131134
132- } else if constexpr (std::is_same_v<DurationType, std::chrono::years>) {
135+ } else if constexpr (samePeriodAs< std::chrono::years>) {
133136 return Unit::make<" years" >();
134137
135138 } else {
136139 static_assert (always_false_v<DurationType>, " Unsupported type." );
137140 }
138- };
141+ }
139142};
140143
141144} // namespace rfl::parsing
0 commit comments