THRIFT-922. cpp: Fix C++ compilation when using list<bool>
The STL specializes vector<bool> to store the values as individual bits, rather
than bools. Therefore, when using a Thrift list<bool>, readBool() gets invoked
not with a bool&, but with a std::vector<bool>::reference.
TProtocol does provide a readBool(std::vector<bool>::reference) implementation.
However, almost all TProtocol subclasses defined only readBool(bool&), which
hides the other overloaded versions of readBool(). As a result, the code
worked only when accessing TProtocol objects via a "TProtocol*", and not
directly via the subclass type. When using C++ templates, protocol objects do
get invoked via pointers to the subclass type, causing compile failures when
std::vector<bool> is used.
This change updates the various TProtocol implementations to also provide
readBool(std::vector<bool>::reference).
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005137 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/protocol/TJSONProtocol.h b/lib/cpp/src/protocol/TJSONProtocol.h
index b3a6667..2be54da 100644
--- a/lib/cpp/src/protocol/TJSONProtocol.h
+++ b/lib/cpp/src/protocol/TJSONProtocol.h
@@ -243,6 +243,9 @@
uint32_t readBool(bool& value);
+ // Provide the default readBool() implementation for std::vector<bool>
+ using TVirtualProtocol<TJSONProtocol>::readBool;
+
uint32_t readByte(int8_t& byte);
uint32_t readI16(int16_t& i16);