diff options
| author | grand <[email protected]> | 2022-02-10 16:50:06 +0300 |
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:50:06 +0300 |
| commit | 7eb3862cccdb866e7e739123c8024ccec628bb62 (patch) | |
| tree | 5ce974787810a396bb1c1cca605feef8f9e85679 /library/cpp/packedtypes | |
| parent | 13dbd0acb78595551b843005d6bd021bdc1a859b (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/packedtypes')
| -rw-r--r-- | library/cpp/packedtypes/zigzag.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/library/cpp/packedtypes/zigzag.h b/library/cpp/packedtypes/zigzag.h index 548403f8384..08854ea48ee 100644 --- a/library/cpp/packedtypes/zigzag.h +++ b/library/cpp/packedtypes/zigzag.h @@ -8,14 +8,14 @@ //! See https://developers.google.com/protocol-buffers/docs/encoding#types for details. template <typename TSignedInt> -inline auto ZigZagEncode(TSignedInt n) -> std::make_unsigned_t<TSignedInt> { +inline auto ZigZagEncode(TSignedInt n) -> std::make_unsigned_t<TSignedInt> { static_assert(std::is_signed<TSignedInt>::value && std::is_integral<TSignedInt>::value, "Expected signed integral type."); auto un = static_cast<std::make_unsigned_t<TSignedInt>>(n); return (un << 1) ^ (n >> (CHAR_BIT * sizeof(TSignedInt) - 1)); } template <typename TUnsignedInt> -inline auto ZigZagDecode(TUnsignedInt n) -> std::make_signed_t<TUnsignedInt> { +inline auto ZigZagDecode(TUnsignedInt n) -> std::make_signed_t<TUnsignedInt> { static_assert(std::is_unsigned<TUnsignedInt>::value, "Expected unsigned integral type."); - return (n >> 1) ^ -static_cast<std::make_signed_t<TUnsignedInt>>(n & 1); + return (n >> 1) ^ -static_cast<std::make_signed_t<TUnsignedInt>>(n & 1); } |
