summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorFrancisco Jerez <[email protected]>2014-10-09 01:06:21 +0300
committerFrancisco Jerez <[email protected]>2014-10-20 10:33:01 +0300
commite987fd5dc6bf8cd161e442c8e6231f0334e12dbf (patch)
treef624f29890ba33524daa5497e1e5312e93084cc9 /src/gallium
parent1441a3c1bba542f318cfc0f4468ef34f97121a1d (diff)
clover/util: Define equality operators for a couple of compat classes.
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/state_trackers/clover/util/compat.hpp43
1 files 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<typename R, typename S>
+ 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<typename T>
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<char> v;
};
- template<typename T>
- bool
- operator==(const vector_ref<T> &a, const vector_ref<T> &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() {}