| 99 | // Reverse function for EncodeZigZagDelta. |
| 100 | template <typename T, typename UnsignedT = std::make_unsigned_t<T>> |
| 101 | T DecodeZigZagDelta(T prev, UnsignedT delta) |
| 102 | { |
| 103 | static_assert(std::is_integral<T>::value, "T should be an integral type"); |
| 104 | |
| 105 | auto decoded = bits::ZigZagDecode(delta); |
| 106 | static_assert(std::is_same<decltype(decoded), std::make_signed_t<T>>::value, |
| 107 | "It's expected that bits::ZigZagDecode returns SignedT"); |
| 108 | return prev + static_cast<T>(decoded); |
| 109 | } |
| 110 | } // namespace routing |