aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/has_bits.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/has_bits.h')
-rw-r--r--src/google/protobuf/has_bits.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/google/protobuf/has_bits.h b/src/google/protobuf/has_bits.h
index 133bc02a..cb1d7ccc 100644
--- a/src/google/protobuf/has_bits.h
+++ b/src/google/protobuf/has_bits.h
@@ -61,10 +61,41 @@ class HasBits {
bool operator!=(const HasBits<doublewords>& rhs) const {
return !(*this == rhs);
}
+
+ bool empty() const;
+
private:
::google::protobuf::uint32 has_bits_[doublewords];
};
+template <>
+inline bool HasBits<1>::empty() const {
+ return !has_bits_[0];
+}
+
+template <>
+inline bool HasBits<2>::empty() const {
+ return !(has_bits_[0] | has_bits_[1]);
+}
+
+template <>
+inline bool HasBits<3>::empty() const {
+ return !(has_bits_[0] | has_bits_[1] | has_bits_[2]);
+}
+
+template <>
+inline bool HasBits<4>::empty() const {
+ return !(has_bits_[0] | has_bits_[1] | has_bits_[2] | has_bits_[3]);
+}
+
+template <size_t doublewords>
+inline bool HasBits<doublewords>::empty() const {
+ for (size_t i = 0; i < doublewords; ++i) {
+ if (has_bits_[i]) return false;
+ }
+ return true;
+}
+
} // namespace internal
} // namespace protobuf