GCC: fix template specialization in webrtc::BitstreamReader
GCC complains that explicit specialization in non-namespace scope
is happening for webrtc::BitstreamReader::Read(). However,
specializationvfor bool isn't used because std::is_unsigned<bool>::value
returns true. Add std::is_same for bool check and enable second
specialization only for bool types.
Bug: chromium:819294
Change-Id: I1873cd59e2737516bd4012fb952da65d6bf3172b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231561
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35007}
diff --git a/rtc_base/bitstream_reader.h b/rtc_base/bitstream_reader.h
index 8c0f66f..51c7914 100644
--- a/rtc_base/bitstream_reader.h
+++ b/rtc_base/bitstream_reader.h
@@ -61,14 +61,17 @@
// Reads unsigned integer of fixed width.
template <typename T,
typename std::enable_if<std::is_unsigned<T>::value &&
+ !std::is_same<T, bool>::value &&
sizeof(T) <= 8>::type* = nullptr>
ABSL_MUST_USE_RESULT T Read() {
return rtc::dchecked_cast<T>(ReadBits(sizeof(T) * 8));
}
// Reads single bit as boolean.
- template <>
- ABSL_MUST_USE_RESULT bool Read<bool>() {
+ template <
+ typename T,
+ typename std::enable_if<std::is_same<T, bool>::value>::type* = nullptr>
+ ABSL_MUST_USE_RESULT bool Read() {
return ReadBit() != 0;
}