diff --git a/include/cppkafka/buffer.h b/include/cppkafka/buffer.h index a1aa580..da831f9 100644 --- a/include/cppkafka/buffer.h +++ b/include/cppkafka/buffer.h @@ -134,16 +134,6 @@ public: return std::vector(data_, data_ + size_); } - /** - * Compares this Buffer for equality - */ - bool operator==(const Buffer& rhs) const; - - /** - * Compares this Buffer for inequality - */ - bool operator!=(const Buffer& rhs) const; - /** * Output operator */ @@ -153,6 +143,16 @@ private: size_t size_; }; +/** + * Compares Buffer objects for equality + */ +bool operator==(const Buffer& lhs, const Buffer& rhs); + +/** + * Compares Buffer objects for inequality + */ +bool operator!=(const Buffer& lhs, const Buffer& rhs); + } // cppkafka #endif // CPPKAFKA_BUFFER_H diff --git a/src/buffer.cpp b/src/buffer.cpp index cdf59b0..a0fbded 100644 --- a/src/buffer.cpp +++ b/src/buffer.cpp @@ -74,17 +74,6 @@ Buffer::operator string() const { return string(data_, data_ + size_); } -bool Buffer::operator==(const Buffer& rhs) const { - if (get_size() != rhs.get_size()) { - return false; - } - return equal(get_data(), get_data() + get_size(), rhs.get_data()); -} - -bool Buffer::operator!=(const Buffer& rhs) const { - return !(*this == rhs); -} - ostream& operator<<(ostream& output, const Buffer& rhs) { for (const uint8_t value : rhs) { if (value >= 0x20 && value < 0x7f) { @@ -101,4 +90,15 @@ ostream& operator<<(ostream& output, const Buffer& rhs) { return output; } +bool operator==(const Buffer& lhs, const Buffer& rhs) { + if (lhs.get_size() != rhs.get_size()) { + return false; + } + return equal(lhs.get_data(), lhs.get_data() + lhs.get_size(), rhs.get_data()); +} + +bool operator!=(const Buffer& lhs, const Buffer& rhs) { + return !(lhs == rhs); +} + } // cppkafka