From e987fd5dc6bf8cd161e442c8e6231f0334e12dbf Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Thu, 9 Oct 2014 01:06:21 +0300 Subject: [PATCH] clover/util: Define equality operators for a couple of compat classes. --- .../state_trackers/clover/util/compat.hpp | 43 +++++++++++++------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/src/gallium/state_trackers/clover/util/compat.hpp b/src/gallium/state_trackers/clover/util/compat.hpp index ca5b8921a40..eaae8c02940 100644 --- a/src/gallium/state_trackers/clover/util/compat.hpp +++ b/src/gallium/state_trackers/clover/util/compat.hpp @@ -36,6 +36,21 @@ namespace clover { // source. Get rid of this as soon as everything can be // compiled as C++11. + namespace detail { + template + bool + ranges_equal(const R &a, const S &b) { + if (a.size() != b.size()) + return false; + + for (size_t i = 0; i < a.size(); ++i) + if (a[i] != b[i]) + return false; + + return true; + } + } + template class vector { protected: @@ -101,6 +116,11 @@ namespace clover { return *this; } + bool + operator==(const vector &v) const { + return detail::ranges_equal(*this, v); + } + void reserve(size_type n) { if (_capacity < n) { @@ -199,6 +219,11 @@ namespace clover { vector_ref(C &v) : p(&*v.begin()), n(v.size()) { } + bool + operator==(const vector_ref &v) const { + return detail::ranges_equal(*this, v); + } + size_type size() const { return n; @@ -306,6 +331,11 @@ namespace clover { return std::string(v.begin(), v.end()); } + bool + operator==(const string &s) const { + return this->v == s.v; + } + void reserve(size_type n) { v.reserve(n); @@ -382,19 +412,6 @@ namespace clover { mutable vector v; }; - template - bool - operator==(const vector_ref &a, const vector_ref &b) { - if (a.size() != b.size()) - return false; - - for (size_t i = 0; i < a.size(); ++i) - if (a[i] != b[i]) - return false; - - return true; - } - class exception { public: exception() {} -- 2.30.2