aboutsummaryrefslogtreecommitdiff
path: root/pw_varint/varint.cc
diff options
context:
space:
mode:
authorWyatt Hepler <hepler@google.com>2020-01-16 16:34:58 -0800
committerWyatt Hepler <hepler@google.com>2020-01-17 15:04:43 -0800
commit588907ad4251027d87c00f827a2a522b0945e361 (patch)
tree755f954e1cf716295045e3b9c16c2dd0c1f6110f /pw_varint/varint.cc
parentda0bccb98fd2bfd7425118a37856b749664d4ee6 (diff)
downloadpigweed-588907ad4251027d87c00f827a2a522b0945e361.tar.gz
Make span and varint C++11 compatible
Change-Id: Idb9f4e1563d4d4cfeb460b23c82d11fd9c298939
Diffstat (limited to 'pw_varint/varint.cc')
-rw-r--r--pw_varint/varint.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/pw_varint/varint.cc b/pw_varint/varint.cc
index 006952cce..ddfc0ed40 100644
--- a/pw_varint/varint.cc
+++ b/pw_varint/varint.cc
@@ -16,7 +16,8 @@
#include <algorithm>
-namespace pw::varint {
+namespace pw {
+namespace varint {
extern "C" size_t pw_VarintEncode(uint64_t integer,
void* output,
@@ -30,11 +31,11 @@ extern "C" size_t pw_VarintEncode(uint64_t integer,
}
// Grab 7 bits; the eighth bit is set to 1 to indicate more data coming.
- buffer[written++] = static_cast<std::byte>(integer) | std::byte{0x80};
+ buffer[written++] = static_cast<std::byte>(integer) | std::byte(0x80);
integer >>= 7;
} while (integer != 0u);
- buffer[written - 1] &= std::byte{0x7f}; // clear the top bit of the last byte
+ buffer[written - 1] &= std::byte(0x7f); // clear the top bit of the last byte
return written;
}
@@ -60,11 +61,11 @@ extern "C" size_t pw_VarintDecode(const void* input,
}
// Add the bottom seven bits of the next byte to the result.
- decoded_value |= static_cast<uint64_t>(buffer[count] & std::byte{0x7f})
+ decoded_value |= static_cast<uint64_t>(buffer[count] & std::byte(0x7f))
<< (7 * count);
// Stop decoding if the top bit is not set.
- if ((buffer[count++] & std::byte{0x80}) == std::byte{0}) {
+ if ((buffer[count++] & std::byte(0x80)) == std::byte(0)) {
break;
}
}
@@ -82,4 +83,5 @@ extern "C" size_t pw_VarintZigZagDecode(const void* input,
return bytes;
}
-} // namespace pw::varint
+} // namespace varint
+} // namespace pw