File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -538,14 +538,15 @@ struct CustomUintFormatter
538
538
539
539
template <typename Stream, typename I> void Unser (Stream& s, I& v)
540
540
{
541
- static_assert (std::numeric_limits<I>::max () >= MAX && std::numeric_limits<I>::min () <= 0 , " CustomUintFormatter type too small" );
541
+ using U = typename std::conditional<std::is_enum<I>::value, std::underlying_type<I>, std::common_type<I>>::type::type;
542
+ static_assert (std::numeric_limits<U>::max () >= MAX && std::numeric_limits<U>::min () <= 0 , " Assigned type too small" );
542
543
uint64_t raw = 0 ;
543
544
if (BigEndian) {
544
545
s.read (((char *)&raw) + 8 - Bytes, Bytes);
545
- v = be64toh (raw);
546
+ v = static_cast <I>( be64toh (raw) );
546
547
} else {
547
548
s.read ((char *)&raw, Bytes);
548
- v = le64toh (raw);
549
+ v = static_cast <I>( le64toh (raw) );
549
550
}
550
551
}
551
552
};
You can’t perform that action at this time.
0 commit comments