@@ -298,18 +298,16 @@ inline scalar_decode_kind get_scalar_decode_kind(proto_encoding encoding)
298298template <typename T, scalar_decode_kind Decode, typename F>
299299constexpr void dispatch_scalar_decoder (F&& f)
300300{
301- if constexpr (Decode == scalar_decode_kind::FIXED ) {
301+ using enum scalar_decode_kind;
302+ if constexpr (Decode == FIXED ) {
302303 static_assert (sizeof (T) == 4 || sizeof (T) == 8 );
303304 std::forward<F>(f).template operator ()<decode_fixed_value<T>>();
304- } else if constexpr (Decode == scalar_decode_kind::VARINT ) {
305- static_assert (std::is_integral_v<T>);
306- std::forward<F>(f).template operator ()<decode_varint_value<T, false >>();
307- } else if constexpr (Decode == scalar_decode_kind::ZIGZAG ) {
308- static_assert (std::is_integral_v<T> && std::is_signed_v<T>);
309- std::forward<F>(f).template operator ()<decode_varint_value<T, true >>();
310305 } else {
311- static_assert (Decode == scalar_decode_kind::FIXED || Decode == scalar_decode_kind::VARINT ||
312- Decode == scalar_decode_kind::ZIGZAG );
306+ static_assert (Decode == VARINT || Decode == ZIGZAG );
307+ static_assert (std::is_integral_v<T>);
308+ constexpr bool zigzag = Decode == ZIGZAG ;
309+ if constexpr (zigzag) { static_assert (std::is_signed_v<T>); }
310+ std::forward<F>(f).template operator ()<decode_varint_value<T, zigzag>>();
313311 }
314312}
315313
0 commit comments