| 39 | |
| 40 | template <typename T, typename Source> |
| 41 | T ReadGamma(BitReader<Source> & reader) |
| 42 | { |
| 43 | static_assert(std::is_unsigned<T>::value, "T should be an unsigned type"); |
| 44 | uint64_t const decoded = coding::GammaCoder::Decode(reader); |
| 45 | if (decoded > std::numeric_limits<T>::max()) |
| 46 | MYTHROW(CorruptedDataException, ("Decoded value", decoded, "out of limit", std::numeric_limits<T>::max())); |
| 47 | |
| 48 | return static_cast<T>(decoded); |
| 49 | } |
| 50 | |
| 51 | template <typename T, typename Sink> |
| 52 | void WriteGamma(BitWriter<Sink> & writer, T value) |